using Core.Utilities; using KTGMGemClient; using DG.Tweening; using UnityEngine; /** * 木桩墙壁 * @Author: chenxin * @Date: 2020-11-07 11:13:25 */ namespace TowerDefense.Agents { public class WoodPileAgent : Agent { /// /// 木桩墙壁收到货塔攻击的额外伤害倍率 /// public float FireHurtRate { get; set; } /// /// Peforms the relevant path update /// 执行相关路径更新 /// protected override void PathUpdate() { } /// /// The behaviour for when the agent has been blocked /// 代理被阻止时的行为 /// protected override void OnPartialPathUpdate() { } protected override void Update() { } protected override void LateUpdate() { } /// /// Stops the navMeshAgent and attempts to return to pool /// public override void Remove() { // 统一管理器内删除当前的Agent: AgentInsManager.instance.removeAgent(this); configuration.SetHealth(0); OnRemoved(); if (m_NavMeshAgent.enabled) { m_NavMeshAgent.isStopped = true; } m_NavMeshAgent.enabled = false; // 必须要重置数据,不然会有一系列的小Bug. this.m_CurrentNode = null; m_NextNode = null; this.liveID = this.liveID + 1; bInDeathAct = false; // 删除当前停止特效和状态. if (MoveStopTime > 0) MoveStopTime = 0.0f; Poolable.TryPool(gameObject); } protected override void SetAgentStopBuff(buffinfo binfo) { // 本来木桩也不会动 } /// /// Setup all the necessary parameters for this agent from configuration data /// public override void Initialize() { configuration.SetHealth(configuration.maxHealth); state = isPathBlocked ? State.OnPartialPath : State.OnCompletePath; // 设置一个DOTween队列,让场景内刷出来的Agent有一个变大淡出的效果,此时是无敌效果加持. this.configuration.bInvincible = true; mDefaultScale = this.transform.localScale; Sequence agentTweenSeq = DOTween.Sequence(); var ss = mDefaultScale * 0.3f; this.transform.localScale = this.transform.localScale * 0.3f; Tweener agScale = this.transform.DOScale(mDefaultScale, 0.3f); agentTweenSeq.Append(agScale); agentTweenSeq.AppendCallback(beDamageStart); this.nodeMoveUpdate = false; // 获取移动速度 fMoveSpeed = this.m_NavMeshAgent.speed / 2.0f; } public override void PlayDeath() { EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessWoodPileBeKilled, Id); Remove(); } } }