95 lines
2.5 KiB
C#
95 lines
2.5 KiB
C#
|
using System.Collections;
|
|||
|
using GCGame.Table;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
public class AdvanceWishValueFloatText : MonoBehaviour
|
|||
|
{
|
|||
|
public UIGradient graDient;
|
|||
|
|
|||
|
private bool _hasReCollect;
|
|||
|
|
|||
|
private Text valueText;
|
|||
|
|
|||
|
private void OnDisable()
|
|||
|
{
|
|||
|
iTween.Stop(gameObject);
|
|||
|
AnimationEnd();
|
|||
|
}
|
|||
|
|
|||
|
public void InitText(int value, bool isCrit)
|
|||
|
{
|
|||
|
if (!gameObject.activeInHierarchy)
|
|||
|
return;
|
|||
|
|
|||
|
StartCoroutine(ForceCollect()); //1S之后强制回收
|
|||
|
|
|||
|
graDient = gameObject.GetComponent<UIGradient>();
|
|||
|
if (graDient == null) return;
|
|||
|
|
|||
|
valueText = gameObject.GetComponent<Text>();
|
|||
|
if (valueText == null) return;
|
|||
|
|
|||
|
if (isCrit)
|
|||
|
{
|
|||
|
valueText.text = StrDictionary.GetClientDictionaryString("#{43044}", value);
|
|||
|
|
|||
|
graDient.maxColor = new Color32(254, 255, 251, 255);
|
|||
|
graDient.minColor = new Color32(242, 96, 96, 255);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
valueText.text = StrDictionary.GetClientDictionaryString("#{43043}", value);
|
|||
|
|
|||
|
graDient.maxColor = new Color32(255, 255, 255, 255);
|
|||
|
graDient.minColor = new Color32(255, 248, 102, 255);
|
|||
|
}
|
|||
|
|
|||
|
var args = new Hashtable();
|
|||
|
args.Add("easeType", iTween.EaseType.easeOutQuad);
|
|||
|
args.Add("time", 1.0f);
|
|||
|
|
|||
|
args.Add("looptype", "none");
|
|||
|
args.Add("islocal", true);
|
|||
|
//args.Add("position", new Vector3(pos.x, pos.y + 100, pos.z));
|
|||
|
args.Add("y", transform.localPosition.y + (isCrit ? 250 : 200));
|
|||
|
|
|||
|
|
|||
|
args.Add("oncomplete", "AnimationEnd");
|
|||
|
|
|||
|
iTween.MoveTo(gameObject, args);
|
|||
|
|
|||
|
var scaleHash = new Hashtable();
|
|||
|
scaleHash.Add("scale", 2.0f);
|
|||
|
iTween.ScaleTo(gameObject, scaleHash);
|
|||
|
}
|
|||
|
|
|||
|
//1S内强制关闭
|
|||
|
private IEnumerator ForceCollect()
|
|||
|
{
|
|||
|
yield return new WaitForSeconds(1.0f);
|
|||
|
|
|||
|
if (!gameObject.activeInHierarchy)
|
|||
|
yield break;
|
|||
|
|
|||
|
if (_hasReCollect && gameObject.activeInHierarchy)
|
|||
|
if (AdvancePanelCtr.Instance)
|
|||
|
{
|
|||
|
_hasReCollect = true;
|
|||
|
AdvancePanelCtr.Instance.AddWishFloatTextToPool(gameObject);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void AnimationEnd()
|
|||
|
{
|
|||
|
if (AdvancePanelCtr.Instance)
|
|||
|
{
|
|||
|
_hasReCollect = true;
|
|||
|
AdvancePanelCtr.Instance.AddWishFloatTextToPool(gameObject);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Destroy(gameObject);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|