weixudong
2020-11-19 69e0fea6c92fd4e153d45e5f26ef89baecf0405a
Assets/Scripts/TowerDefense/Agents/Agent.cs
@@ -455,6 +455,12 @@
        /// </summary>
        public override void Remove()
        {
            GameObject prefab = Resources.Load<GameObject>("Prefabs/Endless/AgentDeathEffect");
            GameObject obj = Poolable.TryGetPoolable(prefab);
            obj.transform.position = transform.position;
            ParticleSystem ps = obj.transform.GetChild(0).GetComponent<ParticleSystem>();
            ps?.Play();
            // 统一管理器内删除当前的Agent:
            AgentInsManager.instance.removeAgent(this);
            EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessAgentDead, this);
@@ -824,8 +830,6 @@
            return;
        }
        float atime = 0;
        /// <summary>
        /// 更新动作信息.
        /// </summary>
@@ -868,26 +872,6 @@
            ActionState = state;
            if (ActionAnimator != null)
                ActionAnimator.SetInteger(paramName, (int)state);
        }
        /// <summary>
        /// 检查自身血量
        /// </summary>
        private void CheckHealth()
        {
            if (this.healthVal <= 0.1)
            {
                Die();
                //Debug.Log("删除多余的攻击Agent.");
            }
        }
        private void Die()
        {
            // 统一管理器内删除当前的Agent:
            AgentInsManager.instance.removeAgent(this);
            this.Remove();
        }
        /// <summary>
@@ -1079,6 +1063,8 @@
        public override void PlayDeath()
        {
            if (bInDeathAct) return;
            if (isPoison)
            {
                isPoison = false;
@@ -1103,10 +1089,8 @@
                }
            }
            ChangeState(AgentActionState.Death);
            // 统一管理器内删除当前的Agent:
            AgentInsManager.instance.removeAgent(this);
            bInDeathAct = true;
            Remove();
        }
        /// <summary>