wangguan
2020-12-28 e439d913a7094082f9618731bed68fe6634dfed0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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
    {
        /// <summary>
        ///  木桩墙壁收到货塔攻击的额外伤害倍率
        /// </summary>
        public float FireHurtRate { get; set; }
 
        public GameObject appearPS;
        public GameObject diePS;
 
 
        /// <summary>
        /// Peforms the relevant path update
        /// 执行相关路径更新
        /// </summary>
        protected override void PathUpdate()
        {
 
        }
 
        /// <summary>
        /// The behaviour for when the agent has been blocked
        /// 代理被阻止时的行为
        /// </summary>
        protected override void OnPartialPathUpdate()
        {
 
        }
 
        protected override void Update()
        {
 
        }
 
        protected override void LateUpdate()
        {
 
        }
 
        /// <summary>
        /// Stops the navMeshAgent and attempts to return to pool
        /// </summary>
        public override void Remove()
        {
            // 统一管理器内删除当前的Agent:
            AgentInsManager.instance.removeAgent(this);
 
            if (BloodBar != null)
            {
                BloodBar.Target = null;
                Destroy(BloodBar.gameObject);
            }
 
            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;
 
            appearPS.SetActive(false);
            diePS.SetActive(true);
 
            Invoke("DestroySelf", 1.0f);
        }
 
        private void DestroySelf()
        {
            Destroy(gameObject);
        }
 
        protected override void SetAgentStopBuff(buffinfo binfo)
        {
            // 本来木桩也不会动
        }
 
        /// <summary>    
        /// Setup all the necessary parameters for this agent from configuration data
        /// </summary>
        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();
        }
    }
}