Ejemplo n.º 1
0
 private List <int> AIMove(int boardId)
 {
     GamePlay.TargetSettings settings = GamePlay.TargetSettings.WithEnemyPawn;
     if (pawn.gamePlayComp.SetTargetsOnBoard(settings, pawn.gameObject, null))
     {
         return(pawn.gamePlayComp.TargetsList);
     }
     return(null);
 }
Ejemplo n.º 2
0
 private void ChoosePawnToBuff(int PawnBoardFieldId)
 {
     GamePlay.TargetSettings settings =
         (GamePlay.TargetSettings.WithFriendlyPawn |
          GamePlay.TargetSettings.WithPawnsLock |
          GamePlay.TargetSettings.MustBeCalled);
     if (pawn.gamePlayComp.SetTargetsOnBoard(settings, pawn.gameObject, BuffPawnCallback))
     {
         pawn.gamePlayComp.ShowTargetNotification(pawn.Desc);
     }
 }
Ejemplo n.º 3
0
 private void AttackRulesOverride(int boardId)
 {
     Debug.Log("SuperVisor on AttackRulesOverride " + boardId);
     if (TargetPawn == null || TargetPawn.Death)
     {
         GamePlay.TargetSettings settings = GamePlay.TargetSettings.WithFriendlyPawn;
         if (pawn.gamePlayComp.SetTargetsOnBoard(settings, pawn.gameObject, TargetPawnCallback))
         {
             pawn.gamePlayComp.ShowTargetNotification(pawn.Desc);
         }
     }
 }
Ejemplo n.º 4
0
 private void AttackRulesOverride(int KilledPawnBoardId)
 {
     if ((!pawn.isFirstPlay) &&
         (!pawn.AttackAlready))
     {
         GamePlay.TargetSettings settings =
             (GamePlay.TargetSettings.WithEnemyHero |
              GamePlay.TargetSettings.WithEnemyPawn);
         if (pawn.gamePlayComp.SetTargetsOnBoard(settings, pawn.gameObject, TargetPawnCallback))
         {
             pawn.gamePlayComp.ShowTargetNotification(pawn.Desc);
         }
     }
 }
Ejemplo n.º 5
0
 private void ChoosePawnToBuff(int PawnBoardFieldId)
 {
     Debug.Log("SuperVisor on ChoosePawnToBuff " + PawnBoardFieldId);
     GamePlay.TargetSettings settings =
         (GamePlay.TargetSettings.WithFriendlyPawn |
          GamePlay.TargetSettings.WithPawnsLock |
          GamePlay.TargetSettings.MustBeCalled);
     if (pawn.gamePlayComp.SetTargetsOnBoard(settings, pawn.gameObject, TargetPawnCallback))
     {
         pawn.gamePlayComp.ShowTargetNotification(pawn.Desc);
     }
     else
     {
         pawn.pawnState = Pawn.pawnStates.onboard_idle;
     }
 }
Ejemplo n.º 6
0
 private void ChoosePawnToBuff(int PawnBoardFieldId)
 {
     if (pawn.CardType == CardsBase.CardTypesEnum.Effect)
     {
         pawn.DetachPawn();
     }
     GamePlay.TargetSettings settings =
         (GamePlay.TargetSettings.WithFriendlyPawn |
          GamePlay.TargetSettings.WithPawnsLock |
          GamePlay.TargetSettings.MustBeCalled);
     if (pawn.gamePlayComp.SetTargetsOnBoard(settings, pawn.gameObject, BuffPawnCallback))
     {
         pawn.gamePlayComp.ShowTargetNotification(pawn.Desc);
     }
     else
     {
         pawn.pawnState = Pawn.pawnStates.onboard_idle;
     }
 }
Ejemplo n.º 7
0
 private void DealDamageCallback(int PawnBoardFieldId)
 {
     GamePlay.TargetSettings settings =
         (GamePlay.TargetSettings.WithEnemyPawn |
          GamePlay.TargetSettings.WithEnemyHero |
          GamePlay.TargetSettings.WithPawnsLock |
          GamePlay.TargetSettings.MustBeCalled);
     if (tutorialMode)
     {
         settings =
             (GamePlay.TargetSettings.WithEnemyPawn |
              GamePlay.TargetSettings.WithPawnsLock |
              GamePlay.TargetSettings.MustBeCalled);
     }
     if (pawn.gamePlayComp.SetTargetsOnBoard(settings, pawn.gameObject, DealDamag))
     {
         pawn.gamePlayComp.ShowTargetNotification(pawn.Desc);
     }
 }
Ejemplo n.º 8
0
    private IEnumerator PlayRandomCardFromHand()
    {
        List <string> skipCard = new List <string> ();

        while (true)
        {
            List <string> cardsToPlay = GetPossibleCardsFromHand();
            if (skipCard.Count > 0)
            {
                foreach (string card in skipCard)
                {
                    cardsToPlay.Remove(card);
                }
            }
            if (cardsToPlay.Count > 0)
            {
                string cardToPlayName = cardsToPlay[Random.Range(0, cardsToPlay.Count)];
                int    handIndex;
                int    boardPosIndex = 0;
                bool   playcard      = true;

                handIndex = AIHandCards.IndexOf(cardToPlayName);
                if (GameplayComponent.IsFreePosision(17))
                {
                    boardPosIndex = 17;
                }
                else if (GameplayComponent.IsFreePosision(18))
                {
                    boardPosIndex = 18;
                }
                else if (GameplayComponent.IsFreePosision(21))
                {
                    boardPosIndex = 21;
                }
                else
                {
                    playcard = false;
                    break;
                }
                if (playcard)
                {
                    CardsBase.CardDescriptionClass cardDesc = GameplayComponent.CardsComp.FindCardDescByName(cardToPlayName);
                    if (cardDesc != null)
                    {
                        yield return(new WaitForSeconds(1f));

                        if (cardDesc.CardMode == CardsBase.CardTypesEnum.Pawn)
                        {
                            GameObject pawnObject = GameplayComponent.PutEnemyPawnOnBoard(cardToPlayName, AIPawnIDNext, 3, handIndex, boardPosIndex);
                            yield return(new WaitForSeconds(1f));

                            GameplayComponent.ConfirmEnemyPawnPos(cardToPlayName, AIPawnIDNext, 3, boardPosIndex);
                            spendMana += cardDesc.Cost;
                            AIHandCards.Remove(cardToPlayName);
                            if (pawnObject != null)
                            {
                                Pawn pawnComp = pawnObject.GetComponent <Pawn> ();
                                pawnComp.isFirstPlay = true;
                                if (pawnComp.AITriggerEffectCallback != null)
                                {
                                    List <int> targets = pawnComp.AITriggerEffectCallback(pawnComp.boardPosisionIndex);
                                    if (targets != null)
                                    {
                                        if (targets.Count > 0)
                                        {
                                            ShooseRandomTarget(cardToPlayName, pawnComp.boardPosisionIndex, -1, targets);
                                            yield return(new WaitForSeconds(1f));
                                        }
                                        else
                                        {
                                            skipCard.Add(cardToPlayName);
                                        }
                                    }
                                    else
                                    {
                                        skipCard.Add(cardToPlayName);
                                    }
                                }
                            }
                        }
                        else if (cardDesc.CardMode == CardsBase.CardTypesEnum.Effect)
                        {
                            //GameObject pawnObject = GameplayComponent.PutEnemyCardOnBoard (cardToPlayName, -1, 0, -1, -1).gameObject;
                            GameObject cardObject = GameplayComponent.CardsComp.SpawnCardByName(cardToPlayName);
                            GameObject pawnObject = cardObject.transform.Find("Pawn").gameObject;
                            cardObject.transform.localPosition = new Vector3(1000, 1000, 1000);
                            if (pawnObject != null)
                            {
                                Pawn pawnComp = pawnObject.GetComponent <Pawn> ();
                                pawnComp.gamePlayComp = GameplayComponent;
                                List <int> targets = pawnComp.AITriggerEffectCallback(pawnComp.boardPosisionIndex);
                                if (targets != null)
                                {
                                    if (cardDesc.EffectComponent.Equals("VerticalLineAttack"))
                                    {
                                        if (targets.Count > 0)
                                        {
                                            GameplayComponent.PlayEnemyEffectOnBoard(pawnComp.Name, Random.Range(0, 5), targets [Random.Range(0, targets.Count)], handIndex);
                                            yield return(new WaitForSeconds(1f));
                                        }
                                        else
                                        {
                                            skipCard.Add(cardToPlayName);
                                        }
                                    }
                                    else
                                    {
                                        if (targets.Count > 0)
                                        {
                                            ShooseRandomTarget(pawnComp.Name, -1, handIndex, targets);
                                            yield return(new WaitForSeconds(1f));
                                        }
                                        else
                                        {
                                            skipCard.Add(cardToPlayName);
                                        }
                                    }
                                    spendMana += cardDesc.Cost;
                                    AIHandCards.Remove(cardToPlayName);
                                }
                                else
                                {
                                    skipCard.Add(cardToPlayName);
                                }
                            }
                            Destroy(cardObject, 10);
                        }
                        else if (cardDesc.CardMode == CardsBase.CardTypesEnum.Weapon)
                        {
                            GamePlay.TargetSettings settings = GamePlay.TargetSettings.WithEnemyPawn;
                            GameplayComponent.SetTargetsOnBoard(settings, null, null);
                            List <int> targets = GameplayComponent.TargetsList;
                            if (targets != null)
                            {
                                if (targets.Count > 0)
                                {
                                    int target = targets [Random.Range(0, targets.Count)];
                                    GameplayComponent.PutEnemyWeaponOnBoard(cardToPlayName, 3, handIndex, target);
                                    yield return(new WaitForSeconds(1f));

                                    GameplayComponent.GiveWeaponToEnemyPawn(cardToPlayName, target, 3);
                                    spendMana += cardDesc.Cost;
                                    AIHandCards.Remove(cardToPlayName);
                                    yield return(new WaitForSeconds(1f));
                                }
                                else
                                {
                                    skipCard.Add(cardToPlayName);
                                }
                            }
                            else
                            {
                                skipCard.Add(cardToPlayName);
                            }
                        }

                        AIPawnIDNext++;
                    }
                }
            }
            else
            {
                break;
            }
            if ((mana - spendMana) <= 1)
            {
                break;
            }
        }
        StartCoroutine(RandomMoves());
    }