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 string Id;
public string GeneratorId;
public string OwnerId;
public float Type;
public float Num;
public int Type;
public int Num;
public bool IsUsed;
public bool IsAdmin;
public string UsedDateTime;
@ -87,8 +96,8 @@ public class AllVocherItem //
[Serializable]
public class AllVocherItemRes : Res {
public object Ids;
public class AllVocherItemRes : Res
{
public AllVocherItem[] List;
}
[Serializable]
@ -107,6 +116,8 @@ public class GenerateForFisherElf //
public int Num;
public int Count;
}
[Serializable]
public class Use //使用道具
{

View File

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

View File

@ -105,8 +105,9 @@ public class JinShaBuy : mount
string response = await web.SendRequest(web.URL+ "/Voucher/GenerateForMinerElf", "POST", JsonUtility.ToJson(generateForFisherElf));
Debug.Log("用户产生代金卷"+response);
// Debug.Log(boxTypes[1].content);
//number = int.Parse(boxTypes[0].content);
string daijinjuanponse = await web.SendRequest(web.URL + "/Voucher/GetList", "POST");
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);
Debug.Log(response);
string daijinjuanponse = await web.SendRequest(web.URL + "/Voucher/GetList", "POST");
Debug.Log("用户所有代金卷" + daijinjuanponse);
Rootobject root = JsonUtility.FromJson<Rootobject>(response);

View File

@ -16,9 +16,14 @@ public class jinsha : mount
public List<Sprite> icons;
public List<Sprite> toolsicons;
private string userid;//赠送对象id
public string Thingid; //赠送物品id
public override void Awake()
{
intance = this;
}
public class GetList : Res
@ -27,18 +32,28 @@ public class jinsha : mount
}
public int type = 0;
public async void loding()
{
}
public async void buy_miners()//购买金币矿工界面
{
//测试用
Login login = new Login();
login.Phone = "1";
await web.SendRequest(web.URL + "/Player/Login", "POST", JsonUtility.ToJson(login));
//Login login = new Login();
//login.Phone = "11111";
//await web.SendRequest(web.URL + "/Player/Login", "POST", JsonUtility.ToJson(login));
////测试用
//Login login = new Login();
//login.Phone = "1";
//await web.SendRequest(web.URL + "/Player/Login", "POST", JsonUtility.ToJson(login));
Response response = new Response();
//关闭摄像头逻辑
Cinemachine_2dCon.SetCameraContorl(false);
@ -78,6 +93,7 @@ public class jinsha : mount
{
Item item = intData.GetTypedData();
Thingid = item.Id.ToString();
go.Show_buy(mount.mountitem.itemDataList[item.Id].IconPath,64, item.Num);
}
@ -126,6 +142,7 @@ public class jinsha : mount
{
PlayerData pldata = intData.GetTypedData();
userid = pldata.Id;
Debug.Log(pldata.Id);
}
@ -139,6 +156,40 @@ public class jinsha : mount
{
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);
//赠送逻辑

View File

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