_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/RacingPanel/AllManeger.cs

388 lines
11 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
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 TextMeshProUGUI TextMPtime;
public Text wordText;//文字文本
public TextMeshProUGUI coinText;//蜗牛蛋
public bool is_jisha;//是否击杀
public bool is_jieshuan;//是否结算
public bool is_Reflash;//是否获取最新游戏
public bool is_NOneedReflash;//是否需要刷新
public int snailMoveNum;//蜗牛出动数量
public RacingPanel racingPanel;
public int WinNum;//到达终点蜗牛数量
public int gameSession;//游戏场次
// 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();//清空本地投注
ToolsManager.instance.ShowTools();//刷新一下道具
ToolsManager.instance.RamgeTools();
Fuck521();//获取最新游戏
//LoadPanel.instance.HidePanel();
}
else if(knightRoomBetList522.Data.CarrySeconds<45)//倒计时
{
MoveBg.instance.ReturnPos();
if (is_Reflash)
{
NewLoadPanel.instance.HidePanel();//刷新完隐藏加载界面
is_Reflash = false;
Allreturn();
}
wordText.text = "秒后比赛开始";
TextMPtime.text = (45 - knightRoomBetList522.Data.CarrySeconds).ToString();
await Task.Delay(1000);
TextMPtime.text = (45 - knightRoomBetList522.Data.CarrySeconds - 1).ToString();
}
else if (knightRoomBetList522.Data.CarrySeconds>=45&& knightRoomBetList522.Data.CarrySeconds<50)//击杀开跑
{
if (!is_jisha)
{
TextMPtime.text = "GO!";
wordText.text = "";
Fuck524();
is_jisha = true;
}
}
else if (knightRoomBetList522.Data.CarrySeconds >=56)//结算
{
if (!is_jieshuan)
{
TextMPtime.text = "";
wordText.text = "";
if (WinNos.Count>0)
{
RacingSuccessPanel.instance.ShowImage();
RacingSuccessPanel.instance.ShowPanel();
}
//RacingSuccessPanel.instance.textSnailEggs.text = knightBetResult.data[0].win.ToString("F1");
is_jieshuan = true;
Fuck525();
}
}
}
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;
}
}
}
}
AllMove();
}
public async void Fuck525()
{
knightBetResult = await queryKnightBetResult525.queryKnightBetResult(id);
GetSelfInfo();
//if (knightBetResult.data[0].outcome==1)//胜利
//{
// Debug.Log("胜利");
//
//}
//else if (knightBetResult.data[0].outcome == 2)//失败
//{
// Debug.Log("失败");
// FailPanel.instance.ShowPanel();
//}
}
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)//获取击杀马匹与留存马匹
{
gameSession = GameKnightModel.GameSession;//游戏场次
if (gameSession==1)
{
WinNum = 4;//8进4
}
else if (gameSession == 2)
{
WinNum = 2;//4进2
}
else if (gameSession == 3)
{
WinNum = 1;//2进1
}
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
horse.gameObject.SetActive(false);//禁用按钮
}
else
{
horse.snail.is_die = false;
horse.snail.killsnail();// 如果存在于 allNos 中,设置 is_die 为 false
horse.gameObject.SetActive(true);//启用按钮
}
}
}
//if (GameKnightModel.HorseNoKill != "")//禁用按钮
//{
// string[] parts = GameKnightModel.HorseNoKill.Split(","); // 根据 ',' 分割字符串d
// KillNos = parts.Select(int.Parse).ToList();
// foreach (int killno in KillNos)
// {
// SetBtnHide(killno);
// }
//}
//if (GameKnightModel.HorseNoRemain != "")//解放按钮
//{
// string[] parts_2 = GameKnightModel.HorseNoRemain.Split(",");
// WinNos = parts_2.Select(int.Parse).ToList();
// foreach (int winno in WinNos)
// {
// SetBtnShow(winno);
// }
//}
}
public void AllMove()//所有蜗牛开跑
{
foreach (snailRider snail in snailRiders)
{
snail.startMove();
}
MoveBg.instance.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;
}
}
public void StopAllSanil()//停止所有蜗牛
{
DOTween.KillAll(); // 停止所有的 DOTween 动画
foreach (snailRider snail in snailRiders)
{
snail.animator.SetInteger("State", 0);
}
}
}