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); }
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); }
//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); } }
//we are hit 被攻击 public void Hit(DamageObject d) { //Camera Shake CamShake camShake = Camera.main.GetComponent <CamShake>(); if (camShake != null) { camShake.Shake(.2f); } //check for hit anim.SetAnimatorTrigger("Hit1"); enemyState = UNITSTATE.HIT; //add small force from the impact LookAtTarget(d.inflictor.transform); anim.AddForce(-knockbackForce); }
//Attack public void ATTACK() { //don't attack when player is jumping var playerMovement = target.GetComponent <PlayerMovement>(); if (!AttackPlayerAirborne && playerMovement != null && playerMovement.jumpInProgress) { return; } else { //init enemyState = UNITSTATE.ATTACK; Move(Vector3.zero, 0f); LookAtTarget(target.transform); TurnToDir(currentDirection); //pick random attack if (PickRandomAttack) { AttackCounter = Random.Range(0, AttackList.Length); } //play animation animator.SetAnimatorTrigger(AttackList[AttackCounter].animTrigger); //go to the next attack in the list if (!PickRandomAttack) { AttackCounter += 1; if (AttackCounter >= AttackList.Length) { AttackCounter = 0; } } lastAttackTime = Time.time; lastAttack = AttackList [AttackCounter]; lastAttack.inflictor = gameObject; //resume Invoke("Ready", AttackList [AttackCounter].duration); } }
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); }
//perform a jump void Jump() { playerState.SetState(UNITSTATE.JUMPING); JumpNextFixedUpdate = false; jumpInProgress = true; rb.velocity = Vector3.up * JumpForce; //play animation animator.SetAnimatorBool("JumpInProgress", true); animator.SetAnimatorTrigger("JumpUp"); animator.ShowDustEffectJump(); //play sfx if (jumpUpVoice != "") { GlobalAudioPlayer.PlaySFXAtPosition(jumpUpVoice, transform.position); } }
IEnumerator DoJump() { //设置跳跃状态 jumpInProgress = true; playerState.SetState(UNITSTATE.JUMPING); //播放动画 animator.SetAnimatorBool("JumpInProgress", true); animator.SetAnimatorTrigger("JumpUp"); //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()); } //落地 SetVelocity(Vector3.zero); playerState.SetState(UNITSTATE.LAND); animator.SetAnimatorFloat("MovementSpeed", 0f); animator.SetAnimatorBool("JumpInProgress", false); jumpInProgress = false; if (playerState.currentState == UNITSTATE.LAND) { yield return(new WaitForSeconds(landRecoveryTime)); SetPlayerState(UNITSTATE.IDLE); } }