_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/Battle_Royale/AllHouseContro.cs

262 lines
9.2 KiB
C#
Raw Normal View History

2024-11-15 23:31:54 +08:00
using Newtonsoft.Json;
2024-11-14 18:11:08 +08:00
using System.Collections;
using System.Collections.Generic;
2024-11-15 23:31:54 +08:00
using System.Threading.Tasks;
2024-11-14 18:11:08 +08:00
using UnityEditor;
using UnityEngine;
2024-11-15 23:31:54 +08:00
using UnityEngine.UI;
2024-11-16 02:05:07 +08:00
using UnityEngine.Windows;
2024-11-15 23:31:54 +08:00
using static UnityEditor.Progress;
using static UnityEngine.UIElements.UxmlAttributeDescription;
2024-11-14 18:11:08 +08:00
public class AllHouseContro : MonoBehaviour
{
public List<HouseBtn> HouseBtnList=new List<HouseBtn>();
2024-11-15 23:31:54 +08:00
public int roomNo = -1;
public int escapeId = -1;
public GameObject text;
public GameObject detailsText;
public HouseBtn house;
2024-11-16 02:05:07 +08:00
public List<GameObject> bossobj;
2024-11-16 05:56:57 +08:00
public HouseBtn BoosHouse;//Boos<6F><73><EFBFBD><EFBFBD>
public GameObject BazhuPanel;
public WarnPanel warnPanel;
public List<GameObject> wonnius = new List<GameObject>();
2024-11-14 18:11:08 +08:00
// Start is called before the first frame update
2024-11-15 23:31:54 +08:00
async void Start()
2024-11-14 18:11:08 +08:00
{
2024-11-15 23:31:54 +08:00
battleRoyaleGameDetails();
InvokeRepeating("checkOutAllTheEscapeRoomsAsync", 2,2);
2024-11-14 18:11:08 +08:00
}
2024-11-15 23:31:54 +08:00
void OnDestroy()
{
CancelInvoke("checkOutAllTheEscapeRoomsAsync");
}
public async Task battleRoyaleGameDetails()//5.1.1
{
2024-11-16 16:01:27 +08:00
2024-11-15 23:31:54 +08:00
foreach (HouseBtn item in HouseBtnList)
2024-11-16 16:01:27 +08:00
{
2024-11-15 23:31:54 +08:00
item.gameObject.GetComponentInChildren<Button>().onClick.RemoveAllListeners();
2024-11-16 05:56:57 +08:00
item.gameObject.GetComponentInChildren<Button>().onClick.AddListener(item.OnClickBtn);
2024-11-16 16:01:27 +08:00
//item.wn.GetComponent<wuniusj>().show();
2024-11-15 23:31:54 +08:00
}
2024-11-16 16:01:27 +08:00
2024-11-15 23:31:54 +08:00
Dictionary<string, string> head511 = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
2024-11-16 16:01:27 +08:00
2024-11-15 23:31:54 +08:00
string response511 = await web.SendRequest(web.URL + "/snail/gameEscape/queryLatest", "POST", "{}", head511);
Debug.Log("5.1.1<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ" + response511);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
2024-11-16 02:05:07 +08:00
Global.global.response = JsonConvert.DeserializeObject<ServerResponse>(response511);
2024-11-15 23:31:54 +08:00
escapeId = Global.global.response.data.gameEscapeModel.id;
int index = 0;
foreach (GameEscapeRoomResponseVo item in Global.global.response.data.gameEscapeRoomResponseVoList)
{
2024-11-16 05:56:57 +08:00
2024-11-15 23:31:54 +08:00
HouseBtnList[index].escapeId = item.escapeId;
HouseBtnList[index].roomNo = item.roomNo;
HouseBtnList[index].roomBeansCoin = item.roomBeansCoin;
HouseBtn a = HouseBtnList[index];
HouseBtnList[index].gameObject.GetComponentInChildren<Button>().onClick.AddListener(() => {
roomNo = item.roomNo;
Debug.Log(a.gameObject.name);
house = a;
Debug.Log("=====-----" + item.roomNo.ToString());
});
2024-11-16 05:56:57 +08:00
2024-11-15 23:31:54 +08:00
index++;
}
is_jisha_jiesuan = false;
is_jisha = false;
2024-11-16 02:24:44 +08:00
2024-11-15 23:31:54 +08:00
}
public bool is_jisha = false;
public bool is_jisha_jiesuan = false;
public async void checkOutAllTheEscapeRoomsAsync()//5.1.2
{
//Debug.Log("===");
userIDgameId body = new userIDgameId();
body.userId = Global.global.serverResponse.data.userId;
body.escapeId = escapeId;
string response = await web.SendRequest(web.URL+"/snail/gameEscape/queryEscapeRoomList", "POST", JsonUtility.ToJson(body), Global.global.CreateHeaders());
2024-11-16 02:05:07 +08:00
Debug.Log("5.1.2<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ: " + response);
2024-11-15 23:31:54 +08:00
ServerResponse serverResponse = JsonConvert.DeserializeObject<ServerResponse>(response);
int index = 0;
foreach (var item in serverResponse.data.gameEscapeRoomResponseVoList){
HouseBtnList[index].text.GetComponentInChildren<TextBox>().SetText(item.roomBeansCoin);
index++;
}
if(serverResponse.data.carrySeconds == -1)
{
detailsText.GetComponentInChildren<Text>().text = "<22><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
battleRoyaleGameDetails();
}
else if (serverResponse.data.carrySeconds < 45){
2024-11-16 02:24:44 +08:00
ControAllDoorOpen();
2024-11-15 23:31:54 +08:00
text.GetComponentInChildren<Text>().text = (60 - serverResponse.data.carrySeconds).ToString();
detailsText.GetComponentInChildren<Text>().text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
await Task.Delay(1000);
text.GetComponentInChildren<Text>().text = (60 - serverResponse.data.carrySeconds - 1).ToString();
}
else if (serverResponse.data.carrySeconds > 45 && serverResponse.data.carrySeconds < 50)
{
2024-11-16 02:24:44 +08:00
ControAllDoorClose();//<2F><><EFBFBD><EFBFBD>
2024-11-16 05:56:57 +08:00
OpenBoosDoor(BoosHouse);//boos<6F><73><EFBFBD><EFBFBD>
2024-11-15 23:31:54 +08:00
text.GetComponentInChildren<Text>().text = "";
detailsText.GetComponentInChildren<Text>().text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
if (!is_jisha){
is_jisha = true;
2024-11-16 05:56:57 +08:00
warnPanel.ShowPanel();
await Task.Delay(2000);
warnPanel.HidePanel();
2024-11-15 23:31:54 +08:00
response = await web.SendRequest(web.URL + "/snail/gameEscape/queryKill", "POST", JsonUtility.ToJson(body), Global.global.CreateHeaders());
2024-11-16 05:56:57 +08:00
//Debug.Log("5.1.4: " + response);
2024-11-16 02:05:07 +08:00
ServerResponse514 serverResponse_514 = JsonConvert.DeserializeObject<ServerResponse514>(response);
2024-11-15 23:41:28 +08:00
2024-11-16 02:05:07 +08:00
string[] parts = serverResponse_514.data.roomNoKill.Split(","); // <20><><EFBFBD><EFBFBD> ',' <20>ָ<EFBFBD><D6B8>ַ<EFBFBD><D6B7><EFBFBD>d
int index_ = 0;
foreach (string part in parts) {
if (parts.Length > index_)
{
int a = 0;
foreach (HouseBtn item in HouseBtnList)
{
if (a == int.Parse(parts[index_])) {
bossobj[index_].GetComponent<BossContro>().BossMove(int.Parse(parts[index_]));
bossobj[index_].GetComponent<PlayerMove>().room_id = parts[index_];
}
a++;
}
index_++;
}
2024-11-16 05:56:57 +08:00
else
{
Debug.Log("sdsdsdssssssssssssssss" + parts.Length);
}
2024-11-16 02:05:07 +08:00
}
2024-11-15 23:31:54 +08:00
}
}
else if (serverResponse.data.carrySeconds > 50) {
2024-11-16 05:56:57 +08:00
CloseBoosDoor(BoosHouse);
2024-11-15 23:31:54 +08:00
text.GetComponentInChildren<Text>().text = "";
detailsText.GetComponentInChildren<Text>().text = "<22><><EFBFBD><EFBFBD>";
2024-11-16 05:56:57 +08:00
2024-11-15 23:31:54 +08:00
if (!is_jisha_jiesuan)
{
is_jisha_jiesuan = true;
response = await web.SendRequest(web.URL + "/snail/gameEscape/queryUserBetResult", "POST", JsonUtility.ToJson(body), Global.global.CreateHeaders());
Debug.Log("5.1.5: " + response);
2024-11-16 05:56:57 +08:00
ServerResponse515 serverResponse_515 = JsonConvert.DeserializeObject<ServerResponse515>(response);
if (serverResponse_515.data==null)
{
Debug.Log("5.1.5:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>");
}
else
{
switch (serverResponse_515.data.outcome)
{
case 0:
Debug.Log(<>н<EFBFBD><D0BD><EFBFBD>");
break;
case 1:
SucceePanel.instance.ShowPanel();
Debug.Log(<><CAA4>");
BoosReturn();
break;
case 2:
FailPanel.instance.ShowPanel();
Debug.Log(<><CAA7>");
BoosReturn();
break;
}
}
2024-11-15 23:31:54 +08:00
}
}
}
2024-11-16 05:56:57 +08:00
public void BoosReturn()
{
foreach (GameObject item in bossobj)//Boos<6F><73>ȥ
{
item.GetComponent<BossContro>().ReturnParent();
}
}
2024-11-14 18:11:08 +08:00
public void ControAllDoorOpen()
{
for (int i=0;i<HouseBtnList.Count;i++)
{
if (!HouseBtnList[i].DoorIsOpen)
{
Tools.MoveUpOrDwon(HouseBtnList[i].door,270);
HouseBtnList[i].DoorIsOpen = true;
}
}
}
public void ControAllDoorClose()
{
for (int i = 0; i < HouseBtnList.Count; i++)
{
if (HouseBtnList[i].DoorIsOpen)
{
Tools.MoveUpOrDwon(HouseBtnList[i].door, -270);
HouseBtnList[i].DoorIsOpen = false;
}
}
}
public void ControOneDoorOpen(int id,System.Action onComplete = null)
{
Tools.MoveUpOrDwon(HouseBtnList[id-1].door, 270,onComplete);
HouseBtnList[id-1].DoorIsOpen = true;
}
public void ControOneDoorClose(int id, System.Action onComplete = null)
{
Tools.MoveUpOrDwon(HouseBtnList[id - 1].door, -270, onComplete);
HouseBtnList[id - 1].DoorIsOpen = false;
}
2024-11-16 05:56:57 +08:00
public void OpenBoosDoor(HouseBtn boosHouse)
{
if (!boosHouse.DoorIsOpen)
{
Tools.MoveUpOrDwon(boosHouse.door, 270);
boosHouse.DoorIsOpen = true;
}
}
public void CloseBoosDoor(HouseBtn boosHouse)
{
if (boosHouse.DoorIsOpen)
{
Tools.MoveUpOrDwon(boosHouse.door, -270);
boosHouse.DoorIsOpen = false;
}
}
2024-11-14 18:11:08 +08:00
}