_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/kuangChang10/KuangChang.cs

135 lines
4.7 KiB
C#
Raw Normal View History

2024-12-06 16:14:45 +08:00
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
2024-12-09 14:33:01 +08:00
using DG.Tweening;
2024-12-06 16:14:45 +08:00
public delegate void SetActiveDelegate(bool isActive);
public class KuangChang : MonoBehaviour
{
// <20><>̬ʵ<CCAC><CAB5>
public static KuangChang Instance { get; private set; }
queryMiningContractList101 queryMiningContractList = new queryMiningContractList101(); // 10.110.1 <20><>ѯ<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD>Լ
MiningContractList miningContractList = new MiningContractList();
queryMiningContracDetail102 queryMiningContracDetail = new queryMiningContracDetail102(); // 10.2
MiningContracDetail miningContracDetail = new MiningContracDetail();
buyMiningContract103 buyMiningContract = new buyMiningContract103(); // 10.3
queryUserMiningSlot104 queryUserMiningSlot = new queryUserMiningSlot104(); // 10.4
openSlot105 openSlot5 = new openSlot105(); // 10.5
queryMyPureContract106 queryMyPureContract = new queryMyPureContract106(); // 10.6
bindSlot107 bindSlot = new bindSlot107();
queryUserVoluteCoin108 queryUserVoluteCoin = new queryUserVoluteCoin108();
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>ť")]
public Button ReturnButton;
[Header("<22>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>")]
public TextMeshProUGUI Userdata;
[Header("<22>󳡵<EFBFBD><F3B3A1B5><EFBFBD>")]
public GameObject kuanghcangPop;
[Header("<22>п<EFBFBD><D0BF><EFBFBD><EFBFBD>к<EFBFBD>Լ")]
public GameObject successItem;
[Header("<22>п<EFBFBD><D0BF><EFBFBD><EFBFBD>޺<EFBFBD>Լ")]
public GameObject NoContractItem;
[Header("<22>޿<EFBFBD><DEBF><EFBFBD><EFBFBD>޺<EFBFBD>Լ")]
public GameObject NoItem;
public SetActiveDelegate onSetActive;
[Header("Itemcontent")]
public GameObject content;
private void Awake()
{
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
}
}
async void Start()
{
IninItem();
onSetActive = SetKuanghcangPopActive;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳˢ<D2B3><CBA2><EFBFBD>Ͽ<EFBFBD>ֵ
QueryUserVoluteCoinResponse queryUserVoluteCoinResponse = await queryUserVoluteCoin.QueryUserVoluteCoin();
Userdata.text = queryUserVoluteCoinResponse.data.ToString();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>ť<EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD>¼<EFBFBD>
2024-12-09 14:33:01 +08:00
ReturnButton.onClick.AddListener(() =>
{
ReturnButton.transform.DOScale(1.5f, 0.25f);
ReturnButton.transform.DOScale(1f, 0.25f);
Invoke("ToMain", 0.5f);
});
2024-12-06 16:14:45 +08:00
}
2024-12-09 14:33:01 +08:00
void ToMain()
{
SceneManager.LoadScene(1);
}
2024-12-06 16:14:45 +08:00
public async void UpdateUserdata()
{
QueryUserVoluteCoinResponse queryUserVoluteCoinResponse = await queryUserVoluteCoin.QueryUserVoluteCoin();
Userdata.text = queryUserVoluteCoinResponse.data.ToString();
}
// <20><><EFBFBD>ÿ󳡵<C3BF><F3B3A1B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
private async void SetKuanghcangPopActive(bool isActive)
{
if (kuanghcangPop != null)
{
kuanghcangPop.SetActive(isActive);
2024-12-09 14:33:01 +08:00
kuanghcangPop.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
kuanghcangPop.transform.DOScale(1f, 0.5f);
2024-12-06 16:14:45 +08:00
}
QueryUserVoluteCoinResponse queryUserVoluteCoinResponse = await queryUserVoluteCoin.QueryUserVoluteCoin();
Userdata.text = queryUserVoluteCoinResponse.data.ToString();
}
public async void IninItem()
{
for (int i = 0; i < content.transform.childCount; i++)
{
Destroy(content.transform.GetChild(i).gameObject);
}
queryUserMiningSlot104 queryUserMiningSlot = new queryUserMiningSlot104();
UserMiningSlotResponse userMiningSlotResponse = await queryUserMiningSlot.QueryUserMiningSlot();
userMiningSlotResponse = await queryUserMiningSlot.QueryUserMiningSlot();
foreach (var userMiningSlot in userMiningSlotResponse.data.dataList)
{
if (userMiningSlot.contractId<=6&& userMiningSlot.contractId>=3)
{
GameObject ob = Instantiate(successItem);
ob.transform.SetParent(content.transform);
2024-12-09 16:39:36 +08:00
ob.transform.localScale = new Vector3(1, 1, 1);
2024-12-06 16:14:45 +08:00
SuccessItem scItem= ob.GetComponent<SuccessItem>();
scItem.UserMiningSlot = userMiningSlot;
}
}
foreach (var userMiningSlot in userMiningSlotResponse.data.dataList)
{
if (userMiningSlot.contractId > 6 ||userMiningSlot.contractId < 3)
{
GameObject ob = Instantiate(NoContractItem);
ob.transform.SetParent(content.transform);
2024-12-09 16:39:36 +08:00
ob.transform.localScale = new Vector3(1, 1, 1);
2024-12-06 16:14:45 +08:00
}
}
GameObject obj = Instantiate(NoItem);
obj.transform.SetParent(content.transform);
2024-12-09 16:39:36 +08:00
obj.transform.localScale = new Vector3(1, 1, 1);
2024-12-06 16:14:45 +08:00
}
}