using System.Collections; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using UnityEditor.PackageManager.UI; using UnityEngine; using UnityEngine.UI; public class AllManeger : MonoBehaviour { public static AllManeger instance; public queryClosestKnight521 queryClosestKnight521=new queryClosestKnight521(); public ClosestKnight closestKnight521 = new ClosestKnight(); public queryKnightRoomList522 queryKnightRoomList522 = new queryKnightRoomList522(); public KnightRoomBetList knightRoomBetList522 = new KnightRoomBetList(); public SnailKnightBet523 snailKnightBet523=new SnailKnightBet523(); public int id;//游戏id public string gameNo;//游戏编号 public int GameSession;//游戏场次 public List horseInfos = new List(); public List snailRiders = new List(); public List KillNos=new List(); public List WinNos = new List(); public Text timeText; public bool isStart; // Start is called before the first frame update async void Start() { instance = this; Fuck521(); InvokeRepeating("Fuck522", 2, 2); } // Update is called once per frame void Update() { } void OnDestroy() { CancelInvoke("Fuck522"); } public async void Fuck521() { closestKnight521 = await queryClosestKnight521.queryClosestKnight(); id = closestKnight521.Data.GameKnightModel.Id; gameNo = closestKnight521.Data.GameKnightModel.GameNo; GameSession = closestKnight521.Data.GameKnightModel.GameSession; GetHorseInfo521(closestKnight521.Data.GameKnightRoomResponseVoList); GetKillInfo521(closestKnight521.Data.GameKnightModel); LoadPanel.instance.HidePanel(); } public async void Fuck522() { knightRoomBetList522 = await queryKnightRoomList522.queryKnightRoomLis(id); foreach (GameKnightRoomResponseVo item in knightRoomBetList522.Data.GameKnightRoomResponseVoList) { foreach (HorseInfo horse in horseInfos) { if (horse.HorseNo == item.HorseNo) { StartCoroutine(Tools.AnimateText(float.Parse(horse.numText.text), item.HorseBeansCoin, 0.5f, horse.numText)); //horse.numText.text = item.HorseBeansCoin.ToString(); } } } if (knightRoomBetList522.Data.CarrySeconds==-1) { LoadPanel.instance.ShowPanel(); Allreturn(); ClearAllHouseBet();//清空本地投注 Fuck521(); isStart = false; } else if(knightRoomBetList522.Data.CarrySeconds<45) { timeText.text = (45 - knightRoomBetList522.Data.CarrySeconds).ToString(); await Task.Delay(1000); timeText.text = (45 - knightRoomBetList522.Data.CarrySeconds - 1).ToString(); } else if (knightRoomBetList522.Data.CarrySeconds>45) { if (!isStart) { AllMove(); isStart = true; } } } public async void Fuck523() { await snailKnightBet523.SnailKnightBet(id, BetBtn.instance.BetValue, BetBtn.instance.BetHorseId); } public void GetHorseInfo521(List GameKnightRoomResponseVoList)//获得马匹的信息 { foreach (GameKnightRoomResponseVo item in GameKnightRoomResponseVoList) { foreach (HorseInfo horse in horseInfos) { if (horse.HorseNo==item.HorseNo) { horse.KnightId = item.KnightId; horse.HorseUserNo = item.HorseUserNo; horse.HorseBeansCoin = item.HorseBeansCoin; horse.numText.text = item.HorseBeansCoin.ToString(); } } } } public void GetKillInfo521(GameKnightModel GameKnightModel)//获取击杀马匹与留存马匹 { if (GameKnightModel.HorseNoKill!="") { string[] parts = GameKnightModel.HorseNoKill.Split(","); // 根据 ',' 分割字符串d KillNos = parts.Select(int.Parse).ToList(); foreach (int killno in KillNos) { foreach (HorseInfo horse in horseInfos) { if (horse.HorseNo == killno) { horse.snail.is_die = true; } } } } if (GameKnightModel.HorseNoRemain!="") { string[] parts_2 = GameKnightModel.HorseNoRemain.Split(","); WinNos = parts_2.Select(int.Parse).ToList(); foreach (int winno in WinNos) { foreach (HorseInfo horse in horseInfos) { if (horse.HorseNo == winno) { horse.snail.is_victory = true; } } } } } public void AllMove()//所有蜗牛开跑 { foreach (snailRider snail in snailRiders) { snail.startMove(); } } public void Allreturn()//所有蜗牛回去 { foreach (snailRider snail in snailRiders) { snail.startMove(); } } public void ClearAllHouseBet()//清空投注 { foreach (HorseInfo horse in horseInfos) { horse.BetCoins=0; horse.betText.text = horse.BetCoins.ToString(); } } }