This commit is contained in:
hyskai 2024-11-04 23:20:25 +08:00
parent 87d9fd73a9
commit 1a65bd5dff
9 changed files with 148 additions and 101 deletions

View File

@ -732,6 +732,12 @@ MonoBehaviour:
number: 1
max: 10
minerjiage: 0
rooms:
- {fileID: 361643069}
- {fileID: 1026708935}
- {fileID: 1262522313}
- {fileID: 1737182421}
- {fileID: 1625391898}
--- !u!1 &138158026
GameObject:
m_ObjectHideFlags: 0
@ -5913,19 +5919,19 @@ MonoBehaviour:
type: 2
buy_type: 0
toolsNumber: 0
haveNumber_text: {fileID: 1337763590}
toolsNumber_text: {fileID: 1489572594}
haveNumber_text: {fileID: 889190687}
toolsNumber_text: {fileID: 1983841859}
minerPrefab: {fileID: 4851271842099260498, guid: 012a53cdd7479ae4ab0266e1c577a1ea, type: 3}
gold: {fileID: 1987812376}
startPos: {fileID: 379972121}
gold: {fileID: 1664782296}
startPos: {fileID: 1267245799}
itemlist: []
cazhi:
- {fileID: 2006961055}
- {fileID: 1058917053}
- {fileID: 24607055}
- {fileID: 1131956201}
- {fileID: 1206549371}
BlackRoom: {fileID: 982477524}
- {fileID: 1984899085}
- {fileID: 1248061564}
- {fileID: 1148382598}
- {fileID: 1507938809}
- {fileID: 1675356532}
BlackRoom: {fileID: 314702314}
Boom: {fileID: 1998930180334184709, guid: 1af55f3362cdbd643937d48b138bef77, type: 3}
--- !u!1 &1058917053
GameObject:
@ -7038,19 +7044,19 @@ MonoBehaviour:
type: 4
buy_type: 0
toolsNumber: 0
haveNumber_text: {fileID: 1337763590}
toolsNumber_text: {fileID: 1489572594}
haveNumber_text: {fileID: 1512878292}
toolsNumber_text: {fileID: 1696745609}
minerPrefab: {fileID: 7704353754827174037, guid: d425dcacef66eca459336ad16ca91fea, type: 3}
gold: {fileID: 1987812376}
startPos: {fileID: 379972121}
gold: {fileID: 1551659950}
startPos: {fileID: 1619078991}
itemlist: []
cazhi:
- {fileID: 2006961055}
- {fileID: 1058917053}
- {fileID: 24607055}
- {fileID: 1131956201}
- {fileID: 1206549371}
BlackRoom: {fileID: 982477524}
- {fileID: 2036569190}
- {fileID: 1643129387}
- {fileID: 140676918}
- {fileID: 36724430}
- {fileID: 331442506}
BlackRoom: {fileID: 64041271}
Boom: {fileID: 1998930180334184709, guid: 1af55f3362cdbd643937d48b138bef77, type: 3}
--- !u!1 &1267245798
GameObject:
@ -10161,19 +10167,19 @@ MonoBehaviour:
type: 8
buy_type: 0
toolsNumber: 0
haveNumber_text: {fileID: 1337763590}
toolsNumber_text: {fileID: 1489572594}
haveNumber_text: {fileID: 1467810887}
toolsNumber_text: {fileID: 881868761}
minerPrefab: {fileID: 8014035693471197394, guid: 4372a8c781dda0043989a8f5ae52c7fa, type: 3}
gold: {fileID: 1987812376}
startPos: {fileID: 379972121}
gold: {fileID: 1301220429}
startPos: {fileID: 861970738}
itemlist: []
cazhi:
- {fileID: 2006961055}
- {fileID: 1058917053}
- {fileID: 24607055}
- {fileID: 1131956201}
- {fileID: 1206549371}
BlackRoom: {fileID: 982477524}
- {fileID: 1153390233}
- {fileID: 2114148405}
- {fileID: 1222377782}
- {fileID: 992765135}
- {fileID: 1954144235}
BlackRoom: {fileID: 927504749}
Boom: {fileID: 1998930180334184709, guid: 1af55f3362cdbd643937d48b138bef77, type: 3}
--- !u!1 &1625551201
GameObject:
@ -10864,19 +10870,19 @@ MonoBehaviour:
type: 6
buy_type: 0
toolsNumber: 0
haveNumber_text: {fileID: 1337763590}
toolsNumber_text: {fileID: 1489572594}
haveNumber_text: {fileID: 1526054076}
toolsNumber_text: {fileID: 1867062610}
minerPrefab: {fileID: 1727175300942666191, guid: bf95ad2db6c84cf4fbcc507e787c7a99, type: 3}
gold: {fileID: 1987812376}
startPos: {fileID: 379972121}
gold: {fileID: 1312070552}
startPos: {fileID: 961551742}
itemlist: []
cazhi:
- {fileID: 2006961055}
- {fileID: 1058917053}
- {fileID: 24607055}
- {fileID: 1131956201}
- {fileID: 1206549371}
BlackRoom: {fileID: 982477524}
- {fileID: 1885928845}
- {fileID: 142504042}
- {fileID: 838613213}
- {fileID: 3798958}
- {fileID: 234795530}
BlackRoom: {fileID: 1676301279}
Boom: {fileID: 1998930180334184709, guid: 1af55f3362cdbd643937d48b138bef77, type: 3}
--- !u!1 &1747948505
GameObject:

View File

@ -47,6 +47,7 @@ public class web : MonoBehaviour
if (request.result == UnityWebRequest.Result.ConnectionError || request.result == UnityWebRequest.Result.ProtocolError)
{
Debug.LogError($"Error: {request.error}");
Promptmgr.Instance.PromptBubble("网络异常",Color.black,Color.red);
return null;
}
else

View File

@ -3,7 +3,8 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UIElements;
using static input_box_pop_up_window;
[Serializable]
public class RootObject
@ -19,6 +20,9 @@ public class JinShaBuy : mount
public int number=1;
public int max = 10;
public int minerjiage = 0;
public List<GameObject> rooms;
public override void Awake()
{
@ -59,7 +63,7 @@ public class JinShaBuy : mount
//初始化
number = 1;
this.minerjiage = (int)minerjiage;
max = (int)(float.Parse(AssestPanel.instance.Coin.text) / minerjiage);
max = (int)(float.Parse(AssestPanel.instance.Coin.text) / minerjiage)>10?10: (int)(float.Parse(AssestPanel.instance.Coin.text) / minerjiage);
//max = int.Parse(AssestPanel.instance.Coin.text) / this.minerjiage;
gameObjects[0].GetComponent<input_box_pop_up_window_item>().numbertextobj1.GetComponent<Text>().text = (this.minerjiage * number).ToString();
@ -75,7 +79,7 @@ public class JinShaBuy : mount
if (number>1)
{
number--;
max = (int)(float.Parse(AssestPanel.instance.Coin.text) / minerjiage);
max = (int)(float.Parse(AssestPanel.instance.Coin.text) / minerjiage) > 10 ? 10 : (int)(float.Parse(AssestPanel.instance.Coin.text) / minerjiage);
gameObjects[0].GetComponent<input_box_pop_up_window_item>().numbertextobj1.GetComponent<Text>().text = (this.minerjiage*number).ToString();
gameObjects[0].GetComponent<input_box_pop_up_window_item>().numbertextobj2.GetComponent<Text>().text = number.ToString();
UpdateText(gameObjects[1].GetComponent<input_box_pop_up_window_item>().contentobj.GetComponent<Text>());
@ -86,7 +90,7 @@ public class JinShaBuy : mount
if (number < max)
{
number++;
max = (int)(float.Parse(AssestPanel.instance.Coin.text) / minerjiage);
max = (int)(float.Parse(AssestPanel.instance.Coin.text) / minerjiage) > 10 ? 10 : (int)(float.Parse(AssestPanel.instance.Coin.text) / minerjiage);
gameObjects[0].GetComponent<input_box_pop_up_window_item>().numbertextobj1.GetComponent<Text>().text = (this.minerjiage * number).ToString();
gameObjects[0].GetComponent<input_box_pop_up_window_item>().numbertextobj2.GetComponent<Text>().text = number.ToString();
UpdateText(gameObjects[1].GetComponent<input_box_pop_up_window_item>().contentobj.GetComponent<Text>());
@ -97,7 +101,7 @@ public class JinShaBuy : mount
if (number!= max)
{
number=max;
max = (int)(float.Parse(AssestPanel.instance.Coin.text) / minerjiage);
max = (int)(float.Parse(AssestPanel.instance.Coin.text) / minerjiage) > 10 ? 10 : (int)(float.Parse(AssestPanel.instance.Coin.text) / minerjiage);
gameObjects[0].GetComponent<input_box_pop_up_window_item>().numbertextobj1.GetComponent<Text>().text = (this.minerjiage * number).ToString();
gameObjects[0].GetComponent<input_box_pop_up_window_item>().numbertextobj2.GetComponent<Text>().text = number.ToString();
UpdateText(gameObjects[1].GetComponent<input_box_pop_up_window_item>().contentobj.GetComponent<Text>());
@ -122,6 +126,10 @@ public class JinShaBuy : mount
generateForFisherElf.Count = Convert.ToInt32(number);
string response = await web.SendRequest(web.URL + "/Voucher/GenerateForMinerElf", "POST", JsonUtility.ToJson(generateForFisherElf));
Promptmgr.Instance.PromptBubble("购买精灵成功", Color.black,Color.blue);
int index1 = Num - 1;
int index2 = (Num - 1)*2;
rooms[index1].GetComponent<RoomJinsha>().addman(index2, number);
}
else
{
@ -132,6 +140,10 @@ public class JinShaBuy : mount
string response = await web.SendRequest(web.URL + "/Item/Buy", "POST", JsonUtility.ToJson(itmebuy));
Debug.Log(response);
Promptmgr.Instance.PromptBubble("购买设备成功", Color.black, Color.blue);
int index1 = Num - 74;
int index2 = (Num - 74)*2;
rooms[index1].GetComponent<RoomJinsha>().addtools(index2, number);
}
}
});

View File

@ -20,15 +20,15 @@ public class AssestPanel : MonoBehaviour
Coin.text=PlayerManager.Instance.Coins.ToString();
Ore.text=PlayerManager.Instance.Ore.ToString();
InvokeRepeating("ExecuteTask", 1.0f, 1.0f);
loding();
InvokeRepeating("ExecuteTask", 1.0f, 1.0f);
}
public async void loding()
{
Login login = new Login();
login.Phone = "111";
login.Phone = "1";
await web.SendRequest(web.URL + "/Player/Login", "POST", JsonUtility.ToJson(login));
}

View File

@ -27,6 +27,8 @@ public class RoomJinsha : mount
public GameObject Boom;
private bool Buy_succefful = false;
public static bool Can = true;
// Start is called before the first frame update
public override void Awake()
{
@ -34,6 +36,7 @@ public class RoomJinsha : mount
}
void Start()
{
if (toolsNumber_text == null)
@ -44,24 +47,27 @@ public class RoomJinsha : mount
ChangeTextPro();
loding();
//Allminer();
jinsha.intance.OnType += addman;
jinsha.intance.OnType += addtools;
//Debug.Log(this.gameObject.name+":"+this.type);
}
private void OnDisable()
{
jinsha.intance.OnType -= addman;
jinsha.intance.OnType -= addtools;
//jinsha.intance.OnType -= addman;
//jinsha.intance.OnType -= addtools;
}
private async void OnTouch()
{
if (!Can)
{
return;
}
if (haveNumber < 1 || toolsNumber < 1)
{
Promptmgr.Instance.PromptBubble("人数或工具不足", Color.black, Color.red);
@ -95,6 +101,11 @@ public class RoomJinsha : mount
private async void OnMouseDown()
{
if (!Can)
{
return;
}
if (haveNumber < 1 || toolsNumber < 1)
{
Promptmgr.Instance.PromptBubble("人数或工具不足", Color.black, Color.red);
@ -149,8 +160,11 @@ public class RoomJinsha : mount
}
void addman(int type, int num)
public void addman(int type, int num)
{
Debug.LogError("=======================");
Debug.LogError(type);
Debug.LogError(this.type);
if (type == this.type)
{
Debug.Log("扣钱检测");
@ -159,7 +173,7 @@ public class RoomJinsha : mount
Promptmgr.Instance.PromptBubble("购买卷不足", Color.black, Color.red);
return;
}
PlayerManager.Instance.SetMoney(MoneyType.Coins, -10);
//PlayerManager.Instance.SetMoney(MoneyType.Coins, -10);
if ((startPos.childCount + haveNumber) > 9)
@ -183,18 +197,21 @@ public class RoomJinsha : mount
}
void addtools(int type, int num)
public void addtools(int type, int num)
{
if (type == this.type + 1)
Debug.LogError("=======================");
Debug.LogError(type);
Debug.LogError(this.type);
if (type == this.type)
{
Debug.LogError("111111111111111111111111111");
Debug.Log("扣钱检测");
if (PlayerManager.Instance.GetNumer(MoneyType.Coins) < 11)
{
Promptmgr.Instance.PromptBubble("购买卷不足", Color.black, Color.red);
return;
}
PlayerManager.Instance.SetMoney(MoneyType.Coins, -10);
//PlayerManager.Instance.SetMoney(MoneyType.Coins, -10);
if ((startPos.childCount + toolsNumber) > 9)
@ -209,8 +226,6 @@ public class RoomJinsha : mount
return;
}
toolsNumber += 1;
Promptmgr.Instance.PromptBubble("购买成功");
UpdateShowCazhi();
@ -220,12 +235,7 @@ public class RoomJinsha : mount
}
}
private async void loding()
{
Login login = new Login();
login.Phone = "123456666";
await web.SendRequest(web.URL + "/Player/Login", "POST", JsonUtility.ToJson(login));
}
@ -312,4 +322,5 @@ public class RoomJinsha : mount
break;
}
}
}

View File

@ -26,14 +26,14 @@ public class boy_jiashaMine : mount
private async void Start()
{
//登入,测试用
Login login = new Login();
/*Login login = new Login();
login.Phone = "tast11";
await web.SendRequest(web.URL + "/Player/Login", "POST", JsonUtility.ToJson(login));
await web.SendRequest(web.URL + "/Player/Login", "POST", JsonUtility.ToJson(login));*/
/*
UpShip();
InvokeRepeating("UpShip", 1.0f, 1.0f);
InvokeRepeating("UpShip", 1.0f, 1.0f);*/
}

View File

@ -33,24 +33,32 @@ public class jinsha : mount
public int type = 0;
////²âÊÔÓÃ
private async void loding()
{
Login login = new Login();
login.Phone = "1";
await web.SendRequest(web.URL + "/Player/Login", "POST", JsonUtility.ToJson(login));
}
public async void Start()
{
base.LoadAllJsonFiles();
}
public async void buy_miners()//购买金币矿工界面
{
////²âÊÔÓÃ
Login login = new Login();
login.Phone = "1";
await web.SendRequest(web.URL + "/Player/Login", "POST", JsonUtility.ToJson(login));
// loding();
Response response = new Response();
//关闭摄像头逻辑
Cinemachine_2dCon.SetCameraContorl(false);
RoomJinsha.Can = false;
Response response = new Response();
string userponse = await web.SendRequest(web.URL+ "/MinerElf/GetList","POST");
//Debug.Log(userponse);
Response itemList = JsonUtility.FromJson<Response>(userponse);
@ -63,7 +71,6 @@ public class jinsha : mount
List<GameObject> list_sb = new List<GameObject>();//设备
foreach (Item item in itemList.List)
{
//Debug.Log(Struct.StructToString(item,1));
if (type == item.Type)
{
boxTypes.Add(new BoxType { Name = index.ToString() + "文本", prompt = "第" + ArabicToChineseNumberConverter.ConvertToChineseNumbers(index.ToString()) + "层", Type = 4, is_required = true });
@ -72,17 +79,26 @@ public class jinsha : mount
index++;
}
}
GameObject gameObject = add_pop_up();
gameObject.GetComponent<input_box_pop_up_window>().minHeight = 800;//设置最低高度
gameObject.GetComponent<input_box_pop_up_window>().setScrollMode(1);//设置滚动模式为滚动
Dictionary<string, GameObject> gameObjects = gameObject.GetComponent<input_box_pop_up_window>().updateUI_Dic(boxTypes, "矿工招募");
gameObject.GetComponent<input_box_pop_up_window>().OnEnd += () => {
//¹Ø±ÕÉãÏñÍ·Âß¼­
Cinemachine_2dCon.SetCameraContorl(true);
RoomJinsha.Can = true;
};
foreach (string key in gameObjects.Keys)
{
if (key.Contains("矿工"))
{
gameObjects[key].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) => {
gameObjects[key].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>
{
if (type == 1)
{
if (boxType.customData is BoxData<Item> intData)//通过储存的泛型来查找挖矿精灵对应的item数据
@ -90,7 +106,6 @@ public class jinsha : mount
Item item = intData.GetTypedData();
Thingid = item.Id.ToString();
go.Show_buy(boxType.icon, boxType.prompt, 64, item.Num, item.ActivateValue);
}
@ -134,7 +149,8 @@ public class jinsha : mount
//收束
foreach (GameObject item in gameObjectitems)
{
item.GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) => {
item.GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>
{
Debug.Log(boxType.customData);
if (boxType.customData is BoxData<PlayerData> intData)//通过储存的泛型来查找挖矿精灵对应的item数据
{
@ -172,7 +188,8 @@ public class jinsha : mount
}
else if (key.Contains("挖矿设备"))
{
gameObjects[key].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) => {
gameObjects[key].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>
{
if (type == 1)
{
//Debug.Log(boxType.customData);
@ -222,7 +239,8 @@ public class jinsha : mount
//收束
foreach (GameObject item in gameObjectitems)
{
item.GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) => {
item.GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>
{
Debug.Log(boxType.customData);
if (boxType.customData is BoxData<PlayerData> intData)//通过储存的泛型来查找挖矿精灵对应的item数据
{
@ -242,7 +260,6 @@ public class jinsha : mount
{
if (type == 1)
{
//赠送逻辑
ercitanchuang.GetComponent<input_box_pop_up_window>().destroy();
}
@ -258,11 +275,11 @@ public class jinsha : mount
}
});
}
}
}
}

View File

@ -17,9 +17,9 @@ public class boy : mount
private async void Start()
{
//测试用
Login login = new Login();
/*Login login = new Login();
login.Phone = "111";
await web.SendRequest(web.URL + "/Player/Login", "POST", JsonUtility.ToJson(login));
await web.SendRequest(web.URL + "/Player/Login", "POST", JsonUtility.ToJson(login));*/