Refactor: Dash
Repositioned some parts of dash code into skillHandler
This commit is contained in:
@@ -9,6 +9,9 @@ public class PlayerMovement : MonoBehaviour
|
||||
public float gravity = -9.81f;
|
||||
public float rotationSpeed = 10f;
|
||||
|
||||
public float dashSpeed;
|
||||
public float dashDuration;
|
||||
|
||||
private CharacterController controller;
|
||||
private Vector3 velocity;
|
||||
private Vector3 move;
|
||||
@@ -18,7 +21,7 @@ public class PlayerMovement : MonoBehaviour
|
||||
private void Awake()
|
||||
{
|
||||
PlayerSkills = PlayerSkillTree.Instance;
|
||||
playerSkillHandler = new PlayerSkillHandler();
|
||||
playerSkillHandler = new PlayerSkillHandler(dashSpeed, dashDuration);
|
||||
}
|
||||
|
||||
void Start()
|
||||
@@ -30,10 +33,9 @@ public class PlayerMovement : MonoBehaviour
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
/* Ugly part here, need to rewrite later */
|
||||
/* Get the input for horizontal and vertical movement */
|
||||
float moveX = Input.GetAxisRaw("Horizontal");
|
||||
float moveZ = Input.GetAxisRaw("Vertical");
|
||||
/* End of the ugly part :P */
|
||||
|
||||
move = new Vector3(moveX, 0, moveZ).normalized;
|
||||
StartCoroutine(playerSkillHandler.DashCoroutine(controller, move));
|
||||
@@ -54,15 +56,6 @@ public class PlayerMovement : MonoBehaviour
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
if (playerSkillHandler.IsDashing())
|
||||
{
|
||||
Physics.IgnoreLayerCollision(6, 7, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Physics.IgnoreLayerCollision(6, 7, false);
|
||||
}
|
||||
|
||||
HandleMovement();
|
||||
ApplyGravity();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user