| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using ActionGameFramework.Health; |
| | | using Core.Health; |
| | |
| | | /// <summary> |
| | | /// 动画器. |
| | | /// </summary> |
| | | protected Animator mAnim; |
| | | public Animator ActionAnimator; |
| | | |
| | | protected AnimationClip[] clips; |
| | | |
| | | protected bool bInDeathAct = false; |
| | | |
| | |
| | | get { return this.m_NavMeshAgent; } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 是否显示目标位置信息 |
| | | /// </summary> |
| | | public bool bShowDebugNode = false; |
| | | |
| | | |
| | | /// <summary> |
| | | /// 持续寻路,起到寻路成功 |
| | |
| | | /// </summary> |
| | | public float originalMovementSpeed { get; protected set; } |
| | | |
| | | /// <summary> |
| | | /// 小怪的动作状态 |
| | | /// </summary> |
| | | public AgentActionState ActionState { get; protected set; } |
| | | |
| | | private string paramName = "AgentActionState"; |
| | | |
| | | /// <summary> |
| | | /// 更新怪物的移动速度。 |
| | |
| | | timeToPoisonHurt = 0; |
| | | bShieldBreak = false; |
| | | bInDeathAct = false; |
| | | |
| | | ChangeState(AgentActionState.Move); |
| | | configuration.ClearShieldWall(); |
| | | |
| | | StopFrostParticle(); |
| | |
| | | return; |
| | | } |
| | | |
| | | float atime = 0; |
| | | |
| | | /// <summary> |
| | | /// 更新动作信息. |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | protected void UpdateAction() |
| | | { |
| | | if (mAnim) |
| | | { |
| | | AnimatorStateInfo stateinfo = mAnim.GetCurrentAnimatorStateInfo(0); |
| | | AnimatorStateInfo stateInfo = ActionAnimator.GetCurrentAnimatorStateInfo(0); |
| | | |
| | | if (stateinfo.IsName("Die") && (stateinfo.normalizedTime >= 0.7f)) |
| | | switch (ActionState) |
| | | { |
| | | this.Remove(); |
| | | } |
| | | else if (stateinfo.IsName("GetHit") && (stateinfo.normalizedTime >= 0.7f)) |
| | | case AgentActionState.Move: |
| | | break; |
| | | case AgentActionState.GetHit: |
| | | if (stateInfo.normalizedTime >= 1f) |
| | | ChangeState(AgentActionState.Move); |
| | | break; |
| | | case AgentActionState.Attack: |
| | | if (stateInfo.normalizedTime >= 1f) |
| | | { |
| | | mAnim.SetBool("GetHit", false); |
| | | } |
| | | else if (stateinfo.IsName("Attack") && (stateinfo.normalizedTime >= 0.9f)) |
| | | if (isDead) |
| | | { |
| | | if (this.healthVal <= 0.1) |
| | | { |
| | | // 统一管理器内删除当前的Agent: |
| | | AgentInsManager.instance.removeAgent(this); |
| | | this.Remove(); |
| | | Remove(); |
| | | } |
| | | } |
| | | break; |
| | | case AgentActionState.Death: |
| | | if (stateInfo.normalizedTime >= 1f) |
| | | Remove(); |
| | | break; |
| | | } |
| | | else if (changeMat) |
| | | { |
| | | } |
| | | |
| | | } |
| | | private void ChangeState(AgentActionState state) |
| | | { |
| | | if (state == ActionState) return; |
| | | |
| | | ActionState = state; |
| | | ActionAnimator.SetInteger(paramName, (int)state); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// Reset destination when path is stale |
| | | /// River: 更新的时候,加入离最终目标的距离数据. |
| | | /// </summary> |
| | | protected virtual void Update() |
| | | protected virtual void LateUpdate() |
| | | { |
| | | this.UpdateAction(); |
| | | HandleShieldWall(); |
| | |
| | | // 计算中毒相关. |
| | | if ((poisonTimes > 0) && (poisonHurt > 0)) |
| | | updatePoison(Time.deltaTime); |
| | | } |
| | | |
| | | protected virtual void Update() |
| | | { |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | if (!endlessLevelManager) |
| | | endlessLevelManager = EndlessLevelManager.instance; |
| | | |
| | | if (mAnim == null) |
| | | { |
| | | foreach (Transform t in transform.GetComponentsInChildren<Transform>()) |
| | | { |
| | | if (t.name == "Model") |
| | | mAnim = t.GetComponent<Animator>(); |
| | | } |
| | | } |
| | | |
| | | //使用三渲二的方式 |
| | | if (mAnim == null) |
| | | { |
| | | changeMat = GetComponent<ChangeMat>(); |
| | | changeMat?.SetSelf(this.opponentAgent, CheckHealth, Die); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public void PlayOnHit() |
| | | { |
| | | if (mAnim) |
| | | mAnim.SetBool("GetHit", true); |
| | | else if (changeMat) |
| | | { |
| | | changeMat.SetGetHit(); |
| | | } |
| | | ChangeState(AgentActionState.GetHit); |
| | | } |
| | | |
| | | public void PlayAttack() |
| | | { |
| | | AudioSourceManager.Ins.Play(AudioEnum.AttackTower); |
| | | if (mAnim) |
| | | mAnim.SetBool("Attack", true); |
| | | else if (changeMat) |
| | | { |
| | | changeMat.SetAttack(); |
| | | } |
| | | ChangeState(AgentActionState.Attack); |
| | | } |
| | | |
| | | public override void PlayDeath() |
| | | { |
| | | if (mAnim) |
| | | { |
| | | if (isPoison) |
| | | { |
| | | isPoison = false; |
| | |
| | | } |
| | | } |
| | | |
| | | mAnim.SetBool("Die", true); |
| | | ChangeState(AgentActionState.Death); |
| | | // 统一管理器内删除当前的Agent: |
| | | AgentInsManager.instance.removeAgent(this); |
| | | bInDeathAct = true; |
| | | } |
| | | else if (changeMat) |
| | | { |
| | | if (isPoison) |
| | | { |
| | | isPoison = false; |
| | | // 移除Agent身上的中毒特效,并播放一个中毒效果消失的特效 |
| | | if (PoisonParticle != null) |
| | | { |
| | | PoisonParticle.Stop(); |
| | | PoisonParticle.Clear(); |
| | | if (PoisonEndParticle != null) |
| | | PoisonEndParticle.Play(); |
| | | } |
| | | } |
| | | |
| | | if (isSlowDown) |
| | | { |
| | | isSlowDown = false; |
| | | |
| | | if (SlowDownParticle != null) |
| | | { |
| | | SlowDownParticle.Stop(); |
| | | SlowDownParticle.Clear(); |
| | | } |
| | | } |
| | | changeMat.SetDie(); |
| | | // 统一管理器内删除当前的Agent: |
| | | AgentInsManager.instance.removeAgent(this); |
| | | bInDeathAct = true; |
| | | } |
| | | else |
| | | { |
| | | this.Remove(); |
| | | } |
| | | } |
| | | |
| | | IEnumerator WaitDeathStop() |
| | | { |
| | | yield return null; |
| | | AnimatorStateInfo stateinfo = mAnim.GetCurrentAnimatorStateInfo(0); |
| | | |
| | | if (stateinfo.IsName("Die") && (stateinfo.normalizedTime >= 1.0f)) |
| | | { |
| | | Debug.Log("死亡动画播放完成,开始处理."); |
| | | this.Remove(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |