_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/Scene_main/main_game.cs

106 lines
2.3 KiB
C#
Raw Normal View History

2024-11-26 15:33:45 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2024-11-26 17:41:48 +08:00
using UnityEngine.UI;
2024-11-26 15:33:45 +08:00
2024-11-26 17:41:48 +08:00
public class main_game :Base
2024-11-26 15:33:45 +08:00
{
2024-11-26 17:41:48 +08:00
[Header("canvas<61><73><EFBFBD><EFBFBD>̬<EFBFBD><CCAC><EFBFBD>ɵĸ<C9B5><C4B8>ڵ<EFBFBD>")]
public Canvas canvas;
[Header("<22><>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>һһ<D2BB><D2BB>Ӧ")]
public Button BTN1;
public Button BTN2;
public Button BTN3;
public Button BTN4;
[Header("<22><>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>һһ<D2BB><D2BB>Ӧ")]
public GameObject panel1;
public GameObject panel2;
public GameObject panel3;
public GameObject panel4;
2024-11-28 02:00:05 +08:00
[Header("<22><>ť<EFBFBD>Ͷ<EFBFBD>Ӧ<EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")]
public Button Game_BTN1;
public int Game_BTN1_index;
public Button Game_BTN2;
public int Game_BTN2_index;
2024-11-26 23:30:03 +08:00
public virtual void Start()
2024-11-26 15:33:45 +08:00
{
2024-11-28 02:00:05 +08:00
if (BTN1!=null)
{
BTN1.onClick.AddListener(() => {
asyncOnShopBTN(BTN1, panel1);
});
}
if (BTN2 != null)
{
BTN2.onClick.AddListener(() => {
asyncOnShopBTN(BTN2, panel2);
});
}
if (BTN3 != null)
{
BTN3.onClick.AddListener(() => {
asyncOnShopBTN(BTN3, panel3);
});
}
if (BTN4 != null)
{
BTN4.onClick.AddListener(() => {
asyncOnShopBTN(BTN4, panel4);
});
}
if (Game_BTN1 != null)
{
Game_BTN1.onClick.AddListener(() => {
asyncOnShopBTN(Game_BTN1, 0);
});
}
if (Game_BTN2 != null)
{
Game_BTN2.onClick.AddListener(() => {
asyncOnShopBTN(Game_BTN2, 0);
});
}
2024-11-26 23:30:03 +08:00
2024-11-26 15:33:45 +08:00
}
2024-11-26 17:41:48 +08:00
public async void asyncOnShopBTN(Button BTN,GameObject _panel)
{
await ButtonClickAnimationAsync(BTN.gameObject);
2024-11-28 02:00:05 +08:00
if (BTN.transform.GetComponent<main_RedDot>()!=null)
{
BTN.transform.GetComponent<main_RedDot>().HideRedDot();
}
2024-11-27 14:26:45 +08:00
2024-11-26 17:41:48 +08:00
if (_panel == null)
{
2024-11-26 23:30:03 +08:00
addEventPopUp(<><CEB4><EFBFBD><EFBFBD>", 3f);
2024-11-26 17:41:48 +08:00
return;
2024-11-27 14:26:45 +08:00
}
2024-11-28 02:00:05 +08:00
GameObject.Instantiate(_panel, canvas.transform);
2024-11-26 23:30:03 +08:00
2024-11-28 02:00:05 +08:00
}
public async void asyncOnShopBTN(Button BTN,int index)
{
await ButtonClickAnimationAsync(BTN.gameObject);
BTN.transform.GetComponent<main_RedDot>().HideRedDot();
}
2024-11-26 15:33:45 +08:00
}