From 1a65bd5dffd840d8f20aa785e73786b23c1b6730 Mon Sep 17 00:00:00 2001 From: hyskai <2545507770@qq.com> Date: Mon, 4 Nov 2024 23:20:25 +0800 Subject: [PATCH] add --- .../cultivation_Jinsha_mine_slices.unity | 86 ++++++++++--------- meng_yao/Assets/communal/web/web.cs | 1 + .../script/ConnactServer/Get_a_voucher.cs | 2 +- .../Assets/script/ConnactServer/JinShaBuy.cs | 22 +++-- meng_yao/Assets/script/Panel/AssestPanel.cs | 6 +- .../RoomJinsha.cs | 51 ++++++----- .../boy_jiashaMine.cs | 8 +- .../cultivation_Jinsha_mine_slices/jinsha.cs | 69 +++++++++------ .../cultivation_gold_coin_Island/boy.cs | 4 +- 9 files changed, 148 insertions(+), 101 deletions(-) diff --git a/meng_yao/Assets/Scenes/cultivation_Jinsha_mine_slices.unity b/meng_yao/Assets/Scenes/cultivation_Jinsha_mine_slices.unity index e4c38ce84..f7e27b460 100644 --- a/meng_yao/Assets/Scenes/cultivation_Jinsha_mine_slices.unity +++ b/meng_yao/Assets/Scenes/cultivation_Jinsha_mine_slices.unity @@ -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: diff --git a/meng_yao/Assets/communal/web/web.cs b/meng_yao/Assets/communal/web/web.cs index 5f17f1d2f..fb61d10a7 100644 --- a/meng_yao/Assets/communal/web/web.cs +++ b/meng_yao/Assets/communal/web/web.cs @@ -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 diff --git a/meng_yao/Assets/script/ConnactServer/Get_a_voucher.cs b/meng_yao/Assets/script/ConnactServer/Get_a_voucher.cs index 41a137420..6e9be9d7c 100644 --- a/meng_yao/Assets/script/ConnactServer/Get_a_voucher.cs +++ b/meng_yao/Assets/script/ConnactServer/Get_a_voucher.cs @@ -43,7 +43,7 @@ public class Get_a_voucher : mount // Update is called once per frame - void Update() + void Update() { } diff --git a/meng_yao/Assets/script/ConnactServer/JinShaBuy.cs b/meng_yao/Assets/script/ConnactServer/JinShaBuy.cs index 47e328093..594c41775 100644 --- a/meng_yao/Assets/script/ConnactServer/JinShaBuy.cs +++ b/meng_yao/Assets/script/ConnactServer/JinShaBuy.cs @@ -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 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().numbertextobj1.GetComponent().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().numbertextobj1.GetComponent().text = (this.minerjiage*number).ToString(); gameObjects[0].GetComponent().numbertextobj2.GetComponent().text = number.ToString(); UpdateText(gameObjects[1].GetComponent().contentobj.GetComponent()); @@ -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().numbertextobj1.GetComponent().text = (this.minerjiage * number).ToString(); gameObjects[0].GetComponent().numbertextobj2.GetComponent().text = number.ToString(); UpdateText(gameObjects[1].GetComponent().contentobj.GetComponent()); @@ -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().numbertextobj1.GetComponent().text = (this.minerjiage * number).ToString(); gameObjects[0].GetComponent().numbertextobj2.GetComponent().text = number.ToString(); UpdateText(gameObjects[1].GetComponent().contentobj.GetComponent()); @@ -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().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().addtools(index2, number); } } }); diff --git a/meng_yao/Assets/script/Panel/AssestPanel.cs b/meng_yao/Assets/script/Panel/AssestPanel.cs index 04fe06d25..aca3de410 100644 --- a/meng_yao/Assets/script/Panel/AssestPanel.cs +++ b/meng_yao/Assets/script/Panel/AssestPanel.cs @@ -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)); } diff --git a/meng_yao/Assets/script/cultivation_Jinsha_mine_slices/RoomJinsha.cs b/meng_yao/Assets/script/cultivation_Jinsha_mine_slices/RoomJinsha.cs index de92f762b..cc881bc4b 100644 --- a/meng_yao/Assets/script/cultivation_Jinsha_mine_slices/RoomJinsha.cs +++ b/meng_yao/Assets/script/cultivation_Jinsha_mine_slices/RoomJinsha.cs @@ -27,12 +27,15 @@ 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() { } + void Start() { @@ -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; } } + } diff --git a/meng_yao/Assets/script/cultivation_Jinsha_mine_slices/boy_jiashaMine.cs b/meng_yao/Assets/script/cultivation_Jinsha_mine_slices/boy_jiashaMine.cs index 4f5ec4146..ef27b15bc 100644 --- a/meng_yao/Assets/script/cultivation_Jinsha_mine_slices/boy_jiashaMine.cs +++ b/meng_yao/Assets/script/cultivation_Jinsha_mine_slices/boy_jiashaMine.cs @@ -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);*/ } diff --git a/meng_yao/Assets/script/cultivation_Jinsha_mine_slices/jinsha.cs b/meng_yao/Assets/script/cultivation_Jinsha_mine_slices/jinsha.cs index dd61a3a7f..754b1a61e 100644 --- a/meng_yao/Assets/script/cultivation_Jinsha_mine_slices/jinsha.cs +++ b/meng_yao/Assets/script/cultivation_Jinsha_mine_slices/jinsha.cs @@ -32,25 +32,33 @@ 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(userponse); @@ -62,8 +70,7 @@ public class jinsha : mount List list_kg = new List();//矿工 List list_sb = new List();//设备 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 }); @@ -71,18 +78,27 @@ public class jinsha : mount boxTypes.Add(new BoxType { Name = "挖矿设备" + index.ToString(), prompt = "挖矿设备·" + ArabicToChineseNumberConverter.ConvertToChineseNumbers(index.ToString()), Type = 3, icon = toolsicons[0],Num=73+index, customData = new BoxData(item) }); index++; - } - + } } GameObject gameObject = add_pop_up(); gameObject.GetComponent().minHeight = 800;//设置最低高度 gameObject.GetComponent().setScrollMode(1);//设置滚动模式为滚动 Dictionary gameObjects = gameObject.GetComponent().updateUI_Dic(boxTypes, "矿工招募"); + + + gameObject.GetComponent().OnEnd += () => { + //关闭摄像头逻辑 + Cinemachine_2dCon.SetCameraContorl(true); + RoomJinsha.Can = true; + }; + + foreach (string key in gameObjects.Keys) { if (key.Contains("矿工")) { - gameObjects[key].GetComponent().register_click(async (BoxType boxType, int type) => { + gameObjects[key].GetComponent().register_click(async (BoxType boxType, int type) => + { if (type == 1) { if (boxType.customData is BoxData 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().register_click(async (BoxType boxType, int type) => { + item.GetComponent().register_click(async (BoxType boxType, int type) => + { Debug.Log(boxType.customData); if (boxType.customData is BoxData intData)//通过储存的泛型来查找挖矿精灵对应的item数据 { @@ -170,17 +186,18 @@ public class jinsha : mount } }); } - else if(key.Contains("挖矿设备")) + else if (key.Contains("挖矿设备")) { - gameObjects[key].GetComponent().register_click(async (BoxType boxType, int type) => { + gameObjects[key].GetComponent().register_click(async (BoxType boxType, int type) => + { if (type == 1) { //Debug.Log(boxType.customData); if (boxType.customData is BoxData intData)//通过储存的泛型来查找对应的item数据 - { + { Item item = intData.GetTypedData(); - Thingid = item.Id.ToString(); - go.Show_buy(boxType.icon, boxType.prompt, 64, boxType.Num,itemDataList[boxType.Num].Gold,false); + Thingid = item.Id.ToString(); + go.Show_buy(boxType.icon, boxType.prompt, 64, boxType.Num, itemDataList[boxType.Num].Gold, false); } } else @@ -222,7 +239,8 @@ public class jinsha : mount //收束 foreach (GameObject item in gameObjectitems) { - item.GetComponent().register_click(async (BoxType boxType, int type) => { + item.GetComponent().register_click(async (BoxType boxType, int type) => + { Debug.Log(boxType.customData); if (boxType.customData is BoxData intData)//通过储存的泛型来查找挖矿精灵对应的item数据 { @@ -242,7 +260,6 @@ public class jinsha : mount { if (type == 1) { - //赠送逻辑 ercitanchuang.GetComponent().destroy(); } @@ -257,12 +274,12 @@ public class jinsha : mount }); } }); - } - + } } + + + - - } } diff --git a/meng_yao/Assets/script/cultivation_gold_coin_Island/boy.cs b/meng_yao/Assets/script/cultivation_gold_coin_Island/boy.cs index b1aa4b978..c29cce9f0 100644 --- a/meng_yao/Assets/script/cultivation_gold_coin_Island/boy.cs +++ b/meng_yao/Assets/script/cultivation_gold_coin_Island/boy.cs @@ -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));*/