_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/GLScripts/Anilottery.cs

119 lines
2.8 KiB
C#
Raw Normal View History

2024-12-12 21:02:09 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2024-12-13 15:35:22 +08:00
using DG.Tweening;
2024-12-12 21:02:09 +08:00
public class Anilottery : MonoBehaviour
{
public GameObject YelloBox;
public Animator YelloAni;
public GameObject PurpleBox;
public Animator PurpleAni;
public GameObject RewardPanel;
2024-12-13 15:35:22 +08:00
public Transform JumpStartPos;
public List<rewardSolt> rewardSolts = new List<rewardSolt>();//<2F><><EFBFBD><EFBFBD>
public List<Sprite> sprites;//<2F><><EFBFBD><EFBFBD>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD>
public MotherFuck531 MotherFuck531;
public Lottery531 lottery531;
2024-12-12 21:02:09 +08:00
// Start is called before the first frame update
void Start()
{
2024-12-13 15:35:22 +08:00
RewardPanel.transform.DOScale(Vector3.zero, 0);
2024-12-12 21:02:09 +08:00
RewardPanel.SetActive(false);
}
2024-12-13 10:02:21 +08:00
public void ShowReward()
{
2024-12-13 15:35:22 +08:00
RewardPanel.transform.DOJump(JumpStartPos.position, 100 , 1,1.5f).SetEase(Ease.OutQuad) // <20><>Ծ
.OnStart(() => RewardPanel.transform.DOScale(Vector3.one,1.5f).SetEase(Ease.OutBack)); // <20>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>մ<EFBFBD>С
2024-12-13 10:02:21 +08:00
RewardPanel.SetActive(true);
}
2024-12-13 16:41:55 +08:00
public void OpenBox(int id )//1<>ǻƣ<C7BB>2<EFBFBD><32><EFBFBD><EFBFBD>
2024-12-12 21:02:09 +08:00
{
2024-12-13 16:41:55 +08:00
if (id == 1)
2024-12-12 21:02:09 +08:00
{
PurpleBox.SetActive(false);
YelloBox.SetActive(true);
2024-12-13 15:35:22 +08:00
GetRewardInfo531(1);
2024-12-12 21:02:09 +08:00
}
else
{
YelloBox.SetActive(false);
PurpleBox.SetActive(true);
2024-12-13 15:35:22 +08:00
GetRewardInfo531(2);
2024-12-13 10:02:21 +08:00
}
}
2024-12-13 15:35:22 +08:00
public async void GetRewardInfo531(int id)
{
lottery531 = await MotherFuck531.Result(id);
SetSoltInfo(lottery531.data);
}
2024-12-13 10:02:21 +08:00
public void OpenB(int id)//0<>ǻƣ<C7BB>1<EFBFBD><31><EFBFBD><EFBFBD>
{
if (id == 0)
{
YelloAni.SetBool("IsOpen", true);
}
else
{
2024-12-12 21:02:09 +08:00
PurpleAni.SetBool("IsOpen", true);
2024-12-13 10:02:21 +08:00
2024-12-12 21:02:09 +08:00
}
2024-12-13 10:02:21 +08:00
2024-12-12 21:02:09 +08:00
}
public void ReturnState()//<2F>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>״̬
{
YelloAni.SetBool("IsOpen", false);
PurpleAni.SetBool("IsOpen", false);
}
2024-12-13 15:35:22 +08:00
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()//<2F><>ƷͼƬ<CDBC><C6AC><EFBFBD><EFBFBD>
{
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];
}
}
}
2024-12-12 21:02:09 +08:00
}