// 唤醒敌人 private void WakeUp() { if (currentMotionState == MotionState.Sleeping) { Transform player = zombieSensorController.GetNearByPlayer(); if (player == null) { return; } currentMotionState = MotionState.WakingUp; animator.SetTrigger("WakeUp"); } if (currentMotionState == MotionState.WakingUp) { AnimatorStateInfo state = animator.GetCurrentAnimatorStateInfo(0); if (state.IsName("BaseLayer.StandUpFromSleep")) { if (state.normalizedTime > 0.9f) { currentMotionState = MotionState.Idling; } if (state.normalizedTime < 0.2f) { if (!audioSource.isPlaying) { AudioClipLoader.Instance.LoadAudioClipAndPlay(audioSource, "ZombieAttack.wav"); } } } } }
void Update() { if (GameManager.Instance.CurrentGameState != GameManager.GameState.Play) { return; } if (motionController.CurrentMotionState != MotionState.Attacking) { return; } Transform player = sensorController.GetNearByPlayer(); if (player == null) { return; } AnimatorStateInfo state = animator.GetCurrentAnimatorStateInfo(0); if (state.IsName("BaseLayer.Attack")) { if (state.normalizedTime > 0.3f && state.normalizedTime < 0.5f) { if (attackFlag) { return; } if (Vector3.Distance(player.position, transform.position) > attackRadius) { return; } Vector3 direction = player.position - transform.position; float angle = Vector3.Angle(transform.forward, direction); if (angle <= attackRightSideAngle && angle >= attackLeftSideAngle) { PlayerHealthManager playerHealth = player.GetComponent <PlayerHealthManager>(); playerHealth.ReduceHealth(transform.position, damage); attackFlag = true; } } if (state.normalizedTime > 0.9f) { attackFlag = false; } } }
void Update() { if (GameManager.Instance.CurrentGameState != GameManager.GameState.Play) { return; } if (motionController.CurrentMotionState == MotionState.Dead) { resurgenceCount += Time.deltaTime; if (resurgenceCount >= resurgenceTime) { motionController.Resurgence(); health = 200; resurgenceCount = 0; } return; } if (health <= 0) { motionController.DeadTrigger(); return; } Transform player = sensorController.GetNearByPlayer(); if (player == null) { return; } if (SpinKickAble(player, motionController.CurrentMotionState)) { if (CrossPlatformInputManager.GetButton("J")) { PlayerMotionController pmc = player.GetComponent <PlayerMotionController>(); pmc.SpinKickTrigger(); } } }