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;
        }
Exemple #2
0
 public static async Task WaitForPlayerOperation()
 {
     await Task.Run(async() =>
     {
         //print("出牌");
         if (Info.GlobalBattleInfo.IsPVE && !Info.GlobalBattleInfo.IsMyTurn)
         {
             await AiCommand.TempOperationAsync();
         }
         //当出牌,弃牌,pass时结束
         while (true)
         {
             if (Info.GlobalBattleInfo.IsCardEffectCompleted)
             {
                 break;
             }
             if (Info.GlobalBattleInfo.IsCurrectPass)
             {
                 Info.GlobalBattleInfo.IsCardEffectCompleted = false;
                 break;
             }
             if (Info.GlobalBattleInfo.IsCardEffectCompleted)
             {
                 Info.GlobalBattleInfo.IsCardEffectCompleted = false;
                 break;
             }
         }
     });
 }
        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 WaitForSelectProperty()
        {
            //放大硬币
            CoinControl.ScaleUp();
            await Task.Delay(1000);

            CoinControl.Unfold();
            AgainstInfo.IsWaitForSelectProperty = true;
            AgainstInfo.SelectProperty          = Region.None;
            //暂时设为1秒,之后还原成10秒
            Timer.SetIsTimerStart(1);
            //AgainstInfo.SelectRegion = null;
            await Task.Run(async() =>
            {
                // Debug.Log("等待选择属性");
                while (AgainstInfo.SelectProperty == Region.None)
                {
                    StateInfo.TaskManager.Token.ThrowIfCancellationRequested();
                    if (AgainstInfo.isAIControl)
                    {
                        //Debug.Log("自动选择属性");
                        int rowRank = AiCommand.GetRandom(0, 4);
                        CoinControl.ChangeProperty((Region)rowRank);
                    }
                    await Task.Delay(1000);
                }
            });

            Command.Network.NetCommand.AsyncInfo(NetAcyncType.SelectProperty);
            Timer.SetIsTimerClose();
            AgainstInfo.IsWaitForSelectProperty = false;
            await Task.Delay(1000);

            CoinControl.ScaleDown();
        }
 public static async Task WashCard(Card TargetCard, bool IsPlayerWash = true, int InsertRank = 0)
 {
     Debug.Log("洗回卡牌");
     if (IsPlayerWash)
     {
         AgainstInfo.TargetCard = TargetCard;
         int MaxCardRank = AgainstInfo.cardSet[Orientation.Down][RegionTypes.Deck].CardList.Count;
         AgainstInfo.RandomRank = AiCommand.GetRandom(0, MaxCardRank);
         Network.NetCommand.AsyncInfo(NetAcyncType.ExchangeCard);
         AgainstInfo.cardSet[Orientation.Down][RegionTypes.Hand].Remove(TargetCard);
         AgainstInfo.cardSet[Orientation.Down][RegionTypes.Deck].Add(TargetCard, AgainstInfo.RandomRank);
         TargetCard.SetCardSeeAble(false);
     }
     else
     {
         AgainstInfo.cardSet[Orientation.Up][RegionTypes.Hand].Remove(TargetCard);
         AgainstInfo.cardSet[Orientation.Up][RegionTypes.Deck].Add(TargetCard, InsertRank);
     }
     await Task.Delay(500);
 }
        public static async Task WaitForSelecUnit(Card OriginCard, List <Card> Cards, int num, bool isAuto)
        {
            //可选列表中移除自身
            Cards.Remove(OriginCard);
            AgainstInfo.ArrowStartCard       = OriginCard;
            AgainstInfo.IsWaitForSelectUnits = true;
            AgainstInfo.AllCardList.ForEach(card => card.isGray = true);
            Cards.ForEach(card => card.isGray = false);
            AgainstInfo.SelectUnits.Clear();
            await Task.Run(async() =>
            {
                //await Task.Delay(500);
                if (Info.AgainstInfo.isMyTurn && !isAuto)
                {
                    GameUI.UiCommand.CreatFreeArrow();
                }
                int selectableNum = Math.Min(Cards.Count, num);
                while (AgainstInfo.SelectUnits.Count < selectableNum)
                {
                    StateInfo.TaskManager.Token.ThrowIfCancellationRequested();
                    //当pve模式或者pvp中的我方回合时,用自身随机决定,否则等待网络同步
                    if (AgainstInfo.isAIControl || (isAuto && AgainstInfo.isMyTurn))
                    {
                        Debug.Log("自动选择场上单位");
                        Cards = Cards.OrderBy(x => AiCommand.GetRandom(0, 514)).ToList();
                        AgainstInfo.SelectUnits = Cards.Take(selectableNum).ToList();
                    }
                    await Task.Delay(100);
                }
                Debug.Log("选择单位完毕" + Math.Min(Cards.Count, num));
                Network.NetCommand.AsyncInfo(NetAcyncType.SelectUnites);
                GameUI.UiCommand.DestoryAllArrow();
                await Task.Delay(250);
                Debug.Log("同步选择单位完毕");
            });

            AgainstInfo.AllCardList.ForEach(card => card.isGray = false);
            AgainstInfo.IsWaitForSelectUnits = false;
            Debug.Log("结束选择单位");
        }
        public static async Task WaitForPlayerOperation()
        {
            bool isFirstOperation = true;

            //Timer.SetIsTimerStart(60);
            Timer.SetIsTimerStart(6000);
            await Task.Run(async() =>
            {
                //Debug.Log("出牌");
                //当出牌,弃牌,pass时结束
                while (true)
                {
                    StateInfo.TaskManager.Token.ThrowIfCancellationRequested();
                    if (Timer.isTimeout)
                    {
                        Debug.Log("超时");
                    }
                    if (AgainstInfo.isAIControl && isFirstOperation)
                    {
                        isFirstOperation = false;
                        Debug.Log("自动出牌");
                        await AiCommand.TempOperationPlayCard();
                    }
                    if (AgainstInfo.IsCardEffectCompleted)
                    {
                        AgainstInfo.IsCardEffectCompleted = false;
                        break;
                    }
                    if (AgainstInfo.isCurrectPass)
                    {
                        AgainstInfo.IsCardEffectCompleted = false;
                        break;
                    }
                    await Task.Delay(1000);
                }
            });

            Timer.SetIsTimerClose();
        }
Exemple #8
0
        //洗回牌库
        public static async Task WashCard(bool IsPlayerWash = true)
        {
            print("洗牌");
            if (IsPlayerWash)
            {
                int MaxCardRank = Info.RowsInfo.GetMyCardList(RegionTypes.Deck).Count;
                int CardRank    = AiCommand.GetRandom(0, MaxCardRank);
                GlobalBattleInfo.SelectLocation      = CardRank;
                GlobalBattleInfo.SelectRegion        = RowsInfo.GetRegionCardList(RegionName_Other.My_Deck);
                GlobalBattleInfo.TargetCard          = GlobalBattleInfo.SingleSelectCardOnBoard;
                GlobalBattleInfo.TargetCard.IsCanSee = false;
                await MoveCard();
            }
            else
            {
                //int MaxCardRank = Info.RowsInfo.GetDownCardList(RegionTypes.Hand).Count;
                //int CardRank = AiCommand.GetRandom(0, MaxCardRank);
                //GlobalBattleInfo.SelectLocation = CardRank;
                //GlobalBattleInfo.SelectRegion = RowsInfo.GetRegionCardList(RegionName_Other.My_Hand);

                //await MoveCard();
            }
            await Task.Delay(500);
        }
        public static async Task WaitForSelectBoardCard <T>(List <T> CardIds, CardBoardMode Mode = CardBoardMode.Select, int num = 1)
        {
            AgainstInfo.selectBoardCardRanks    = new List <int>();
            AgainstInfo.IsFinishSelectBoardCard = false;
            AgainstInfo.cardBoardMode           = Mode;
            GameUI.UiCommand.SetCardBoardShow();
            if (typeof(T) == typeof(Card))
            {
                GameUI.CardBoardCommand.LoadBoardCardList(CardIds.Cast <Card>().ToList());
            }
            else
            {
                GameUI.CardBoardCommand.LoadBoardCardList(CardIds.Cast <int>().ToList());
            }
            //Debug.Log("进入选择模式");
            await Task.Run(async() =>
            {
                switch (Mode)
                {
                case CardBoardMode.Select:
                    while (AgainstInfo.selectBoardCardRanks.Count < Mathf.Min(CardIds.Count, num) && !AgainstInfo.IsFinishSelectBoardCard)
                    {
                    }
                    GameUI.UiCommand.SetCardBoardHide();
                    break;

                case CardBoardMode.ExchangeCard:
                    {
                        AiCommand.RoundStartExchange(false);
                        while (Info.AgainstInfo.ExChangeableCardNum != 0 && !Info.AgainstInfo.IsSelectCardOver)
                        {
                            StateInfo.TaskManager.Token.ThrowIfCancellationRequested();
                            if (Info.AgainstInfo.selectBoardCardRanks.Count > 0)
                            {
                                //List<Card> CardLists = CardIds.Cast<Card>().ToList();
                                List <Card> CardLists = AgainstInfo.cardSet[Orientation.Down][RegionTypes.Hand].CardList;
                                await CardCommand.ExchangeCard(CardLists[AgainstInfo.selectBoardCardRanks[0]], isRoundStartExchange: true);
                                Info.AgainstInfo.ExChangeableCardNum--;
                                Info.AgainstInfo.selectBoardCardRanks.Clear();
                                GameUI.UiCommand.SetCardBoardTitle("剩余抽卡次数为" + Info.AgainstInfo.ExChangeableCardNum);
                            }
                        }
                        if (AgainstInfo.isPlayer1)
                        {
                            AgainstInfo.isPlayer1RoundStartExchangeOver = true;
                        }
                        else
                        {
                            AgainstInfo.isPlayer2RoundStartExchangeOver = true;
                        }
                        GameUI.UiCommand.SetCardBoardHide();
                        Network.NetCommand.AsyncInfo(NetAcyncType.RoundStartExchangeOver);
                        while (!(AgainstInfo.isPlayer1RoundStartExchangeOver && AgainstInfo.isPlayer2RoundStartExchangeOver))
                        {
                            StateInfo.TaskManager.Token.ThrowIfCancellationRequested();
                            Debug.Log("等待双方选择完毕");
                            Debug.Log("等待双方选择完毕" + AgainstInfo.isPlayer1RoundStartExchangeOver + ":" + AgainstInfo.isPlayer2RoundStartExchangeOver);
                            await Task.Delay(1000);
                        }
                        AgainstInfo.isPlayer1RoundStartExchangeOver = false;
                        AgainstInfo.isPlayer2RoundStartExchangeOver = false;
                        AgainstInfo.IsSelectCardOver = false;
                        break;
                    }

                case CardBoardMode.ShowOnly:
                    while (AgainstInfo.selectBoardCardRanks.Count < Mathf.Min(CardIds.Count, num) && !AgainstInfo.IsFinishSelectBoardCard)
                    {
                    }
                    GameUI.UiCommand.SetCardBoardHide();
                    break;

                default:
                    break;
                }
            });

            AgainstInfo.cardBoardMode = CardBoardMode.None;
        }