public void TransitionToState(BozuState newState) { BozuState tmpInitialState = CurrentBozuState; OnStateExit(tmpInitialState, newState); CurrentBozuState = newState; OnStateEnter(newState, tmpInitialState); }
public void OnStateExit(BozuState state, BozuState toState) { switch (state) { case BozuState.Idle: { animator.SetBool("Idle", false); break; } case BozuState.Shooting: { animator.SetBool("Shoot", false); break; } case BozuState.Sweep: { animator.SetBool("Sweep", false); break; } case BozuState.Jump: { timeSinceLastJump = 0; verticalMoveSpeed = 0; animator.SetBool("Jump", false); break; } case BozuState.Run: { animator.SetBool("Run", false); break; } case BozuState.Fall: { verticalMoveSpeed = 0; break; } } }
public void OnStateEnter(BozuState state, BozuState fromState) { switch (state) { case BozuState.Idle: { animator.SetBool("Idle", true); dropTimer = 0; stateTimer = 0; break; } case BozuState.Shooting: { Shoot("notflat"); animator.SetBool("Shoot", true); dropTimer = 0; stateTimer = 0; break; } case BozuState.Sweep: { dropTimer = 0; stateTimer = 0; animator.SetBool("Sweep", true); break; } case BozuState.Jump: { GrenadeThrow(); float jumpVelocity; Motor.ForceUnground(); Gravity = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2); maxGravity = Gravity * downMultiplier; jumpVelocity = Mathf.Abs(Gravity) * timeToJumpApex; verticalMoveSpeed = jumpVelocity; if (jumpForwards) { moveSpeed += initialForwardVelocity; } dropTimer = 0; stateTimer = 0; animator.SetBool("Jump", true); break; } case BozuState.Run: { animator.SetBool("Run", true); stateTimer = 0; break; } case BozuState.Fall: { stateTimer = 0; break; } } }