Skip to content

Commit

Permalink
Soul Walk
Browse files Browse the repository at this point in the history
-Soul Walk completed and working fully functional

! Visuals-Effects needed !

Issue Key: NAOR-75
  • Loading branch information
AbdyTekin committed Feb 22, 2024
1 parent 7dbb430 commit 1ac05c2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 6 deletions.
29 changes: 26 additions & 3 deletions Assets/Scripts/Player/Scripts/AbilityManager.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System.Collections;
using UltimateCC;
using Unity.VisualScripting;
using UnityEngine;

public class AbilityManager : MonoBehaviour
{
private PlayerData playerData;
private PlayerMain player;

public enum Phase { Off, Start, End, Active }
[System.Serializable]
Expand Down Expand Up @@ -41,7 +40,7 @@ public class SoulWalkVariables

private void Awake()
{
playerData = GetComponent<PlayerMain>().PlayerData;
player = GetComponent<PlayerMain>();
SoulWalk.manaSoulSystem = GetComponent<ManaSoulSystem>();
}

Expand Down Expand Up @@ -129,10 +128,34 @@ public void HandleSoulWalk()
if (SoulWalk.phase == Phase.Start)
{
SoulWalk.phase = Phase.Active;

if (player.CurrentState == PlayerMain.AnimName.CrouchIdle || player.CurrentState == PlayerMain.AnimName.CrouchWalk)
{
SoulWalk.IsInvisible = true;
}
player._stateMachine.OnStateEnter += CheckCrouchAndDash;
}
else if (SoulWalk.phase == Phase.End)
{
SoulWalk.phase = Phase.Off;

player._stateMachine.OnStateEnter -= CheckCrouchAndDash;
}
}

public void CheckCrouchAndDash(PlayerMain.AnimName state)
{
if (state == PlayerMain.AnimName.CrouchWalk || state == PlayerMain.AnimName.CrouchIdle)
{
SoulWalk.IsInvisible = true;
}
else
{
if (state == PlayerMain.AnimName.Dash && !SoulWalk.CanDash)
{
SoulWalk.phase = Phase.End;
}
SoulWalk.IsInvisible = false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class MainState
protected PlayerMain player;
protected PlayerStateMachine stateMachine;
protected Rigidbody2D rigidbody2D;
protected readonly PlayerMain.AnimName _animEnum;
public readonly PlayerMain.AnimName _animEnum;
protected PlayerData playerData;
protected PlayerInputManager inputManager;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,18 @@ public void Move1D()
else if (!playerData.Physics.IsOnNotWalkableSlope)
{
newVelocity = VelocityOnX();
rigidbody2D.velocity = -1 * newVelocity * playerData.Physics.WalkSpeedDirection.normalized;

var abilityManager = player.GetComponent<AbilityManager>();

rigidbody2D.velocity = -1 * newVelocity * playerData.Physics.WalkSpeedDirection.normalized * (abilityManager.SoulWalk.phase == AbilityManager.Phase.Active ? abilityManager.SoulWalk.walkMultiplier : 1);
}
else
{
newVelocity = VelocityOnX();
rigidbody2D.velocity = new Vector2(newVelocity, rigidbody2D.velocity.y);

var abilityManager = player.GetComponent<AbilityManager>();

rigidbody2D.velocity = new Vector2(newVelocity * (abilityManager.SoulWalk.phase == AbilityManager.Phase.Active ? abilityManager.SoulWalk.walkMultiplier : 1), rigidbody2D.velocity.y);
}
localXVelovity = rigidbody2D.velocity.x;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
using System;

namespace UltimateCC
{
[System.Serializable]
public class PlayerStateMachine
{
public event Action<PlayerMain.AnimName> OnStateEnter;
public event Action<PlayerMain.AnimName> OnStateExit;

// Declaration of current runtime state
public MainState CurrentState { get; private set; }

Expand All @@ -17,8 +22,11 @@ public void Initialize(MainState startingState)
public void ChangeState(MainState newState)
{
CurrentState.Exit();
OnStateExit?.Invoke(CurrentState._animEnum);
CurrentState = newState;
CurrentState.Enter();
OnStateEnter?.Invoke(CurrentState._animEnum);

}
}
}

0 comments on commit 1ac05c2

Please sign in to comment.