Cute_demon_attacks/meng_yao/Assets/communal/mount.cs
舒荣森 fe109c7b14 add
2024-11-01 02:27:50 +08:00

143 lines
5.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using Unity.VisualScripting;
using UnityEngine;
using static UnityEditor.PlayerSettings;
[System.Serializable]
public struct Register
{
public string Phone;
}
public struct AddGold
{
public int Gold;
}
public struct Login
{
public string Phone;
}
public struct GetListByPhone
{
public string Phone;
}
public class mount : MonoBehaviour
{
public static Dictionary<string, Texture> SpriteDic = new Dictionary<string, Texture>();
public static mount mountitem;
// Start is called before the first frame update
public virtual void Awake()
{
mountitem = this;
DontDestroyOnLoad(this);
//mountitem.login_screen();
}
private void Start()
{
//give_firend();
}
public GameObject add_pop_up(bool is_force = false)//添加弹窗
{
GameObject prefab = Resources.Load<GameObject>("preform/gui/pop_up_ui");
GameObject ranking_list_item = Instantiate(prefab, this.transform);
ranking_list_item.GetComponent<input_box_pop_up_window>().is_force = is_force;
return ranking_list_item;
}
//0 输入框
//1 输入框带按钮
//2 取消按钮 确定按钮
//3 购买人才item
//4 购买人才文字消息
public void login_screen()//注册界面
{
List<BoxType> boxTypes = new List<BoxType>();
boxTypes.Add(new BoxType { Name = "account_number", textName = " 手机号", prompt= "请输入手机号", Type = 1, is_required = true });
boxTypes.Add(new BoxType { Name = "verification_code", textName = " 验证码 ", prompt = "请输入验证码", Type = 0, is_required = true });
boxTypes.Add(new BoxType { Name = "submit", textName = " 取消确定 ",Type = 2});
GameObject gameObject = add_pop_up(true);//生成弹窗母体
List<GameObject> gameObjects = gameObject.GetComponent<input_box_pop_up_window>().updateUI(boxTypes, "注册");//测试输入框回调处理
gameObjects[0].GetComponent<input_box_pop_up_window_item>().register_click((BoxType boxType,int type) =>//手机号获取验证码点击
{
if (boxType.is_required && string.IsNullOrWhiteSpace(boxType.content)) {
Promptmgr.Instance.PromptBubble("请不要" + boxType.textName + "为空");
return; }
Debug.Log("获取验证码");
});
gameObjects[2].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){
Register register = new Register();
register.Phone = boxTypes[0].content;
//register.Code = boxTypes[0].content;
string jsonString = JsonUtility.ToJson(register);
string response = await web.SendRequest("http://47.109.133.52/Player/Register", "POST", jsonString);
Debug.Log(response);
}
});
}
public void give_firend()
{
List<BoxType> boxTypes = new List<BoxType>();
boxTypes.Add(new BoxType { Name = "account_number", textName = " 手机号", prompt = "请输入手机号", Type = 8, is_required = true });
GameObject gameObject = add_pop_up(true);//生成弹窗母体
gameObject.GetComponent<input_box_pop_up_window>().minHeight = 150;
gameObject.GetComponent<input_box_pop_up_window>().setScrollMode(0);
List<GameObject> gameObjects = gameObject.GetComponent<input_box_pop_up_window>().updateUI(boxTypes, "赠送好友");//回调处理
List<GameObject> gameObjectitems = new List<GameObject>();
gameObjects[0].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>//登录确定或取消
{
foreach (GameObject item in gameObjectitems)
{
gameObject.GetComponent<input_box_pop_up_window>().Remove(item);
}
gameObject.GetComponent<input_box_pop_up_window>().minHeight = 900;
gameObject.GetComponent<input_box_pop_up_window>().setScrollMode(1);
//获取玩家数量代码。。。。。。。
List<BoxType> boxTypes = new List<BoxType>();
for (int i = 0; i < Random.Range(5,20); i++)
{
boxTypes.Add(new BoxType {textName = " 查找到的玩家",Type = 7 });
}
gameObjectitems = gameObject.GetComponent<input_box_pop_up_window>().updateUI(boxTypes, "赠送好友");
foreach (GameObject item in gameObjectitems)
{
item.GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) => {
List<BoxType> boxTypeser = new List<BoxType>();
boxTypeser.Add(new BoxType { Name = "account_number", textName = "二次确定", content = "xxxxxxxxxxx", Type = 9, is_required = true });
boxTypeser.Add(new BoxType { Name = "account_number", textName = "确认取消按钮", Type = 2, is_required = true });
GameObject ercitanchuang = add_pop_up(true);//生成弹窗母体
ercitanchuang.GetComponent<input_box_pop_up_window>().is_force = false;
List <GameObject> ercitanchuangs = ercitanchuang.GetComponent<input_box_pop_up_window>().updateUI(boxTypeser, "警告");
ercitanchuangs[1].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>
{
});
});
}
});
}
}