public static async Task WaitForSelectLocation(Card card)
        {
            AgainstInfo.IsWaitForSelectLocation = true;
            RowCommand.SetRegionSelectable((RegionTypes)card.region, card.territory);
            AgainstInfo.SelectLocation = -1;
            await Task.Run(async() =>
            {
                while (AgainstInfo.SelectLocation < 0)
                {
                    StateInfo.TaskManager.Token.ThrowIfCancellationRequested();
                    if (AgainstInfo.isAIControl)
                    {
                        await Task.Delay(1000);
                        List <SingleRowInfo> rows = AgainstInfo.cardSet.singleRowInfos.Where(row => row.CanBeSelected).ToList();
                        int rowRank = AiCommand.GetRandom(0, rows.Count());
                        AgainstInfo.SelectRegion   = rows[rowRank]; //设置部署区域
                        AgainstInfo.SelectLocation = 0;             //设置部署次序
                    }
                    await Task.Delay(1000);
                }
            });

            Debug.Log($"选择坐标{AgainstInfo.SelectLocation}");
            Network.NetCommand.AsyncInfo(NetAcyncType.SelectLocation);
            RowCommand.SetRegionSelectable(RegionTypes.None);
            AgainstInfo.IsWaitForSelectLocation = false;
        }
        public static async Task WaitForSelectRegion(RegionTypes regionTypes, Territory territory)
        {
            AgainstInfo.IsWaitForSelectRegion = true;
            AgainstInfo.SelectRegion          = null;
            RowCommand.SetRegionSelectable(regionTypes, territory);
            await Task.Run(async() =>
            {
                while (Info.AgainstInfo.SelectRegion == null)
                {
                    StateInfo.TaskManager.Token.ThrowIfCancellationRequested();
                    if (AgainstInfo.isAIControl)
                    {
                        await Task.Delay(1000);
                        List <SingleRowInfo> rows = AgainstInfo.cardSet.singleRowInfos.Where(row => row.CanBeSelected).ToList();
                        int rowRank = AiCommand.GetRandom(0, rows.Count());
                        AgainstInfo.SelectRegion = rows[rowRank];//设置部署区域
                    }
                    await Task.Delay(1000);
                }
            });

            Network.NetCommand.AsyncInfo(NetAcyncType.SelectRegion);
            RowCommand.SetRegionSelectable(RegionTypes.None);
            AgainstInfo.IsWaitForSelectRegion = false;
        }
 public static async Task TurnStart()
 {
     await Task.Run(async() =>
     {
         GameUI.UiCommand.SetNoticeBoardTitle(AgainstInfo.isMyTurn ? "我方回合开始".TransUiText() : "对方回合开始".TransUiText());
         await GameUI.UiCommand.NoticeBoardShow();
         //await Task.Delay(000);
         AgainstInfo.IsCardEffectCompleted = false;
         RowCommand.SetPlayCardMoveFree(AgainstInfo.isMyTurn);
         await Task.Delay(000);
     });
 }
 public static async Task TurnEnd()
 {
     await Task.Run(async() =>
     {
         await GameSystem.ProcessSystem.WhenTurnEnd();
         GameUI.UiCommand.SetNoticeBoardTitle(AgainstInfo.isMyTurn ? "我方回合结束".TransUiText() : "对方回合结束".TransUiText());
         await GameUI.UiCommand.NoticeBoardShow();
         //await Task.Delay(000);
         RowCommand.SetPlayCardMoveFree(false);
         await Task.Delay(1000);
         AgainstInfo.isMyTurn = !AgainstInfo.isMyTurn;
     });
 }
Ejemplo n.º 5
0
        public static async Task WaitForSelectLocation()
        {
            GlobalBattleInfo.IsWaitForSelectLocation = true;
            RowCommand.SetRegionSelectable(true);
            await Task.Run(() =>
            {
                while (Info.GlobalBattleInfo.SelectLocation < 0)
                {
                }
            });

            RowCommand.SetRegionSelectable(false);
            GlobalBattleInfo.IsWaitForSelectLocation = false;
        }
 public static async Task PlayCard(Card targetCard, bool IsAnsy = true)
 {
     AgainstInfo.PlayerPlayCard = targetCard;
     EffectCommand.AudioEffectPlay(0);
     RowCommand.SetPlayCardMoveFree(false);
     targetCard.isPrepareToPlay = false;
     if (IsAnsy)
     {
         Network.NetCommand.AsyncInfo(NetAcyncType.PlayCard);
     }
     targetCard.SetCardSeeAble(true);
     RemoveCard(targetCard);
     AgainstInfo.cardSet[Orientation.My][RegionTypes.Uesd].Add(targetCard);
     AgainstInfo.PlayerPlayCard = null;
 }
        public static async Task BattleStart()
        {
            AgainstInfo.isMyTurn       = AgainstInfo.isPlayer1;
            AgainstInfo.cardSet        = new CardSet();
            Info.StateInfo.TaskManager = new System.Threading.CancellationTokenSource();
            MainThread.Run(() =>
            {
                foreach (var item in GameObject.FindGameObjectsWithTag("SingleInfo"))
                {
                    SingleRowInfo singleRowInfo = item.GetComponent <SingleRowInfo>();
                    AgainstInfo.cardSet.singleRowInfos.Add(singleRowInfo);
                }
                AgainstInfo.cardSet.CardList = null;
            });
            await Task.Delay(500);

            if (AgainstInfo.isPVE)
            {
                AllPlayerInfo.UserInfo = new NetInfoModel.PlayerInfo(
                    "gezi", "yaya",
                    new List <CardDeck>
                {
                    new CardDeck("gezi", 10001, new List <int>
                    {
                        //10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,
                        10015, 10016, 10012, 10013, 10014, 10015, 10016, 10002, 10008, 10004, 10005, 10007, 10006, 10008, 10004, 10012, 10010, 10011, 10012, 10014, 10007, 10006, 10016, 10008, 10014
                        //10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009, 10010, 10011, 10012, 10013, 10014, 10015, 10016, 10012, 10013, 10014, 10015, 10016, 10012, 10013, 10014, 10015, 10016
                        //1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004
                    })
                });
                AllPlayerInfo.OpponentInfo = new NetInfoModel.PlayerInfo(
                    "gezi", "yaya",
                    new List <CardDeck>
                {
                    new CardDeck("gezi", 10001, new List <int>
                    {
                        //10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,10002,
                        10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009, 10010, 10011, 10012, 10013, 10014, 10015, 10016, 10012, 10013, 10014, 10015, 10016, 10012, 10013, 10014, 10015, 10016
                        //10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009, 10010, 10011, 10012, 10013, 10014, 10015, 10016, 10012, 10013, 10014, 10015, 10016, 10012, 10013, 10014, 10015, 10016
                    })
                });
            }
            RowCommand.SetRegionSelectable(RegionTypes.None);
            //Debug.LogError("初始双方信息");
            await Task.Run(async() =>
            {
                try
                {
                    //await Task.Delay(500);
                    Debug.Log("对战开始".TransUiText());
                    GameUI.UiCommand.SetNoticeBoardTitle("对战开始".TransUiText());
                    await GameUI.UiCommand.NoticeBoardShow();
                    //初始化我方领袖卡
                    Card MyLeaderCard = await CardCommand.CreatCard(AllPlayerInfo.UserInfo.UseDeck.LeaderId);
                    AgainstInfo.cardSet[Orientation.Down][RegionTypes.Leader].Add(MyLeaderCard);
                    MyLeaderCard.SetCardSeeAble(true);
                    //初始化敌方领袖卡
                    Card OpLeaderCard = await CardCommand.CreatCard(AllPlayerInfo.OpponentInfo.UseDeck.LeaderId);
                    AgainstInfo.cardSet[Orientation.Up][RegionTypes.Leader].Add(OpLeaderCard);
                    OpLeaderCard.SetCardSeeAble(true);
                    //初始双方化牌组
                    CardDeck Deck = AllPlayerInfo.UserInfo.UseDeck;
                    //Debug.LogError("初始双方化牌组");

                    for (int i = 0; i < Deck.CardIds.Count; i++)
                    {
                        Card NewCard    = await CardCommand.CreatCard(Deck.CardIds[i]);
                        CardSet cardSet = AgainstInfo.cardSet[Orientation.Down][RegionTypes.Deck];
                        cardSet.Add(NewCard);
                    }
                    Deck = AllPlayerInfo.OpponentInfo.UseDeck;

                    for (int i = 0; i < Deck.CardIds.Count; i++)
                    {
                        Card NewCard = await CardCommand.CreatCard(Deck.CardIds[i]);
                        AgainstInfo.cardSet[Orientation.Up][RegionTypes.Deck].Add(NewCard);
                    }
                    await Task.Delay(000);
                }
                catch (Exception e)
                {
                    Debug.LogError(e);
                }
            });
        }