其他蜗牛移动到房间随机位置,修复蜗牛在45秒后还能移动的bug

This commit is contained in:
GL 2024-11-21 17:27:26 +08:00
commit ec9349e919
8 changed files with 498 additions and 1105 deletions

File diff suppressed because it is too large Load Diff

View File

@ -3631,7 +3631,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 540, y: -1369.5}
m_AnchoredPosition: {x: 540, y: -1339.5}
m_SizeDelta: {x: 1018, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1071890038

View File

@ -51,19 +51,61 @@ public class AllHouseContro : MonoBehaviour
{
CancelInvoke("checkOutAllTheEscapeRoomsAsync");
}
public async Task ReGet511()
{
Dictionary<string, string> head511 = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
string response511 = await web.SendRequest(web.URL + "/snail/gameEscape/queryLatest", "POST", "{}", head511);
Debug.Log("5.1.1查询最近一场大屠杀" + response511);
// 解析服务器返回的数据
Global.global.response = JsonConvert.DeserializeObject<ServerResponse>(response511);
escapeId = Global.global.response.data.gameEscapeModel.id;
gameNo = Global.global.response.data.gameEscapeModel.gameNo;
int index = 0;
if (Global.global.response.data.gameEscapeRoomResponseVoList.Count>0)
{
foreach (GameEscapeRoomResponseVo item in Global.global.response.data.gameEscapeRoomResponseVoList)
{
if (HouseBtnList[index].roomNo == item.roomNo)
{
HouseBtnList[index].escapeId = item.escapeId;
HouseBtnList[index].roomBeansCoin = item.roomBeansCoin;
}
index++;
//HouseBtnList[index].roomNo = item.roomNo;
//HouseBtn a = HouseBtnList[index];
//HouseBtnList[index].gameObject.GetComponentInChildren<Button>().onClick.AddListener(() => {
// roomNo = item.roomNo;
// Debug.Log("所在房间Id" + roomNo);
// Debug.Log(a.gameObject.name);
// house = a;
// Debug.Log("=====-----" + item.roomNo.ToString());
//});
}
}
}
public async Task battleRoyaleGameDetails()//5.1.1
{
foreach (HouseBtn item in HouseBtnList)
{
item.gameObject.GetComponentInChildren<Button>().onClick.RemoveAllListeners();
item.gameObject.GetComponentInChildren<Button>().onClick.AddListener(item.OnClickBtn);
//item.gameObject.GetComponentInChildren<Button>().onClick.AddListener(() => {
// roomNo = item.roomNo;
//foreach (HouseBtn item in HouseBtnList)
//{
// //item.gameObject.GetComponentInChildren<Button>().onClick.RemoveAllListeners();
// //item.gameObject.GetComponentInChildren<Button>().onClick.AddListener(item.OnClickBtn);
// //item.gameObject.GetComponentInChildren<Button>().onClick.AddListener(() => {
// // roomNo = item.roomNo;
//});
//item.wn.GetComponent<wuniusj>().show();
}
// //});
// //item.wn.GetComponent<wuniusj>().show();
//}
Dictionary<string, string> head511 = new Dictionary<string, string>
{
@ -74,25 +116,34 @@ public class AllHouseContro : MonoBehaviour
Debug.Log("5.1.1查询最近一场大屠杀" + response511);
// 解析服务器返回的数据
Global.global.response = JsonConvert.DeserializeObject<ServerResponse>(response511);
escapeId = Global.global.response.data.gameEscapeModel.id;
gameNo = Global.global.response.data.gameEscapeModel.gameNo;
int index = 0;
foreach (GameEscapeRoomResponseVo item in Global.global.response.data.gameEscapeRoomResponseVoList)
if (Global.global.response.data.gameEscapeRoomResponseVoList.Count > 0)
{
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("所在房间Id"+roomNo);
Debug.Log(a.gameObject.name);
house = a;
Debug.Log("=====-----" + item.roomNo.ToString());
});
index++;
foreach (GameEscapeRoomResponseVo item in Global.global.response.data.gameEscapeRoomResponseVoList)
{
if (HouseBtnList[index].roomNo == item.roomNo)
{
HouseBtnList[index].escapeId = item.escapeId;
HouseBtnList[index].roomBeansCoin = item.roomBeansCoin;
}
index++;
//HouseBtnList[index].roomNo = item.roomNo;
//HouseBtn a = HouseBtnList[index];
//HouseBtnList[index].gameObject.GetComponentInChildren<Button>().onClick.AddListener(() => {
// roomNo = item.roomNo;
// Debug.Log("所在房间Id" + roomNo);
// Debug.Log(a.gameObject.name);
// house = a;
// Debug.Log("=====-----" + item.roomNo.ToString());
//});
}
}
is_jisha_jiesuan = false;
is_jisha = false;
@ -103,44 +154,54 @@ public class AllHouseContro : MonoBehaviour
public bool is_jisha = false;
public bool is_jisha_jiesuan = false;
public async void touzhu()
public async void ReHouseText()//刷新房间文本
{
RequestData body = new RequestData();
body.escapeId = escapeId;
body.bet = PlayerInfo.instance.AllBetCoins;
body.roomNo = roomNo;
Debug.Log("切换始roomNo" + body.roomNo);
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());
Debug.Log("5.1.2查询逃亡房间 请求:" + JsonUtility.ToJson(body) + " 详情响应: " + response);
ServerResponse serverResponse = JsonConvert.DeserializeObject<ServerResponse>(response);
//int index = 0;
foreach (var item in serverResponse.data.gameEscapeRoomResponseVoList)
{
foreach (HouseBtn houseBtn in HouseBtnList)
{
if (houseBtn.roomNo == item.roomNo)
{
houseBtn.roomBeansCoin = item.roomBeansCoin;
houseBtn.roomUserNo = item.roomUserNo;
houseBtn.text.GetComponentInChildren<TextBox>().SetText(item.roomBeansCoin);
string response = await web.SendRequest(web.URL + "/snail/gameEscape/userBet", "POST", JsonUtility.ToJson(body), Global.global.CreateHeaders());
Debug.Log("用户切换下注响应: " + response + "|||||" + "请求参数escapeId" + body.escapeId + " bet:" + body.bet + " roomNo:" + body.roomNo + " userId:" + body.userId);
ServerResponse513 serverResponse_513 = JsonConvert.DeserializeObject<ServerResponse513>(response);
if (serverResponse_513.code == 200)
{
//SuccessBet = true;
Debug.Log("-------切换投注成功-------");
checkOutAllTheEscapeRoomsAsync();//5.1.2
}
else
{
Debug.Log("-------切换投注失败-------");
}
}
//if (HouseBtnList.Count > index)
//{
// HouseBtnList[index].text.GetComponentInChildren<TextBox>().SetText(item.roomBeansCoin);
//}
//index++;
}
Debug.Log("更新房间蜗牛蛋");
}
public async void checkOutAllTheEscapeRoomsAsync()//5.1.2
{
foreach (HouseBtn house in HouseBtnList)
{
house.GetComponentInChildren<Button>().onClick.AddListener(() => {
roomNo = house.roomNo;
Debug.Log("所在房间Id" + roomNo);
//foreach (HouseBtn house in HouseBtnList)
//{
// house.GetComponentInChildren<Button>().onClick.AddListener(() => {
// roomNo = house.roomNo;
// Debug.Log("所在房间Id" + roomNo);
});
}
// });
//}
//GetInfo516();
@ -177,11 +238,18 @@ public class AllHouseContro : MonoBehaviour
{
//OtherBack();
player.ReturnStartPos();
detailsText.GetComponentInChildren<Text>().text = "";//游戏结束
battleRoyaleGameDetails();
LoadPanel.instance.ShowPanel();
CanMoveWoniu();//允许蜗牛移动
ClearText();
//ReHouseText();
BoosReturn();
player.ReturnStartPos();
allother.Reflash();//假蜗牛随机
allother.ClearAllWoniu();
IsHideLoadPanel = false;
GetInfo516();
@ -204,18 +272,20 @@ public class AllHouseContro : MonoBehaviour
text.GetComponentInChildren<Text>().text = (45 - serverResponse.data.carrySeconds - 1).ToString();
if (!HaveallotherMove)
{
//StartCoroutine(allother.IECreateWoniu());
allother.startIEmove();//生成其他蜗牛
//if (!HaveallotherMove)
//{
// //StartCoroutine(allother.IECreateWoniu());
allother.startIEmove();
HaveallotherMove = true;
//其他蜗牛进笼子
}
// HaveallotherMove = true;
// //其他蜗牛进笼子
//}
}
else if (serverResponse.data.carrySeconds > 45 && serverResponse.data.carrySeconds < 50)
{
StopWoniu();
ControAllDoorClose();//关门
OpenBoosDoor(BoosHouse);//boos开门
text.GetComponentInChildren<Text>().text = "";
@ -293,17 +363,17 @@ public class AllHouseContro : MonoBehaviour
case 0:
Debug.Log("没有结果");
BoosReturn();
//BoosReturn();
break;
case 1:
SucceePanel.instance.ShowPanel();
Debug.Log("胜利");
BoosReturn();
//BoosReturn();
break;
case 2:
FailPanel.instance.ShowPanel();
Debug.Log("失败");
BoosReturn();
//BoosReturn();
break;
}
settlementCoinUpdate.QueryPlayerInfo();
@ -347,6 +417,22 @@ public class AllHouseContro : MonoBehaviour
}
}
public void StopWoniu()//禁止玩家移动
{
foreach (HouseBtn item in HouseBtnList)
{
item.gameObject.GetComponentInChildren<Button>().enabled=false;
}
}
public void CanMoveWoniu()//允许玩家移动
{
foreach (HouseBtn item in HouseBtnList)
{
item.gameObject.GetComponentInChildren<Button>().enabled=true;
}
}
public void ClearBoosHouseId()
{
foreach (GameObject item in bossobj)//Boos回去
@ -424,5 +510,14 @@ public class AllHouseContro : MonoBehaviour
}
public void ClearText()//本地手动清零
{
foreach (HouseBtn houseBtn in HouseBtnList)
{
houseBtn.text.GetComponentInChildren<TextBox>().SetText(0);
}
}
}

View File

@ -5,11 +5,13 @@ using UnityEngine;
public class Allother : MonoBehaviour
{
public List<otherWoniu> otherWonius=new List<otherWoniu>();
//public List<otherWoniu> otherWonius=new List<otherWoniu>();
// public List<HouseBtn> House;//蜗牛进入的父物体
public GameObject OtherWoniuPre;//其他蜗牛预制体
public AllHouseContro allHouseContro;
public List<GameObject> JiaWoniu;//场下留下的假蜗牛
// Start is called before the first frame update
void Start()
{
@ -32,26 +34,40 @@ public class Allother : MonoBehaviour
// }
// }
public void Reflash()//假蜗牛随机
{
foreach (GameObject go in JiaWoniu)
{
go.GetComponent<RectTransform>().anchoredPosition = new Vector2(Random.Range(-350, 350), Random.Range(-80, 80));
}
}
//笼子里的蜗牛全部清空
public void ClearAllWoniu()
{
if (otherWonius != null)
foreach (HouseBtn house in allHouseContro.HouseBtnList)
{
for (int i = 0; i < otherWonius.Count; i++)
if (house.otherWonius != null)
{
Destroy(otherWonius[i].gameObject);
for (int i = 0; i < house.otherWonius.Count; i++)
{
Destroy(house.otherWonius[i].gameObject);
}
house.otherWonius.Clear();
}
}
otherWonius.Clear();
}
public void CreateWoniu()
{
foreach (HouseBtn house in allHouseContro.HouseBtnList)
{
for (int i = 0; i < house.roomUserNo; i++)
for (int i = 0; i < house.roomUserNo-house.otherWonius.Count; i++)
{
// 在指定范围内随机生成位置
float randomX = Random.Range(-250f, 250f); // X轴范围
float randomY = Random.Range(-80f, 80f); // Y轴范围
@ -62,7 +78,8 @@ public class Allother : MonoBehaviour
ot.GetComponent<RectTransform>().anchoredPosition = randomPosition;
// 添加到蜗牛列表并设置其行为
otherWonius.Add(ot.GetComponent<otherWoniu>());
house.otherWonius.Add(ot.GetComponent<otherWoniu>());
ot.GetComponent<otherWoniu>().OtherWoniuMove(house); // 移动到目标房间
Debug.Log("生成蜗牛,随机位置:" + randomPosition);
@ -79,12 +96,12 @@ public class Allother : MonoBehaviour
{
foreach (HouseBtn house in allHouseContro.HouseBtnList)
{
for (int i = 0; i < house.roomUserNo; i++)
for (int i = 0; i < house.roomUserNo-house.otherWonius.Count; i++)
{
GameObject ot = Instantiate(OtherWoniuPre, transform);
ot.GetComponent<RectTransform>().anchoredPosition = new Vector2(Random.Range(-250, 250), Random.Range(-80, 80));
otherWonius.Add(ot.GetComponent<otherWoniu>());
ot.GetComponent<RectTransform>().anchoredPosition = new Vector2(Random.Range(-250, 250), Random.Range(-80, 0));
house.otherWonius.Add(ot.GetComponent<otherWoniu>());
ot.GetComponent<otherWoniu>().OtherWoniuMove(house);//进房间
Debug.Log("生成蜗牛");

View File

@ -77,7 +77,7 @@ public class BettingBtn : MonoBehaviour
ServerResponse513 serverResponse_513 = JsonConvert.DeserializeObject<ServerResponse513>(response);
if (serverResponse_513.code==200)
{
bg.GetComponentInChildren<AllHouseContro>().checkOutAllTheEscapeRoomsAsync();//5.1.2
bg.GetComponentInChildren<AllHouseContro>().ReHouseText();//5.1.2
StartCoroutine(Tools.AnimateTextMashPro(PlayerInfo.instance.AllBetCoins, PlayerInfo.instance.AllBetCoins + BetValue, 0.5f, SelfWoniuText));//修改蜗牛头上文本
PlayerInfo.instance.AllBetCoins += BetValue;
PlayerInfo.instance.HaveBet = true;
@ -119,7 +119,7 @@ public class BettingBtn : MonoBehaviour
Debug.Log("-------切换投注成功-------");
Promptmgr.Instance.PromptBubble(serverResponse_513.message);
onComplete?.Invoke();
bg.GetComponentInChildren<AllHouseContro>().checkOutAllTheEscapeRoomsAsync();//5.1.2
bg.GetComponentInChildren<AllHouseContro>().ReHouseText();//5.1.2
}
else
{

View File

@ -19,14 +19,14 @@ public class HouseBtn : MonoBehaviour
//public selectLatest511.GameEscapeRoomResponseVo gameEscapeRoomResponseVo;
public bool DoorIsOpen;
public PlayerMovePos woniuMovePos;
public List<otherWoniu> otherWonius;
// Start is called before the first frame update
void Start()
{
if (GetComponent<Button>()!= null)
{
btn=GetComponent<Button>();
//btn.onClick.AddListener(OnClickBtn);
btn.onClick.AddListener(OnClickBtn);
}
@ -38,7 +38,7 @@ public class HouseBtn : MonoBehaviour
if (!bg.GetComponent<AllHouseContro>().is_jisha)
{
Debug.Log("¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ªÑ¡Ôñ·¿¼ä¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª");
if (PlayerInfo.instance.HaveBet)
{
if (bg.GetComponent<AllHouseContro>().roomNo!=roomNo)
@ -58,8 +58,15 @@ public class HouseBtn : MonoBehaviour
}
else
{
transform.GetComponent<PlayerMove>().StartMove();
woniuMovePos.HadChoise = true;
if (bg.GetComponent<AllHouseContro>().roomNo != roomNo)
{
bg.GetComponent<AllHouseContro>().roomNo = roomNo;
transform.GetComponent<PlayerMove>().StartMove();
woniuMovePos.HadChoise = true;
}
}
}

View File

@ -185,7 +185,7 @@ public class OtherMove : MonoBehaviour
//objectToMove.DOMoveY(objectToMove.position.y + 100, 0.5f).OnComplete(() => {
rectTransform.DOAnchorPosY(rectTransform.anchoredPosition.y + 80f, 0.5f)
rectTransform.DOAnchorPosY(rectTransform.anchoredPosition.y + 80f, 0.5f).SetEase(Ease.Linear)
.OnComplete(() => {
@ -197,11 +197,24 @@ public class OtherMove : MonoBehaviour
objectToMove.GetComponent<PlayerMovePos>().PlayAni.SetInteger("State", 0);
rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x + Random.Range(-100, 100), rectTransform.anchoredPosition.y);
// rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x + Random.Range(-100, 100), rectTransform.anchoredPosition.y);
float range = Random.Range(-100, 100);
// 判断物体是否需要旋转
if (range>0&& objectToMove.GetComponent<PlayerMovePos>().IsLeft)
{
objectToMove.GetComponent<PlayerMovePos>().IsLeft = false;
// 旋转物体使其面向左侧绕Y轴旋转180度
Rotate();
}
else if (range<0 && !objectToMove.GetComponent<PlayerMovePos>().IsLeft)
{
objectToMove.GetComponent<PlayerMovePos>().IsLeft = true;
Rotate();
}
rectTransform.DOAnchorPosX(rectTransform.anchoredPosition.x + range, 1f).SetEase(Ease.Linear);
});

View File

@ -369,35 +369,35 @@ public class PlayerMove : MonoBehaviour
BettingBtn.instance.GiveMoney(room_id);
yield return new WaitForSeconds(2f);
allHouseContro.BoosReturn();
//allHouseContro.BoosReturn();
//JudgeSuccOrFail();
}
public void JudgeSuccOrFail()
{
Debug.Log("=000000000000000000000000000000000000000000000000");
if (GetComponent<BossContro>().BoosStartPos == transform.GetComponent<PlayerMovePos>().StartPos && transform.GetComponent<PlayerMovePos>().HadChoise)
{
//BossContro.instance.BossAni.SetInteger("State", 2);//boos攻击
Debug.Log("失败");//失败
FailPanel.instance.ShowPanel();
}
else if (GetComponent<BossContro>().BoosStartPos != transform.GetComponent<PlayerMovePos>().StartPos && transform.GetComponent<PlayerMovePos>().HadChoise)
{
Debug.Log("胜利");//胜利
SucceePanel.instance.ShowPanel();
}
else
{
Debug.Log("没有失败和胜利");//胜利
foreach (GameObject item in allHouseContro.bossobj)
{
item.GetComponent<BossContro>().ReturnParent();
}
}
//HegemonTime.instance.StartCoroutine(HegemonTime.instance.StartGame());//重新计算时间
}
//public void JudgeSuccOrFail()
//{
// Debug.Log("=000000000000000000000000000000000000000000000000");
// if (GetComponent<BossContro>().BoosStartPos == transform.GetComponent<PlayerMovePos>().StartPos && transform.GetComponent<PlayerMovePos>().HadChoise)
// {
// //BossContro.instance.BossAni.SetInteger("State", 2);//boos攻击
// Debug.Log("失败");//失败
// FailPanel.instance.ShowPanel();
// }
// else if (GetComponent<BossContro>().BoosStartPos != transform.GetComponent<PlayerMovePos>().StartPos && transform.GetComponent<PlayerMovePos>().HadChoise)
// {
// Debug.Log("胜利");//胜利
// SucceePanel.instance.ShowPanel();
// }
// else
// {
// Debug.Log("没有失败和胜利");//胜利
// foreach (GameObject item in allHouseContro.bossobj)
// {
// item.GetComponent<BossContro>().ReturnParent();
// }
// }
// //HegemonTime.instance.StartCoroutine(HegemonTime.instance.StartGame());//重新计算时间
//}
public void Rotate()
{