_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/RacingPanel/RacingSuccessPanel.cs

125 lines
4.0 KiB
C#
Raw Normal View History

2024-12-02 16:30:36 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class RacingSuccessPanel : BasePanel
{
public Button ReturnBtn;
public static RacingSuccessPanel instance;
public TextMeshProUGUI textSnailEggs;//<2F><>ţ<EFBFBD><C5A3><EFBFBD>ı<EFBFBD>
public List<Image> images=new List<Image>();//<2F><>ʾ<EFBFBD><CABE>ţͼƬ
2024-12-04 17:12:02 +08:00
public List<Sprite> sprites = new List<Sprite>();//ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD>
public List<RuntimeAnimatorController> animators = new List<RuntimeAnimatorController>();//ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD>
2024-12-02 16:30:36 +08:00
public override void Start()
{
instance = this;
base.Start();
ReturnBtn.onClick.AddListener(OnClickReBtn);
}
public void OnClickReBtn()
{
HidePanel();
}
public void ShowImage()//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>չʾͼƬ
{
if (AllManeger.instance.WinNos.Count==4)
{
2024-12-04 17:12:02 +08:00
int index = 0;
for (int i = 1; i < images.Count; i++)
2024-12-02 16:30:36 +08:00
{
2024-12-04 17:12:02 +08:00
SetImage(AllManeger.instance.WinNos[index], images[i]);
if (index < AllManeger.instance.WinNos.Count - 1)
{
index++;
}
2024-12-02 16:30:36 +08:00
}
2024-12-04 17:12:02 +08:00
images[0].gameObject.SetActive(false);
images[1].gameObject.SetActive(true);
images[2].gameObject.SetActive(true);
images[3].gameObject.SetActive(true);
images[4].gameObject.SetActive(true);
}
else if (AllManeger.instance.WinNos.Count == 2)
{
int index = 0;
for (int i=1;i<images.Count;i++)
{
SetImage(AllManeger.instance.WinNos[index], images[i]);
if (index < AllManeger.instance.WinNos.Count - 1)
{
index++;
}
}
images[0].gameObject.SetActive(false);
images[1].gameObject.SetActive(true);
images[2].gameObject.SetActive(true);
images[3].gameObject.SetActive(false);
images[4].gameObject.SetActive(false);
}
else if (AllManeger.instance.WinNos.Count == 1)
{
SetImage(AllManeger.instance.WinNos[0], images[0]);
images[0].gameObject.SetActive(true);
images[1].gameObject.SetActive(false);
images[2].gameObject.SetActive(false);
images[3].gameObject.SetActive(false);
images[4].gameObject.SetActive(false);
2024-12-02 16:30:36 +08:00
}
}
public void SetImage(int horseId,Image image)
{
switch (horseId)
{
case 1:
2024-12-04 17:12:02 +08:00
image.sprite = sprites[0];
image.gameObject.GetComponent<Animator>().runtimeAnimatorController = animators[0];
2024-12-02 16:30:36 +08:00
break;
case 2:
2024-12-04 17:12:02 +08:00
image.sprite = sprites[1];
image.gameObject.GetComponent<Animator>().runtimeAnimatorController = animators[1];
break;
case 3:
image.sprite = sprites[2];
image.gameObject.GetComponent<Animator>().runtimeAnimatorController = animators[2];
break;
case 4:
image.sprite = sprites[3];
image.gameObject.GetComponent<Animator>().runtimeAnimatorController = animators[3];
break;
case 5:
image.sprite = sprites[4];
image.gameObject.GetComponent<Animator>().runtimeAnimatorController = animators[4];
break;
case 6:
image.sprite = sprites[5];
image.gameObject.GetComponent<Animator>().runtimeAnimatorController = animators[5];
break;
case 7:
image.sprite = sprites[6];
image.gameObject.GetComponent<Animator>().runtimeAnimatorController = animators[6];
break;
case 8:
image.sprite = sprites[7];
image.gameObject.GetComponent<Animator>().runtimeAnimatorController = animators[7];
2024-12-02 16:30:36 +08:00
break;
}
}
}