132 lines
3.5 KiB
C#
132 lines
3.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
|
|
[Serializable]
|
|
public class RootObject
|
|
{
|
|
public List<Item> List;
|
|
public int ErrorCode;
|
|
public string ErrorMessage;
|
|
}
|
|
|
|
[Serializable]
|
|
public class Item
|
|
{
|
|
public int Id;
|
|
public int Num;
|
|
public string Name;
|
|
public int ActivateValue;
|
|
public int StoreValue;
|
|
public float Yield;
|
|
public int Limit;
|
|
public int EndureTime;
|
|
public List<float> ReferrerBouns;
|
|
public string CreateDateTime;
|
|
}
|
|
|
|
|
|
public class JinShaBuy : mount
|
|
{
|
|
|
|
public int number=1;
|
|
public int max = 10;
|
|
public override void Awake()
|
|
{
|
|
|
|
}
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public void Show_buy()//购买弹窗
|
|
{
|
|
|
|
List<BoxType> boxTypes = new List<BoxType>();
|
|
boxTypes.Add(new BoxType { Name = "account_number", textName = " 数量:", prompt = "请输入购买数量", Type = 6, is_required = false});
|
|
boxTypes.Add(new BoxType { Name = "submit", textName = " 取消购买 ", Type = 2 });
|
|
GameObject gameObject = add_pop_up(true);//生成弹窗母体
|
|
gameObject.GetComponent<input_box_pop_up_window>().minHeight = 800;//设置最低高度
|
|
List<GameObject> gameObjects = gameObject.GetComponent<input_box_pop_up_window>().updateUI(boxTypes, "购买");//测试输入框回调处理
|
|
|
|
UpdateText(gameObjects[0].GetComponent<input_box_pop_up_window_item>().contentobj.GetComponent<Text>());
|
|
|
|
gameObjects[0].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>//登录确定或取消
|
|
{
|
|
if (type == 0)
|
|
{
|
|
if (number>1)
|
|
{
|
|
number--;
|
|
UpdateText(gameObjects[0].GetComponent<input_box_pop_up_window_item>().contentobj.GetComponent<Text>());
|
|
Debug.Log("减少");
|
|
Debug.Log(number);
|
|
|
|
}
|
|
}
|
|
else if (type == 1)
|
|
{
|
|
if (number < max)
|
|
{
|
|
number++;
|
|
UpdateText(gameObjects[0].GetComponent<input_box_pop_up_window_item>().contentobj.GetComponent<Text>());
|
|
Debug.Log("增加");
|
|
Debug.Log(number);
|
|
}
|
|
}
|
|
else if (type == 2)
|
|
{
|
|
if (number!= max)
|
|
{
|
|
number=max;
|
|
UpdateText(gameObjects[0].GetComponent<input_box_pop_up_window_item>().contentobj.GetComponent<Text>());
|
|
Debug.Log("Max");
|
|
Debug.Log(number);
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
gameObjects[1].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>//登录确定或取消
|
|
{
|
|
if (type == 0)
|
|
{
|
|
gameObject.GetComponent<input_box_pop_up_window>().destroy();
|
|
|
|
|
|
}
|
|
else if (type == 1)
|
|
{
|
|
string response = await web.SendRequest("http://47.109.133.52/MinerElf/GetList", "POST");
|
|
Debug.Log(response);
|
|
|
|
|
|
|
|
Debug.Log(boxTypes[1].content);
|
|
//number = int.Parse(boxTypes[0].content);
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
void UpdateText(Text text)
|
|
{
|
|
Debug.Log(text.text);
|
|
text.text = number.ToString();
|
|
}
|
|
|
|
|
|
}
|