| | |
| | | using TowerDefense.Economy; |
| | | using TowerDefense.Level; |
| | | using TowerDefense.Nodes; |
| | | using TowerDefense.UI.HUD; |
| | | using UnityEngine; |
| | | using UnityEngine.AI; |
| | | |
| | |
| | | private string paramName = "AgentActionState"; |
| | | |
| | | /// <summary> |
| | | /// 外部赋值,唯一标识一个代理 |
| | | /// </summary> |
| | | public int Id { get; set; } |
| | | |
| | | private Tween repelTween; |
| | | |
| | | /// <summary> |
| | | /// 击退距离 |
| | | /// </summary> |
| | | protected float repelDistance { get; set; } = 7f; |
| | | |
| | | /// <summary> |
| | | /// 击退时间间隔 |
| | | /// </summary> |
| | | protected float repelTime { get; set; } = 0.5f; |
| | | |
| | | /// <summary> |
| | | /// 是否受到木属性强化子弹攻击 |
| | | /// </summary> |
| | | public bool IsEnhancedBulletAttack { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 木属性精灵瞄准小怪特效 |
| | | /// </summary> |
| | | public ParticleSystem WoodAimEffect; |
| | | |
| | | /// <summary> |
| | | /// 有几个木属性精灵瞄准了Agent |
| | | /// </summary> |
| | | public int WoodAimCount { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 更新怪物的移动速度。 |
| | | /// </summary> |
| | | /// <param name="fscale"></param> |
| | |
| | | return true; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Agent被击退 |
| | | /// </summary> |
| | | public void AgentBeRepelled() |
| | | { |
| | | CanMove = false; |
| | | |
| | | if (repelTween != null) |
| | | repelTween.Kill(); |
| | | |
| | | Node StartingNodeList = EndlessLevelManager.instance.StartingNodeList[waveLineID]; |
| | | repelTween = transform.DOMoveZ(Mathf.Min(StartingNodeList.transform.position.z, transform.position.z + repelDistance), repelTime); |
| | | repelTween.onComplete = RepelCompleted; |
| | | } |
| | | |
| | | private void RepelCompleted() |
| | | { |
| | | CanMove = true; |
| | | repelTween = null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Stops the navMeshAgent and attempts to return to pool |
| | |
| | | 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(); |
| | | if (prefab != null) |
| | | { |
| | | 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); |
| | | if (EnemyData != null) |
| | | EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessAgentDead, EnemyData.point); |
| | | base.Remove(); |
| | | |
| | | if (m_LevelManager) m_LevelManager.DecrementNumberOfEnemies(); |
| | |
| | | configuration.ClearShieldWall(); |
| | | |
| | | StopFrostParticle(); |
| | | |
| | | if (WoodAimCount > 0) |
| | | WoodAimCount = 0; |
| | | WoodAimEffect.Stop(); |
| | | WoodAimEffect.Clear(); |
| | | //this.SetTargetableMatColor(Color.white); |
| | | |
| | | // 删除当前停止特效和状态. |
| | | if (MoveStopTime > 0) |
| | | MoveStopTime = 0.0f; |
| | | |
| | | if (repelTween != null) |
| | | { |
| | | repelTween.Kill(); |
| | | repelTween = null; |
| | | } |
| | | |
| | | // 停止DoTween动画. |
| | | this.transform.DOKill(); |
| | |
| | | /// </summary> |
| | | public virtual void Initialize() |
| | | { |
| | | Id = GameUtils.GetId(); |
| | | ResetPositionData(); |
| | | LazyLoad(); |
| | | configuration.SetHealth(configuration.maxHealth); |
| | |
| | | } |
| | | |
| | | bInDeathAct = true; |
| | | |
| | | if (EnemyData != null && EndlessGameUI.instance.state != EndlessGameUI.State.GameOver) |
| | | { |
| | | // Debug.Log("小怪被杀死了,增加能量" + EnemyData.energy); |
| | | EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EnergyUp, EnemyData.energy); |
| | | } |
| | | |
| | | Remove(); |
| | | } |
| | | |