128 lines
3.2 KiB
C#
128 lines
3.2 KiB
C#
using DG.Tweening;
|
|
using Spine.Unity;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using Random = UnityEngine.Random;
|
|
|
|
public class LeiLongEvent : MonoBehaviour
|
|
{
|
|
public TextMeshProUGUI tMP_Score;
|
|
public int currScore;
|
|
public int maxScore;
|
|
public LayeredPool layeredPool;
|
|
public int posID;
|
|
public int paoBei;
|
|
public Action JiaFen;
|
|
public SkeletonGraphic skeletonGraphic;
|
|
public TextMeshProUGUI tMP_longzhu1;
|
|
public TextMeshProUGUI tMP_longzhu2;
|
|
public TextMeshProUGUI tMP_longzhu3;
|
|
|
|
public int longzhu1;
|
|
public int longzhu2;
|
|
public void Awake()
|
|
{
|
|
//skeletonGraphic.AnimationState.Complete += (trackEntry) =>
|
|
//{
|
|
// if (trackEntry.Animation.Name != "stand")
|
|
// {
|
|
// skeletonGraphic.AnimationState.SetAnimation(0, "stand1", false);
|
|
// }
|
|
//};
|
|
}
|
|
private void Start()
|
|
{
|
|
PlayThen("stand", "stand1");
|
|
transform.SetParent(null);
|
|
transform.position = Vector3.zero;
|
|
transform.position = Vector3.forward*-100;
|
|
}
|
|
/// <summary>
|
|
/// 播放完一个再接另一个(UI Spine)
|
|
/// </summary>
|
|
public void PlayThen(string first, string next)
|
|
{
|
|
var state = skeletonGraphic.AnimationState;
|
|
state.SetAnimation(0, first, false);
|
|
state.AddAnimation(0, next, true, 0f);
|
|
}
|
|
|
|
public void Init(int goldCount,int posID,int paobei,Action<int> action,int lz1,int lz2)
|
|
{
|
|
JiaFen =()=>{
|
|
action?.Invoke(0);
|
|
} ;
|
|
maxScore = goldCount;
|
|
this.posID = posID;
|
|
paoBei = paobei;
|
|
longzhu1 = lz1;
|
|
longzhu2 = lz2;
|
|
}
|
|
public void GoldEffect()
|
|
{
|
|
//开始加分
|
|
isAddScore = true;
|
|
BigPrize();
|
|
}
|
|
|
|
public void EffEnd()
|
|
{
|
|
|
|
}
|
|
public void LongZhuMerge()
|
|
{
|
|
tMP_longzhu3.text = (longzhu1*longzhu2).ToString();
|
|
|
|
}
|
|
public void LongZhu2()
|
|
{
|
|
tMP_longzhu2.text = longzhu2.ToString();
|
|
|
|
}
|
|
public void LongZhu1()
|
|
{
|
|
tMP_longzhu1.text = longzhu1.ToString();
|
|
}
|
|
bool isAddScore=false;
|
|
float a = 1f;
|
|
private void Update()
|
|
{
|
|
if (isAddScore) {
|
|
if (currScore < maxScore - paoBei)
|
|
{
|
|
currScore += Random.Range(paoBei*2, paoBei*5);
|
|
tMP_Score.text = currScore.ToString();
|
|
}
|
|
else
|
|
{
|
|
tMP_Score.text = maxScore.ToString();
|
|
a += Time.deltaTime;
|
|
Invoke("die", 1f);
|
|
|
|
isAddScore = false;
|
|
}
|
|
|
|
}
|
|
}
|
|
public void die()
|
|
{
|
|
transform.DOScale(Vector3.zero, 0.5f).OnComplete(() =>
|
|
{
|
|
Destroy(gameObject);
|
|
});
|
|
}
|
|
public List<RedPacketRecord> BigPrize(int min = 10, int max = 15)
|
|
{
|
|
if (layeredPool == null)
|
|
{
|
|
layeredPool = new LayeredPool(maxScore, 1); // 初始化LayeredPool,假设5个人,10000分
|
|
}
|
|
|
|
var v = layeredPool.BossGlodCoinRandrom(tMP_Score.transform.position, min, max);
|
|
return v;
|
|
}
|
|
}
|