blob: 1edbbd7b23d79e1efd15db444970a09a1403fd7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
using MontanaJohns.Core.Interfaces;
using MontanaJohns.Items;
using UnityEngine;
using UnityEngine.InputSystem;
namespace MontanaJohns.Actors
{
[RequireComponent(typeof(Rigidbody2D))]
[RequireComponent(typeof(CapsuleCollider2D))]
public class Player : Actor, IFollowable
{
public Transform ActorTransform => _transform;
public Camera MainCamera => _camera;
Camera _camera;
PlayerInput playerInput;
InputAction use, move, jump;
protected override void Awake()
{
base.Awake();
_camera = FindObjectOfType<Camera>();
playerInput = GetComponent<PlayerInput>();
move = playerInput.currentActionMap.FindAction("Move");
jump = playerInput.currentActionMap.FindAction("Jump");
use = playerInput.currentActionMap.FindAction("Use");
jump.started += context => Jump();
use.started += context => Use();
move.started += context => Debug.Log("Moving!");
move.performed += context => Debug.Log("Stopping!");
}
protected override void Start()
{
base.Start();
activeItem = gameObject.AddComponent<Whip>();
}
protected void Update()
{
((IFollowable)this).Follow();
base.Move(move.ReadValue<Vector2>().x);
}
}
}
|