335 lines
9.7 KiB
C#
335 lines
9.7 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Threading.Tasks;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
using TMPro;
|
||
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 queryKnightKill524 queryKnightKill524 = new queryKnightKill524();
|
||
public KnightKill knightKill524=new KnightKill();
|
||
|
||
public queryPlayerInfo queryPlayerInfo = new queryPlayerInfo();
|
||
public RealPlayerInfo realPlayerInfo = new RealPlayerInfo();
|
||
|
||
public queryKnightBetResult525 queryKnightBetResult525=new queryKnightBetResult525();
|
||
public KnightBetResult knightBetResult=new KnightBetResult();
|
||
|
||
public int id;//游戏id
|
||
public string gameNo;//游戏编号
|
||
public int GameSession;//游戏场次
|
||
|
||
public List<HorseInfo> horseInfos = new List<HorseInfo>();
|
||
public List<snailRider> snailRiders = new List<snailRider>();
|
||
|
||
public List<int> KillNos=new List<int>();
|
||
public List<int> WinNos = new List<int>();
|
||
|
||
//public List<int> allNos=new List<int>();//留下的马
|
||
public Text timeText;
|
||
|
||
|
||
public TextMeshProUGUI coinText;//蜗牛蛋
|
||
|
||
public bool is_jisha;//是否击杀
|
||
public bool is_jieshuan;//是否结算
|
||
public bool is_Reflash;//是否获取最新游戏
|
||
|
||
public bool is_NOneedReflash;//是否需要刷新
|
||
|
||
public int snailMoveNum;//蜗牛出动数量
|
||
// Start is called before the first frame update
|
||
async void Start()
|
||
{
|
||
instance = this;
|
||
Fuck521();
|
||
InvokeRepeating("Fuck522", 2, 2);
|
||
GetSelfInfo();
|
||
}
|
||
|
||
// 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);
|
||
|
||
|
||
is_jieshuan = false;
|
||
is_jisha = false;
|
||
is_Reflash = true;
|
||
}
|
||
|
||
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<0|| knightRoomBetList522.Data.CarrySeconds>59)
|
||
{
|
||
NewLoadPanel.instance.ShowPanel();
|
||
is_Reflash = false;
|
||
Allreturn();
|
||
ClearAllHouseBet();//清空本地投注
|
||
|
||
Fuck521();//获取最新游戏
|
||
|
||
|
||
|
||
|
||
|
||
//LoadPanel.instance.HidePanel();
|
||
}
|
||
else if(knightRoomBetList522.Data.CarrySeconds<45)//倒计时
|
||
{
|
||
|
||
if (is_Reflash)
|
||
{
|
||
NewLoadPanel.instance.HidePanel();//刷新完隐藏加载界面
|
||
is_Reflash = false;
|
||
Allreturn();
|
||
}
|
||
|
||
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&& knightRoomBetList522.Data.CarrySeconds<50)//击杀开跑
|
||
{
|
||
if (!is_jisha)
|
||
{
|
||
Fuck524();
|
||
|
||
AllMove();
|
||
is_jisha = true;
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|
||
else if (knightRoomBetList522.Data.CarrySeconds >=50)//结算
|
||
{
|
||
if (!is_jieshuan)
|
||
{
|
||
Fuck525();
|
||
is_jieshuan = true;
|
||
}
|
||
|
||
|
||
|
||
}
|
||
}
|
||
|
||
public async void Fuck523()
|
||
{
|
||
await snailKnightBet523.SnailKnightBet(id, BetBtn.instance.BetValue, BetBtn.instance.BetHorseId);
|
||
|
||
}
|
||
|
||
public async void Fuck524()
|
||
{
|
||
knightKill524 = await queryKnightKill524.queryKnightKill(id);
|
||
//if (knightKill524.data.horseNoKill!="")
|
||
//{
|
||
// string[] parts = knightKill524.data.horseNoKill.Split(","); // 根据 ',' 分割字符串d
|
||
// KillNos = parts.Select(int.Parse).ToList();
|
||
|
||
// foreach (int killno in KillNos)
|
||
// {
|
||
// Debug.Log("击杀蜗牛"+killno);
|
||
// foreach (HorseInfo horse in horseInfos)
|
||
// {
|
||
// if (horse.HorseNo == killno)
|
||
// {
|
||
// Debug.Log("wwwww" + horse.HorseNo);
|
||
// horse.snail.is_die = true;
|
||
// }
|
||
// }
|
||
// }
|
||
//}
|
||
|
||
if (knightKill524.data.horseNoRemain!= "")
|
||
{
|
||
string[] parts_2 = knightKill524.data.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 async void Fuck525()
|
||
{
|
||
knightBetResult = await queryKnightBetResult525.queryKnightBetResult(id);
|
||
GetSelfInfo();
|
||
}
|
||
|
||
public async void GetSelfInfo()
|
||
{
|
||
realPlayerInfo = await queryPlayerInfo.QueryPlayerInfoPro();//玩家信息
|
||
coinText.text=realPlayerInfo.data.beansCoin.ToString("F1");
|
||
}
|
||
|
||
public void GetHorseInfo521(List<GameKnightRoomResponseVo> 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.HorseNoAll!="")
|
||
{
|
||
string[] parts = GameKnightModel.HorseNoAll.Split(",");
|
||
List<int> allNos= parts.Select(int.Parse).ToList();
|
||
HashSet<int> allNosSet = new HashSet<int>(allNos);
|
||
|
||
// 遍历 horseInfos,检查每个 HorseNo 是否存在于 allNos 中
|
||
foreach (HorseInfo horse in horseInfos)
|
||
{
|
||
if (!allNosSet.Contains(horse.HorseNo))
|
||
{
|
||
horse.snail.is_die = true;
|
||
horse.snail.killsnail(); // 如果不存在于 allNos 中,设置 is_die 为 true
|
||
}
|
||
else
|
||
{
|
||
horse.snail.is_die = false;
|
||
horse.snail.killsnail();// 如果存在于 allNos 中,设置 is_die 为 false
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
//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.returnStart();
|
||
}
|
||
}
|
||
public void ClearAllHouseBet()//清空投注//顺便刷新所有蜗牛状态
|
||
{
|
||
foreach (HorseInfo horse in horseInfos)
|
||
{
|
||
horse.BetCoins=0;
|
||
horse.betText.text = horse.BetCoins.ToString();
|
||
horse.snail.is_victory = false;
|
||
|
||
}
|
||
}
|
||
|
||
}
|
||
|