using UnityEngine.UI;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using DG.Tweening;
|
using TowerDefense.Level;
|
using Core.Utilities;
|
using TowerDefense.Agents;
|
using Core.Health;
|
using TowerDefense.UI.HUD;
|
|
/**
|
* 水精灵技能-冷冻气息控制脚本
|
* @Author: chenxin
|
* @Date: 2020-11-12 14:41:23
|
*/
|
namespace KTGMGemClient
|
{
|
public class FreezeBreath : MonoBehaviour
|
{
|
public Image ProgressImg;
|
|
private int currentProgress;
|
|
/// <summary>
|
/// 充能时间(s)
|
/// </summary>
|
public static float ChargeTime { get; private set; } = 10f;
|
|
/// <summary>
|
/// 伤害时间
|
/// </summary>
|
public float EffectTime { get; private set; } = 2f;
|
|
/// <summary>
|
/// 伤害结算次数
|
/// </summary>
|
/// <value></value>
|
public int DamageCount { get; private set; } = 6;
|
|
/// <summary>
|
/// 整个技能时间
|
/// </summary>
|
public float SkillTime { get; private set; } = 2.5f;
|
|
/// <summary>
|
/// 当前的充能进度
|
/// </summary>
|
public int CurrentProgress { get; private set; }
|
|
/// <summary>
|
/// 喷冰特效
|
/// </summary>
|
public GameObject FreezeJet;
|
|
public int ReleaseCount { get; set; }
|
|
public void SetCtrlProgress(int progress)
|
{
|
if (progress == (int)Mathf.Floor(ChargeTime))
|
progress = 0;
|
|
ProgressImg.rectTransform.DOKill();
|
SetProgress(progress, false);
|
}
|
|
public void SetProgress(int progress, bool ani = true)
|
{
|
if (CurrentProgress == progress) return;
|
|
CurrentProgress = progress;
|
ProgressImg.rectTransform.DOScaleY(progress / ChargeTime, ani ? 0.3f : 0);
|
}
|
|
public void SetProgress(float progress)
|
{
|
ProgressImg.rectTransform.DOScaleY(progress / ChargeTime, 0);
|
CurrentProgress = (int)Mathf.Floor(progress);
|
}
|
|
/// <summary>
|
/// 释放冷冻气息
|
/// </summary>
|
/// <param name="waveLineId">哪条兵线</param>
|
/// <param name="damage">伤害值</param>
|
public void ReleaseFreeze(int waveLineId, float damage, IAlignmentProvider alignmentProvider)
|
{
|
WaveLineAgentInsMgr[] agentInsMgrs = AgentInsManager.instance.GetWaveLineList();
|
WaveLineAgentInsMgr waveLineAgentInsMgr = agentInsMgrs[waveLineId];
|
List<Agent> list = waveLineAgentInsMgr.listAgent;
|
|
if (list.Count == 0) return;
|
|
List<Agent> agentList = new List<Agent>();
|
|
for (int i = 0; i < list.Count; ++i)
|
{
|
agentList.Add(list[i]);
|
}
|
|
// 一次性死亡数量
|
int deathCount = 0;
|
|
while (agentList.Count > 0)
|
{
|
Agent agent = agentList[0];
|
agentList.Remove(agentList[0]);
|
|
if (agent.isDead) continue;
|
|
if (agent.AgentType == SpawnAgentType.Normal)
|
{
|
agent.addSpeedSlowRate(0.15f);
|
agent.PlayOnHitImmediately();
|
EndlessGameUI.instance.generateBloodText(agent.position, damage);
|
agent.TakeDamage(damage, agent.position, alignmentProvider);
|
|
if (agent.isDead)
|
++deathCount;
|
}
|
else if (agent.AgentType == SpawnAgentType.BubbleBomb)
|
EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessBossSkillBubbleBombGetHit, (agent as BubbleBombAgent).Id);
|
}
|
|
if (deathCount > 1)
|
EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.EndlessOneTimeKillCount, deathCount);
|
}
|
|
public void PlayFreezeEffect(int waveLineId)
|
{
|
WaveLineAgentInsMgr[] agentInsMgrs = AgentInsManager.instance.GetWaveLineList();
|
WaveLineAgentInsMgr waveLineAgentInsMgr = agentInsMgrs[waveLineId];
|
List<Agent> list = waveLineAgentInsMgr.listAgent;
|
|
if (list.Count == 0) return;
|
|
GameObject obj = Poolable.TryGetPoolable(FreezeJet);
|
ParticleSystem ps = obj.GetComponent<ParticleSystem>();
|
|
if (ps == null) ps = obj.transform.GetChild(0).GetComponent<ParticleSystem>();
|
|
ps.transform.position = EndlessLevelManager.instance.WaveManager.GetWaveEndPos(waveLineId);
|
ps.Play();
|
}
|
}
|
}
|