void Start() { i_trail = GetComponent <TrailRenderer>(); i_trail.enabled = false; vAux_currentParryColdown = v_coolDownParryTimer; i_currentCollider = i_shieldCollider; v_shieldState = S_ShieldState.Hide; v_playerPosition = transform.localPosition; vAux_originalX = this.transform.localPosition.x; }
public void ChangeShieldState(S_ShieldState current, S_ShieldState next) { if (v_active) { switch (current) { case S_ShieldState.Hide: switch (next) { case S_ShieldState.Protect: i_player.i_sound.PlayPrepareBlock(); if (i_player.v_playerDirection == S_Direction.Right) { this.transform.localPosition = new Vector3(vAux_originalX, this.transform.localPosition.y); } else { this.transform.localPosition = new Vector3(-vAux_originalX, this.transform.localPosition.y); } if (!i_player.vAux_knocback) { i_player.v_speed = v_blockingSpeed; } i_currentCollider = i_shieldCollider; i_currentCollider.enabled = true; if (i_player.v_playerState == S_PlayerState.Idle) { i_player.ChangeAnimation(S_PlayerAnimation.IdleBlock); } else if (i_player.v_playerState == S_PlayerState.Run) { i_player.ChangeAnimation(S_PlayerAnimation.WalkBlock); } v_shieldState = next; break; case S_ShieldState.Released: if (CanThrow()) { i_player.i_sound.PlayThrow(); i_trail.enabled = true; vAux_releasedShieldTimer = 1.5f; i_currentCollider = i_shieldCollider; i_player.ChangeAnimation(S_PlayerAnimation.Throw); i_player.ChangeToLastAnimation(0.32f); Invoke("Throw", 0.24f); v_shieldState = next; } break; case S_ShieldState.Parry: if (i_player.v_playerDirection == S_Direction.Right) { this.transform.localPosition = new Vector3(vAux_originalX, this.transform.localPosition.y); } else { this.transform.localPosition = new Vector3(-vAux_originalX, this.transform.localPosition.y); } if (i_player.v_playerState == S_PlayerState.Jump) { i_player.i_sound.PlayParry(); i_player.ChangeAnimation(S_PlayerAnimation.ParryJump); i_player.ChangeToLastAnimation(0.25f); i_currentCollider = i_jumpParryCollider; i_currentCollider.enabled = true; v_shieldState = next; } else if (i_player.v_playerState == S_PlayerState.Idle || i_player.v_playerState == S_PlayerState.Run) { i_player.i_sound.PlayParry(); i_player.ChangeAnimation(S_PlayerAnimation.ParryGround); i_player.ChangeToLastAnimation(0.25f); if (i_player.v_playerDirection == S_Direction.Right) { transform.localPosition = v_playerPosition; } else { transform.localPosition = v_secondPlayerPosition; } i_currentCollider = i_groundParryCollider; i_currentCollider.enabled = true; v_shieldState = next; } break; } break; case S_ShieldState.Protect: switch (next) { case S_ShieldState.Hide: if (i_player.v_playerDirection == S_Direction.Right) { this.transform.localPosition = new Vector3(vAux_originalX, this.transform.localPosition.y); } else { this.transform.localPosition = new Vector3(-vAux_originalX, this.transform.localPosition.y); } if (!i_player.vAux_knocback) { i_player.v_speed = i_player.vAux_TemporalSpeed; } i_currentCollider.enabled = false; i_myRenderer.enabled = false; if (i_player.v_playerState == S_PlayerState.Idle) { i_player.ChangeAnimation(S_PlayerAnimation.Idle); } else if (i_player.v_playerState == S_PlayerState.Run) { i_player.ChangeAnimation(S_PlayerAnimation.Run); } v_shieldState = next; break; case S_ShieldState.Released: i_trail.enabled = true; vAux_releasedShieldTimer = 1.5f; if (!i_player.vAux_knocback) { i_player.v_speed = i_player.vAux_TemporalSpeed; } if (Throw()) { v_shieldState = next; } break; } break; case S_ShieldState.Released: switch (next) { case S_ShieldState.Platform: v_shieldState = next; break; case S_ShieldState.Returning: Return(); v_shieldState = next; break; case S_ShieldState.Hide: if (i_player.v_playerDirection == S_Direction.Right) { this.transform.localPosition = new Vector3(vAux_originalX, this.transform.localPosition.y); } else { this.transform.localPosition = new Vector3(-vAux_originalX, this.transform.localPosition.y); } if (i_player.v_playerState == S_PlayerState.Idle) { i_player.ChangeAnimation(S_PlayerAnimation.Idle); } else if (i_player.v_playerState == S_PlayerState.Run) { i_player.ChangeAnimation(S_PlayerAnimation.Run); } i_currentCollider = i_shieldCollider; i_currentCollider.enabled = false; i_myRenderer.enabled = false; v_shieldState = next; break; } break; case S_ShieldState.Platform: switch (next) { case S_ShieldState.Returning: i_player.i_sound.PlayShieldReturn(); Return(); i_currentCollider.enabled = false; v_shieldState = next; break; } break; case S_ShieldState.Returning: switch (next) { case S_ShieldState.Hide: i_player.i_sound.PlayCatch(); i_trail.enabled = false; if (i_player.v_playerDirection == S_Direction.Right) { this.transform.localPosition = new Vector3(vAux_originalX, this.transform.localPosition.y); } else { this.transform.localPosition = new Vector3(-vAux_originalX, this.transform.localPosition.y); } if (i_player.v_playerState == S_PlayerState.Idle) { i_player.ChangeAnimation(S_PlayerAnimation.Idle); } else if (i_player.v_playerState == S_PlayerState.Run) { i_player.ChangeAnimation(S_PlayerAnimation.Run); } i_currentCollider = i_shieldCollider; i_currentCollider.enabled = false; i_myRenderer.enabled = false; v_shieldState = next; break; case S_ShieldState.Protect: i_player.i_sound.PlayPrepareBlock(); i_trail.enabled = false; if (i_player.v_playerDirection == S_Direction.Right) { this.transform.localPosition = new Vector3(vAux_originalX, this.transform.localPosition.y); } else { this.transform.localPosition = new Vector3(-vAux_originalX, this.transform.localPosition.y); } if (i_player.v_playerState == S_PlayerState.Idle) { i_player.ChangeAnimation(S_PlayerAnimation.IdleBlock); } else if (i_player.v_playerState == S_PlayerState.Run) { i_player.ChangeAnimation(S_PlayerAnimation.WalkBlock); } i_currentCollider = i_shieldCollider; i_currentCollider.enabled = true; i_myRenderer.enabled = false; i_player.v_speed = v_blockingSpeed; v_shieldState = next; break; } break; case S_ShieldState.Parry: switch (next) { case S_ShieldState.Hide: if (i_player.v_playerDirection == S_Direction.Right) { this.transform.localPosition = new Vector3(vAux_originalX, this.transform.localPosition.y); } else { this.transform.localPosition = new Vector3(-vAux_originalX, this.transform.localPosition.y); } i_currentCollider.enabled = false; v_shieldState = next; break; } break; } } }