_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/GLScripts/Anilottery.cs
2024-12-13 16:41:55 +08:00

119 lines
2.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class Anilottery : MonoBehaviour
{
public GameObject YelloBox;
public Animator YelloAni;
public GameObject PurpleBox;
public Animator PurpleAni;
public GameObject RewardPanel;
public Transform JumpStartPos;
public List<rewardSolt> rewardSolts = new List<rewardSolt>();//格子
public List<Sprite> sprites;//奖励图片精灵
public MotherFuck531 MotherFuck531;
public Lottery531 lottery531;
// Start is called before the first frame update
void Start()
{
RewardPanel.transform.DOScale(Vector3.zero, 0);
RewardPanel.SetActive(false);
}
public void ShowReward()
{
RewardPanel.transform.DOJump(JumpStartPos.position, 100 , 1,1.5f).SetEase(Ease.OutQuad) // 跳跃
.OnStart(() => RewardPanel.transform.DOScale(Vector3.one,1.5f).SetEase(Ease.OutBack)); // 放大到最终大小
RewardPanel.SetActive(true);
}
public void OpenBox(int id )//1是黄2是紫
{
if (id == 1)
{
PurpleBox.SetActive(false);
YelloBox.SetActive(true);
GetRewardInfo531(1);
}
else
{
YelloBox.SetActive(false);
PurpleBox.SetActive(true);
GetRewardInfo531(2);
}
}
public async void GetRewardInfo531(int id)
{
lottery531 = await MotherFuck531.Result(id);
SetSoltInfo(lottery531.data);
}
public void OpenB(int id)//0是黄1是紫
{
if (id == 0)
{
YelloAni.SetBool("IsOpen", true);
}
else
{
PurpleAni.SetBool("IsOpen", true);
}
}
public void ReturnState()//恢复动画状态
{
YelloAni.SetBool("IsOpen", false);
PurpleAni.SetBool("IsOpen", false);
}
public void SetSoltInfo(List<Lottery531Data> data)
{
int index = 0;
foreach (Lottery531Data item in data)
{
rewardSolts[index].Type = item.Type;
if (item.BeansCoin!=0)
{
rewardSolts[index].NumText.text = item.BeansCoin.ToString("F1");
}
index++;
}
SetImage();
}
public void SetImage()//奖品图片设置
{
foreach (rewardSolt item in rewardSolts)
{
if (item.Type==0)
{
item.RewardImage.sprite = sprites[0];
}
else if (item.Type == 1)
{
item.RewardImage.sprite = sprites[1];
}
else if (item.Type == 2)
{
item.RewardImage.sprite = sprites[2];
}
}
}
}