135 lines
4.7 KiB
C#
135 lines
4.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
using DG.Tweening;
|
|
public delegate void SetActiveDelegate(bool isActive);
|
|
|
|
public class KuangChang : MonoBehaviour
|
|
{
|
|
// 静态实例
|
|
public static KuangChang Instance { get; private set; }
|
|
|
|
queryMiningContractList101 queryMiningContractList = new queryMiningContractList101(); // 10.110.1 查询可购买的挖矿合约
|
|
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("返回主页按钮")]
|
|
public Button ReturnButton;
|
|
[Header("用户收益")]
|
|
public TextMeshProUGUI Userdata;
|
|
[Header("矿场弹窗")]
|
|
public GameObject kuanghcangPop;
|
|
[Header("有卡槽有合约")]
|
|
public GameObject successItem;
|
|
[Header("有卡槽无合约")]
|
|
public GameObject NoContractItem;
|
|
[Header("无卡槽无合约")]
|
|
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;
|
|
// 矿厂主页刷新蜗壳值
|
|
QueryUserVoluteCoinResponse queryUserVoluteCoinResponse = await queryUserVoluteCoin.QueryUserVoluteCoin();
|
|
Userdata.text = queryUserVoluteCoinResponse.data.ToString();
|
|
|
|
// 返回主页按钮的点击事件
|
|
ReturnButton.onClick.AddListener(() =>
|
|
{
|
|
|
|
ReturnButton.transform.DOScale(1.5f, 0.25f);
|
|
ReturnButton.transform.DOScale(1f, 0.25f);
|
|
Invoke("ToMain", 0.5f);
|
|
});
|
|
}
|
|
|
|
void ToMain()
|
|
{
|
|
SceneManager.LoadScene(1);
|
|
}
|
|
public async void UpdateUserdata()
|
|
{
|
|
QueryUserVoluteCoinResponse queryUserVoluteCoinResponse = await queryUserVoluteCoin.QueryUserVoluteCoin();
|
|
Userdata.text = queryUserVoluteCoinResponse.data.ToString();
|
|
}
|
|
// 设置矿场弹窗的显示与隐藏
|
|
private async void SetKuanghcangPopActive(bool isActive)
|
|
{
|
|
if (kuanghcangPop != null)
|
|
{
|
|
kuanghcangPop.SetActive(isActive);
|
|
kuanghcangPop.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
|
|
kuanghcangPop.transform.DOScale(1f, 0.5f);
|
|
}
|
|
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);
|
|
ob.transform.localScale = new Vector3(1, 1, 1);
|
|
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);
|
|
ob.transform.localScale = new Vector3(1, 1, 1);
|
|
}
|
|
}
|
|
GameObject obj = Instantiate(NoItem);
|
|
obj.transform.SetParent(content.transform);
|
|
obj.transform.localScale = new Vector3(1, 1, 1);
|
|
|
|
}
|
|
}
|