Skip to content

Commit

Permalink
I FUCKING FIXED THIS SHIT DON'T BLOODY FORGET TO UNSUBSCRIBE TO EVENT…
Browse files Browse the repository at this point in the history
…S!!!!!
  • Loading branch information
JariBou committed Jan 13, 2023
1 parent 1bd920c commit 9d5f589
Show file tree
Hide file tree
Showing 5 changed files with 708 additions and 533 deletions.
3 changes: 2 additions & 1 deletion Assets/Scripts/PlayerBundle/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class Player : MonoBehaviour

[HideInInspector]
public SpriteRenderer sprite;
public Animator animator { get; private set; }
public Animator animator { get; set; }
public static Player instance;

[Header("Heat Mechanic")]
Expand All @@ -68,6 +68,7 @@ public class Player : MonoBehaviour
private BraceletUpgrades _braceletUpgrades;

void Awake() {
Debug.Log("AWAKENING PLAYER");
instance = this;

playerActions = new PlayerActions();
Expand Down
59 changes: 46 additions & 13 deletions Assets/Scripts/PlayerBundle/PlayerInputsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class PlayerInputsHandler : MonoBehaviour
// TODO: Problem if is composite like wasd, using InputAction.name should resolve that

public Dictionary<string, int> spellLinks;
private static readonly int XMovement = Animator.StringToHash("xMovement");
private static readonly int YMovement = Animator.StringToHash("yMovement");
private static readonly int Speed = Animator.StringToHash("speed");

public static event Action<InputAction.CallbackContext> KeyPressedEvent;

Expand Down Expand Up @@ -73,40 +76,70 @@ private void Awake()
private void Start()
{
player = Player.instance;
KeyPressedEvent += ResolveKeyPressed;
Debug.Log(player);
Debug.Log($"Player Animator: {player.animator}");
}

private void OnEnable()
{
playerActions.Playermaps.Enable();
KeyPressedEvent += ResolveKeyPressed;
}

private void OnDisable()
{
playerActions.Playermaps.Disable();
KeyPressedEvent -= ResolveKeyPressed;
}


private void Move(InputAction.CallbackContext context)
{
Vector2 moveVector = context.ReadValue<Vector2>().normalized;
player.SetMoveVector(moveVector);

if ((int)moveVector.x == 1 && (int)moveVector.y == 0)
{
player.animator.SetInteger(player.Facing, 3);
} else if ((int)moveVector.x == -1 && (int)moveVector.y == 0)

// TODO: Problem, the script is apparently destroyed here??
try
{
player.animator.SetInteger(player.Facing, 9);
} else if (Mathf.Abs((int)moveVector.y) == 1)
if ((int)moveVector.x == 1 && (int)moveVector.y == 0)
{
player.animator.SetInteger(player.Facing, 3);
} else if ((int)moveVector.x == -1 && (int)moveVector.y == 0)
{
player.animator.SetInteger(player.Facing, 9);
} else if (Mathf.Abs((int)moveVector.y) == 1)
{
player.animator.SetInteger(player.Facing, 9 + 3*(int)moveVector.y);
}


player.animator.SetFloat(XMovement, moveVector.x);
player.animator.SetFloat(YMovement, moveVector.y);
player.animator.SetFloat(Speed, moveVector.sqrMagnitude);
}
catch (Exception e)
{
player.animator.SetInteger(player.Facing, 9 + 3*(int)moveVector.y);
}
// TODO: We need to remake an animator????
player.animator = GetComponent<Animator>();


if ((int)moveVector.x == 1 && (int)moveVector.y == 0)
{
player.animator.SetInteger(player.Facing, 3);
} else if ((int)moveVector.x == -1 && (int)moveVector.y == 0)
{
player.animator.SetInteger(player.Facing, 9);
} else if (Mathf.Abs((int)moveVector.y) == 1)
{
player.animator.SetInteger(player.Facing, 9 + 3*(int)moveVector.y);
}


player.animator.SetFloat("xMovement", moveVector.x);
player.animator.SetFloat("yMovement", moveVector.y);
player.animator.SetFloat("speed", moveVector.sqrMagnitude);
player.animator.SetFloat(XMovement, moveVector.x);
player.animator.SetFloat(YMovement, moveVector.y);
player.animator.SetFloat(Speed, moveVector.sqrMagnitude);
}


}

Expand Down
8 changes: 4 additions & 4 deletions UserSettings/EditorUserSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ EditorUserSettings:
value: 5004055f04020f0b0f0b5a7647755b4442154a7f2a717e612c704b60e7b36368
flags: 0
RecentlyUsedSceneGuid-6:
value: 07540c5f5d030a0c5f575a75447b094444161979297971607f7c1866bae6356f
value: 5a030d535606595f0c595a7416745d4444151d7a287f7e67792c4c61bae56d3c
flags: 0
RecentlyUsedSceneGuid-7:
value: 5a030d535606595f0c595a7416745d4444151d7a287f7e67792c4c61bae56d3c
value: 5606525053075e0a0e585a7446265944444f417f2d7e22642f714a64b4e4306a
flags: 0
RecentlyUsedSceneGuid-8:
value: 5606525053075e0a0e585a7446265944444f417f2d7e22642f714a64b4e4306a
value: 57530c5f04575b590e5e5c2046720844144f4b2e2a7c74687f704c30e7e33061
flags: 0
RecentlyUsedSceneGuid-9:
value: 57530c5f04575b590e5e5c2046720844144f4b2e2a7c74687f704c30e7e33061
value: 07540c5f5d030a0c5f575a75447b094444161979297971607f7c1866bae6356f
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650
Expand Down
Loading

0 comments on commit 9d5f589

Please sign in to comment.