using System.Collections; using System.Collections.Generic; using System.Linq; using System; using UnityEngine; using UnityEngine.InputSystem; public class PlayerInput : MonoBehaviour, IMoveData { private MoveData moveData = new(); public Gamepad controller { get; private set; } public bool whipAttack; public event Action ropeLengthShrinken; public event Action ropeLengthExtend; public event Action OnNewMoveData; public int PlayerNum = 0; //private void Start() //{ // controller = Gamepad.all.ElementAtOrDefault(PlayerNum); // if (controller == null) // { // Debug.LogWarning($"No Gamepad found for player {PlayerNum + 1}"); // } //} private void Update() { if (PlayerNum == 0) { moveData.Movement.x = Input.GetAxisRaw("Horizontal"); moveData.Movement.y = Input.GetAxisRaw("Vertical"); } else { moveData.Movement.x = Input.GetAxisRaw("ArrowHorizontal"); moveData.Movement.y = Input.GetAxisRaw("ArrowVertical"); } //whipAttack = Input.GetKey(KeyCode.R); //if (Input.GetKey(KeyCode.E)) ropeLengthShrinken?.Invoke(PlayerNum); //if (Input.GetKey(KeyCode.Q)) ropeLengthExtend?.Invoke(PlayerNum); OnNewMoveData?.Invoke(moveData); } }