protected override void Awake() { base.Awake(); m_currentPlayerState = E_PlayerStates.STATE_IDLE; m_isGrounded.Value = true; m_isRunning.Value = false; m_playerLife.Value = 2; m_playerStamina.Value = 100; m_playerAttacks.Value = 100; m_timer.Value = 0; }
protected override void Update() { base.Update(); switch (m_currentPlayerState) { case E_PlayerStates.STATE_IDLE: if (m_xInput.Value != 0) { m_currentPlayerState = E_PlayerStates.STATE_WALK; } if (Input.GetButtonDown("Jumping") || Input.GetKeyDown(KeyCode.Space) || m_isGrounded.Value == false) { m_currentPlayerState = E_PlayerStates.STATE_JUMP; } if (Input.GetButtonDown("ColorSwap") || Input.GetKeyDown(KeyCode.Tab)) { m_currentPlayerState = E_PlayerStates.STATE_COLORSWAP; if (m_AgilityMode.Value == true) { m_AgilityMode.Value = false; } else { m_AgilityMode.Value = true; } } break; case E_PlayerStates.STATE_WALK: if (m_xInput.Value == 0) { m_currentPlayerState = E_PlayerStates.STATE_IDLE; } if (Input.GetButton("Running") || Input.GetKey(KeyCode.LeftShift)) { m_currentPlayerState = E_PlayerStates.STATE_RUN; } if (Input.GetButtonDown("Jumping") || Input.GetKeyDown(KeyCode.Space)) { m_currentPlayerState = E_PlayerStates.STATE_JUMP; } if (Input.GetButtonDown("ColorSwap") || Input.GetKeyDown(KeyCode.Tab)) { m_currentPlayerState = E_PlayerStates.STATE_COLORSWAP; if (m_AgilityMode.Value == true) { m_AgilityMode.Value = false; } else { m_AgilityMode.Value = true; } } break; case E_PlayerStates.STATE_RUN: if (Input.GetButtonUp("Running") || Input.GetKeyUp(KeyCode.LeftShift)) { m_currentPlayerState = E_PlayerStates.STATE_WALK; } if (Input.GetButtonDown("ColorSwap") || Input.GetKeyDown(KeyCode.Tab)) { m_currentPlayerState = E_PlayerStates.STATE_COLORSWAP; if (m_AgilityMode.Value == true) { m_AgilityMode.Value = false; } else { m_AgilityMode.Value = true; } } break; case E_PlayerStates.STATE_JUMP: if (m_isGrounded.Value == true) { m_currentPlayerState = E_PlayerStates.STATE_IDLE; } if (Input.GetButtonDown("ColorSwap") || Input.GetKeyDown(KeyCode.Tab)) { m_currentPlayerState = E_PlayerStates.STATE_COLORSWAP; if (m_AgilityMode.Value == true) { m_AgilityMode.Value = false; } else { m_AgilityMode.Value = true; } } break; case E_PlayerStates.STATE_COLORSWAP: if (m_isGrounded.Value == false || Input.GetButtonDown("Jumping") || Input.GetKeyDown(KeyCode.Space)) { m_currentPlayerState = E_PlayerStates.STATE_JUMP; } if (m_xInput.Value == 0) { m_currentPlayerState = E_PlayerStates.STATE_IDLE; } if (m_xInput.Value != 0) { m_currentPlayerState = E_PlayerStates.STATE_WALK; } if (Input.GetButton("Running") || Input.GetKey(KeyCode.LeftShift)) { m_currentPlayerState = E_PlayerStates.STATE_RUN; } break; } if (m_playerLife.Value == 0) { Destroy(gameObject); } }