This commit is contained in:
shurongsen 2024-11-03 15:09:40 +08:00
parent a01dfe42d4
commit 760a004c6b
6 changed files with 100 additions and 25 deletions

View File

@ -72,13 +72,22 @@ public class Mining_Wizard_ID //
} }
public class Giveaway //ÔùËÍ´ú½ð¾í
{
public string[] Ids;
public string GiftTargetId;
}
public class AllVocherItem //所有代金卷数据 public class AllVocherItem //所有代金卷数据
{ {
public string Id; public string Id;
public string GeneratorId; public string GeneratorId;
public string OwnerId; public string OwnerId;
public float Type; public int Type;
public float Num; public int Num;
public bool IsUsed; public bool IsUsed;
public bool IsAdmin; public bool IsAdmin;
public string UsedDateTime; public string UsedDateTime;
@ -87,8 +96,8 @@ public class AllVocherItem //
[Serializable] [Serializable]
public class AllVocherItemRes : Res { public class AllVocherItemRes : Res
public object Ids; {
public AllVocherItem[] List; public AllVocherItem[] List;
} }
[Serializable] [Serializable]
@ -107,6 +116,8 @@ public class GenerateForFisherElf //
public int Num; public int Num;
public int Count; public int Count;
} }
[Serializable] [Serializable]
public class Use //使用道具 public class Use //使用道具
{ {

View File

@ -25,9 +25,9 @@ public class Get_a_voucher : mount
async void ExecuteTask() async void ExecuteTask()
{ {
string userponse = await web.SendRequest(web.URL + "/Voucher/GetList", "POST"); string userponse = await web.SendRequest(web.URL + "/Voucher/GetList", "POST");
Debug.Log(userponse); // Debug.Log(userponse);
AllVocherItemRes itemList = JsonUtility.FromJson<AllVocherItemRes>(userponse); AllVocherItemRes itemList = JsonUtility.FromJson<AllVocherItemRes>(userponse);
Debug.Log(itemList.List); // Debug.Log(itemList.List.Length);

View File

@ -100,14 +100,15 @@ public class JinShaBuy : mount
Debug.Log(Num); Debug.Log(Num);
GenerateForFisherElf generateForFisherElf = new GenerateForFisherElf(); // 购买矿工 GenerateForFisherElf generateForFisherElf = new GenerateForFisherElf(); // 购买矿工
generateForFisherElf.Num = Num; generateForFisherElf.Num = Num;
generateForFisherElf.Count =Convert.ToInt32( boxTypes[1].content); generateForFisherElf.Count =Convert.ToInt32(boxTypes[1].content);
//Debug.Log(generateForFisherElf); //Debug.Log(generateForFisherElf);
string response = await web.SendRequest(web.URL+ "/Voucher/GenerateForMinerElf", "POST", JsonUtility.ToJson(generateForFisherElf)); string response = await web.SendRequest(web.URL+ "/Voucher/GenerateForMinerElf", "POST", JsonUtility.ToJson(generateForFisherElf));
Debug.Log("用户产生代金卷"+response); Debug.Log("用户产生代金卷"+response);
// Debug.Log(boxTypes[1].content); string daijinjuanponse = await web.SendRequest(web.URL + "/Voucher/GetList", "POST");
//number = int.Parse(boxTypes[0].content); Debug.Log("用户所有代金卷" + daijinjuanponse);
} }
}); });
} }

View File

@ -80,6 +80,10 @@ public class Logo_in : mount
string response = await web.SendRequest("http://47.109.133.52/Player/Login", "POST", jsonString); string response = await web.SendRequest("http://47.109.133.52/Player/Login", "POST", jsonString);
Debug.Log(response); Debug.Log(response);
string daijinjuanponse = await web.SendRequest(web.URL + "/Voucher/GetList", "POST");
Debug.Log("用户所有代金卷" + daijinjuanponse);
Rootobject root = JsonUtility.FromJson<Rootobject>(response); Rootobject root = JsonUtility.FromJson<Rootobject>(response);

View File

@ -16,9 +16,14 @@ public class jinsha : mount
public List<Sprite> icons; public List<Sprite> icons;
public List<Sprite> toolsicons; public List<Sprite> toolsicons;
private string userid;//赠送对象id
public string Thingid; //赠送物品id
public override void Awake() public override void Awake()
{ {
intance = this; intance = this;
} }
public class GetList : Res public class GetList : Res
@ -27,23 +32,33 @@ public class jinsha : mount
} }
public int type = 0; public int type = 0;
public async void loding()
{
}
public async void buy_miners()//购买金币矿工界面 public async void buy_miners()//购买金币矿工界面
{ {
//测试用 //测试用
Login login = new Login(); //Login login = new Login();
login.Phone = "1"; //login.Phone = "11111";
await web.SendRequest(web.URL + "/Player/Login", "POST", JsonUtility.ToJson(login)); //await web.SendRequest(web.URL + "/Player/Login", "POST", JsonUtility.ToJson(login));
////测试用 ////测试用
//Login login = new Login(); //Login login = new Login();
//login.Phone = "1"; //login.Phone = "1";
//await web.SendRequest(web.URL + "/Player/Login", "POST", JsonUtility.ToJson(login)); //await web.SendRequest(web.URL + "/Player/Login", "POST", JsonUtility.ToJson(login));
Response response = new Response(); Response response = new Response();
//关闭摄像头逻辑 //关闭摄像头逻辑
Cinemachine_2dCon.SetCameraContorl(false); Cinemachine_2dCon.SetCameraContorl(false);
string userponse = await web.SendRequest(web.URL+ "/MinerElf/GetList", "POST"); string userponse = await web.SendRequest(web.URL+ "/MinerElf/GetList","POST");
Debug.Log(userponse); Debug.Log(userponse);
Response itemList = JsonUtility.FromJson<Response>(userponse); Response itemList = JsonUtility.FromJson<Response>(userponse);
@ -78,6 +93,7 @@ public class jinsha : mount
{ {
Item item = intData.GetTypedData(); Item item = intData.GetTypedData();
Thingid = item.Id.ToString();
go.Show_buy(mount.mountitem.itemDataList[item.Id].IconPath,64, item.Num); go.Show_buy(mount.mountitem.itemDataList[item.Id].IconPath,64, item.Num);
} }
@ -126,6 +142,7 @@ public class jinsha : mount
{ {
PlayerData pldata = intData.GetTypedData(); PlayerData pldata = intData.GetTypedData();
userid = pldata.Id;
Debug.Log(pldata.Id); Debug.Log(pldata.Id);
} }
@ -139,8 +156,42 @@ public class jinsha : mount
{ {
if (type == 1) if (type == 1)
{ {
// string daijinjuanponse = await web.SendRequest(web.URL + "/Voucher/GetList", "POST");
// Debug.Log("获取所有的代金卷数据"+daijinjuanponse);
// AllVocherItemRes itemList = JsonUtility.FromJson<AllVocherItemRes>(daijinjuanponse);
// if (itemList.List.Length == 0)
// {
// Promptmgr.Instance.PromptBubble("没有代金卷");
// return;
// }
// foreach (AllVocherItem alltiem in itemList.List)//遍历返回的数据,如果中间没有想要赠送的代金卷提示没有。
// {
// if (alltiem.Id == Thingid)
// {
// }
// else
// {
// Promptmgr.Instance.PromptBubble("没有想要赠送的代金卷");
// return;
// }
//}
//string[] str = new string[] { };
//Array.Resize(ref str, str.Length + 1);
//str[str.Length - 1] = Thingid;
//Giveaway giveaway = new Giveaway();
//giveaway.Ids = str;
//giveaway.GiftTargetId = userid;
//string response = await web.SendRequest(web.URL + "/Voucher/Gift", "POST", JsonUtility.ToJson(giveaway));
//Debug.Log(response);
//赠送逻辑 //赠送逻辑
ercitanchuang.GetComponent<input_box_pop_up_window>().destroy(); ercitanchuang.GetComponent<input_box_pop_up_window>().destroy();
} }

View File

@ -30,7 +30,7 @@ public class room : mount
public GameObject Boom; public GameObject Boom;
private bool Buy_succefful =false;
// Start is called before the first frame update // Start is called before the first frame update
public override void Awake() public override void Awake()
{ {
@ -93,7 +93,7 @@ public class room : mount
ChangeTextPro(); ChangeTextPro();
//Vector3 //Vector3u
GameObject.Instantiate(Boom, new Vector3(startPos.position.x, startPos.position.y + 0.5f, startPos.position.z - 1f), Quaternion.identity); GameObject.Instantiate(Boom, new Vector3(startPos.position.x, startPos.position.y + 0.5f, startPos.position.z - 1f), Quaternion.identity);
await Task.Delay(500); await Task.Delay(500);
GameObject newMiner = GameObject.Instantiate(minerPrefab); GameObject newMiner = GameObject.Instantiate(minerPrefab);
@ -126,12 +126,15 @@ public class room : mount
PlayerManager.Instance.SetMoney(MoneyType.Stones, -10); PlayerManager.Instance.SetMoney(MoneyType.Stones, -10);
} }
if (!Buy_succefful) return;
Generate(1);
haveNumber--; haveNumber--;
toolsNumber--; toolsNumber--;
UpdateShowCazhi(); UpdateShowCazhi();
ChangeTextPro(); ChangeTextPro();
Generate(1);//创建对应id的矿工精灵 //创建对应id的矿工精灵
//Vector3 //Vector3
@ -232,7 +235,7 @@ public class room : mount
private async void loding() private async void loding()
{ {
Login login = new Login(); Login login = new Login();
login.Phone = "1"; login.Phone = "123456666";
await web.SendRequest(web.URL + "/Player/Login", "POST", JsonUtility.ToJson(login)); await web.SendRequest(web.URL + "/Player/Login", "POST", JsonUtility.ToJson(login));
} }
@ -243,14 +246,19 @@ public class room : mount
generateForFisherElf.Num = buy_type; generateForFisherElf.Num = buy_type;
generateForFisherElf.Count = count; generateForFisherElf.Count = count;
string response = await web.SendRequest(web.URL + "/Voucher/GenerateForMinerElf", "POST", JsonUtility.ToJson(generateForFisherElf)); string response = await web.SendRequest(web.URL + "/Voucher/GenerateForMinerElf", "POST", JsonUtility.ToJson(generateForFisherElf));
Debug.Log(response);
Mining_Wizard_ID data = JsonUtility.FromJson<Mining_Wizard_ID>(response);
Mining_Wizard_ID data = JsonUtility.FromJson<Mining_Wizard_ID>(response);
Use use = new Use(); Use use = new Use();
use.Id = data.Ids[0]; use.Id = data.Ids[0];
if (data.Ids[0] != null)
{
Buy_succefful = true;
}
string jsonString = JsonUtility.ToJson(use.Id); string jsonString = JsonUtility.ToJson(use.Id);
string aa =await web.SendRequest(web.URL + "/Voucher/Use", "POST", jsonString); string aa =await web.SendRequest(web.URL + "/Voucher/Use", "POST", jsonString);
Debug.Log(aa); Debug.Log(aa);
} }