//jump IEnumerator doJump() { //set jump state jumpInProgress = true; playerState.SetState(UNITSTATE.JUMPING); //play animation animator.SetAnimatorBool("JumpInProgress", true); animator.SetAnimatorTrigger("JumpUp"); animator.ShowDustEffectJump(); //play sfx if (jumpUpVoice != "") { GlobalAudioPlayer.PlaySFXAtPosition(jumpUpVoice, transform.position); } //set state yield return(new WaitForFixedUpdate()); //start jump while (isGrounded) { SetVelocity(Vector3.up * JumpForce); yield return(new WaitForFixedUpdate()); } //continue until we hit the ground while (!isGrounded) { yield return(new WaitForFixedUpdate()); } //land playerState.SetState(UNITSTATE.LAND); SetVelocity(Vector3.zero); animator.SetAnimatorFloat("MovementSpeed", 0f); animator.SetAnimatorBool("JumpInProgress", false); animator.SetAnimatorBool("JumpKickActive", false); animator.SetAnimatorBool("JumpPunchActive", false); //LETHAL FORCES - Adding Jump Punch animator.ShowDustEffectLand(); //sfx GlobalAudioPlayer.PlaySFX("FootStep"); if (jumpLandVoice != "") { GlobalAudioPlayer.PlaySFXAtPosition(jumpLandVoice, transform.position); } jumpInProgress = false; if (playerState.currentState == UNITSTATE.LAND) { yield return(new WaitForSeconds(landRecoveryTime)); setPlayerState(UNITSTATE.IDLE); } }
private void DoAttack(DamageObject d, UNITSTATE state, INPUTACTION inputAction) { animator.SetAnimatorTrigger(d.animTrigger); playerState.SetState(state); lastAttack = d; lastAttack.inflictor = gameObject; lastAttackTime = Time.time; lastAttackDirection = currentDirection; TurnToDir(currentDirection); Invoke("Ready", d.duration); }
/// <summary> /// 设置玩家动作状态 /// </summary> /// <param name="state"></param> public void SetPlayerState(UNITSTATE state) { if (playerState != null) { playerState.SetState(state); } else { Debug.LogError("No playerstate found on this gamaobject"); } }
private void doAttack(DamageObject damageObject, UNITSTATE state, string inputAction) { animator.SetAnimatorTrigger(damageObject.animTrigger); playerState.SetState(state); //save attack data lastAttack = damageObject; lastAttack.inflictor = gameObject; lastAttackTime = Time.time; lastAttackInput = inputAction; lastAttackDirection = currentDirection; //turn towards current input direction TurnToDir(currentDirection); if (isGrounded) { SetVelocity(Vector3.zero); } if (damageObject.forwardForce > 0) { animator.AddForce(damageObject.forwardForce); } if (state == UNITSTATE.JUMPKICK) { return; } Invoke("Ready", damageObject.duration); }
void FixedUpdate() { if (!MovementStates.Contains(playerState.currentState) || isDead) { return; } //start a jump if (JumpNextFixedUpdate) { Jump(); return; } //land after a jump if (jumpInProgress && IsGrounded()) { HasLanded(); return; } //continue after landing if (playerState.currentState == UNITSTATE.LAND && Time.time - landTime > landRecoveryTime) { playerState.SetState(UNITSTATE.IDLE); } //air and ground Movement bool isGrounded = IsGrounded(); animator.SetAnimatorBool("isGrounded", isGrounded); if (isGrounded) { MoveGrounded(); } else { MoveAirborne(); } //always turn towards the current direction TurnToCurrentDirection(); }
private void doAttack(DamageObject d, UNITSTATE state, INPUTACTION inputAction) { animator.SetAnimatorTrigger(d.animTrigger); playerState.SetState(state); lastAttack = d; lastAttack.inflictor = gameObject; lastAttackTime = Time.time; lastAttackInput = inputAction; lastAttackDirection = currentDirection; TurnToDir(currentDirection); SetVelocity(Vector3.zero); if (state == UNITSTATE.JUMPKICK) { return; } Invoke("Ready", d.duration); }