using UnityEngine;
|
using UnityEngine.UI;
|
using DG.Tweening;
|
using TowerDefense.UI.HUD;
|
|
/**
|
* 精灵升级面板
|
* @Author: chenxin
|
* @Date: 2020-12-11 10:59:15
|
*/
|
namespace KTGMGemClient
|
{
|
public class ElfUpgrade : MonoBehaviour
|
{
|
[SerializeField]
|
private Image lightImg;
|
|
[SerializeField]
|
private Text continueText;
|
|
[SerializeField]
|
private GameObject particlePrefab;
|
|
private GameObject particleObj;
|
|
private float startAlpha = 0.3f;
|
|
private Vector3 rotation = Vector3.forward;
|
|
/// <summary>
|
/// 升级最低等级
|
/// </summary>
|
private int upgradeLevel;
|
|
// Start is called before the first frame update
|
private void Start()
|
{
|
EndlessUIStart.instance.ShowUIMask();
|
particleObj = Instantiate(particlePrefab);
|
particleObj.transform.SetParent(GameObject.Find("ParticleSystemObject").transform, false);
|
particleObj.transform.localPosition = new Vector3(0f, 5.5f, 38.6f);
|
particleObj.transform.localScale = new Vector3(2f, 2f, 2f);
|
ParticleSystem ps = particleObj.transform.GetChild(0).GetComponent<ParticleSystem>();
|
ps?.Play();
|
Tween1();
|
}
|
|
private void Update()
|
{
|
lightImg.transform.Rotate(-rotation * 10 * Time.deltaTime);
|
}
|
|
private void Tween1()
|
{
|
continueText.color = new Color(1f, 1f, 1f, startAlpha);
|
DOTween.To(
|
() => continueText.color,
|
(Color v) => continueText.color = v,
|
new Color(1f, 1f, 1f, 1f), 0.3f)
|
.SetEase(Ease.OutCubic)
|
.OnComplete(Tween2);
|
}
|
|
private void Tween2()
|
{
|
DOTween.To(
|
() => continueText.color,
|
(Color v) => continueText.color = v,
|
new Color(1f, 1f, 1f, startAlpha), 0.6f)
|
.SetDelay(0.5f)
|
.OnComplete(Tween1);
|
}
|
|
public void OnClick()
|
{
|
EndlessUIStart.instance.HideUIMask();
|
Destroy(gameObject);
|
Destroy(particleObj);
|
particleObj = null;
|
EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.ElfUpgradePanelClosed);
|
}
|
|
public void SetUpgradeLevel(int level)
|
{
|
if (level < 1) level = 1;
|
else if (level >= ElfUpgradeData.MaxTowerLevel) level = ElfUpgradeData.MaxTowerLevel;
|
|
upgradeLevel = level;
|
}
|
|
public int GetUpgradeLevel()
|
{
|
return upgradeLevel == 0 ? 1 : upgradeLevel;
|
}
|
}
|
}
|