using MontanaJohns.Core.Interfaces; using MontanaJohns.Items; using UnityEngine; using UnityEngine.InputSystem; namespace MontanaJohns.Actors { [RequireComponent(typeof(Rigidbody2D))] public class Player : Actor, IFollowable { public Transform ActorTransform => _transform; public Camera MainCamera => _camera; public GameObject projectilePrefab; public Transform firePoint; Camera _camera; PlayerInput playerInput; InputAction use, move, jump; protected override void Awake() { base.Awake(); _camera = FindObjectOfType(); playerInput = GetComponent(); move = playerInput.currentActionMap.FindAction("Move"); jump = playerInput.currentActionMap.FindAction("Jump"); use = playerInput.currentActionMap.FindAction("Use"); jump.started += context => Jump(); use.started += context => Use(); use.started += context => Fire(); } protected override void Start() { base.Start(); GameObject loadedItem = (GameObject)Instantiate(Resources.Load("ActiveItems/Whip")); activeItem = loadedItem.GetComponent(); stats = baseStats + activeItem.stats; } protected void Update() { ((IFollowable)this).Follow(); if(isGrappling) { base.Grapple(move.ReadValue().x, move.ReadValue().y, (Vector2)grapplePoint); } else { base.Move(move.ReadValue().x); } } protected void Fire() { Instantiate(projectilePrefab, firePoint.position, firePoint.rotation); } } }