Exemplo n.º 1
0
        public int[] ApplyActiveToAlly(CardTablePart playerTablepart,
                                       CardPosition playerSpecifiedCardPosition = null)
        {
            int[] result = new int[0];

            for (int a = 0; a < cardAbilities.Length; a++)
            {
                if (playerSpecifiedCardPosition != null)
                {
                    for (int ta = 0; ta < cardAbilities[a].toAlly.Length; ta++)
                    {
                        if (cardAbilities[a].toAlly[ta] == ApplyToAlly.SPECIFIED)
                        {
                            //Debug.Log("playerSpecifiedCardPosition.row = " + playerSpecifiedCardPosition.row);
                            //Debug.Log("playerSpecifiedCardPosition.column = " + playerSpecifiedCardPosition.column);
                            playerTablepart.cardArray
                            [playerSpecifiedCardPosition.row]
                            [playerSpecifiedCardPosition.column]
                            .ApplyAbility(cardAbilities[a]);

                            result = HelperFunctions.Add <int>(result,
                                                               playerTablepart.cardArray[playerSpecifiedCardPosition.row]
                                                               [playerSpecifiedCardPosition.column].cardIndex);
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        public int[] ApplyActiveToOpponent(CardTablePart opponentTablePart, CardPosition opponentSpecifiedCardPosition = null)
        {
            int[] result = new int[0];

            for (int a = 0; a < cardAbilities.Length; a++)
            {
                if (opponentSpecifiedCardPosition != null)
                {
                    for (int ta = 0; ta < cardAbilities[a].toOpponent.Length; ta++)
                    {
                        if (cardAbilities[a].toOpponent[ta] == ApplyToOpponent.SPECIFIED)
                        {
                            opponentTablePart.cardArray
                            [opponentSpecifiedCardPosition.row]
                            [opponentSpecifiedCardPosition.column]
                            .ApplyAbility(cardAbilities[a]);
                        }
                    }

                    result = HelperFunctions.Add <int>(result,
                                                       opponentTablePart.cardArray[opponentSpecifiedCardPosition.row]
                                                       [opponentSpecifiedCardPosition.column].cardIndex);
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called from AbstructPlayer.Initialize()
        /// </summary>
        /// <param name="card"></param>
        public void AddCardToHand(Card card)
        {
            GameObject  newCard     = Instantiate(cardPrefab);
            CardVisuals cardVisuals = newCard.GetComponent <CardVisuals>();

            newCard.GetComponent <CardVisuals>().Initialize(card, player.playerIndex);
            newCard.transform.SetParent(playerHand.transform);
            newCard.transform.localPosition = new Vector3(cardOffset.x * card.cardIndex, 0, 0);
            playerCards = HelperFunctions.Add <GameObject>(playerCards, newCard);

            //TODO: Update player card points text
            UpdateCardPointsText(cardVisuals, card);
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param player OR opponent table part="playerTablePart"></param>
        /// <param name="thisCardPosition"></param>
        /// <returns>returns an array of int - indexes of cards this ability applied to</returns>
        public int[] ApplyPassiveToAlly(CardTablePart playerTablePart, CardPosition thisCardPosition)
        {
            // Indexes of cards this ability applied to
            int[] result = new int[0];

            for (int a = 0; a < cardAbilities.Length; a++)
            {
                CardAbility ability = cardAbilities[a];

                // toAlly
                for (int i = 0; i < ability.toAlly.Length; i++)
                {
                    switch (ability.toAlly[i])
                    {
                    case ApplyToAlly.ALL:
                        for (int row = 0; row < playerTablePart.cardArray.Length; row++)
                        {
                            for (int col = 0; col < playerTablePart.cardArray[row].Length; col++)
                            {
                                //Debug.Log("Passive ability applieed");
                                playerTablePart.cardArray[row][col].ApplyAbility(ability);

                                result = HelperFunctions.Add(result, playerTablePart.cardArray[row][col].cardIndex);
                            }
                        }
                        break;

                    case ApplyToAlly.ITSELF:
                        this.ApplyAbility(ability);
                        result = HelperFunctions.Add <int>(result, this.cardIndex);
                        break;

                    case ApplyToAlly.LEFT:
                        try
                        {
                            playerTablePart.cardArray[thisCardPosition.row][thisCardPosition.column - 1].ApplyAbility(ability);
                            result = HelperFunctions.Add <int>(result,
                                                               playerTablePart.cardArray[thisCardPosition.row][thisCardPosition.column - 1].cardIndex);
                        }
                        catch (IndexOutOfRangeException) { }
                        break;

                    case ApplyToAlly.RIGHT:
                        try
                        {
                            playerTablePart.cardArray[thisCardPosition.row][thisCardPosition.column + 1].ApplyAbility(ability);
                            result = HelperFunctions.Add <int>(result,
                                                               playerTablePart.cardArray[thisCardPosition.row][thisCardPosition.column + 1].cardIndex);
                        }
                        catch (IndexOutOfRangeException) { }
                        break;

                    case ApplyToAlly.ROW:
                        for (int col = 0; col < playerTablePart.cardArray[thisCardPosition.row].Length; col++)
                        {
                            playerTablePart.cardArray[thisCardPosition.row][col].ApplyAbility(ability);
                            result = HelperFunctions.Add <int>(result, playerTablePart.cardArray[thisCardPosition.row][col].cardIndex);
                        }
                        break;

                    case ApplyToAlly.RANDOM:
                    {
                        int row = playerTablePart.GetRandomRowWithCards();
                        if (row != -1)
                        {
                            int col = HelperFunctions.RandomExcept(
                                0, playerTablePart.cardArray[row].Length,
                                thisCardPosition.column);
                            if (col != 0)
                            {
                                playerTablePart.cardArray[row][col].ApplyAbility(ability);
                                result = HelperFunctions.Add <int>(result, playerTablePart.cardArray[row][col].cardIndex);
                            }
                        }
                    }
                    break;

                    case ApplyToAlly.NONE:
                        break;

                    default:
                        break;
                    }

                    Debug.Log("     ApplyPassiveAbilityToAlly");
                }
            }

            return(result);
        }
Exemplo n.º 5
0
        public int[] ApplyPassiveToOpponent(CardTablePart opponentTablePart, CardPosition thisCardPosition)
        {
            // Indexes of cards this ability applied to
            int[] result = new int[0];

            for (int a = 0; a < cardAbilities.Length; a++)
            {
                CardAbility ability = cardAbilities[a];

                // toOpponent
                for (int i = 0; i < ability.toOpponent.Length; i++)
                {
                    switch (ability.toOpponent[i])
                    {
                    case ApplyToOpponent.ALL:
                        for (int row = 0; row < opponentTablePart.cardArray.Length; row++)
                        {
                            for (int col = 0; col < opponentTablePart.cardArray[row].Length; col++)
                            {
                                //Debug.Log("Passive ability applieed");
                                opponentTablePart.cardArray[row][col].ApplyAbility(ability);

                                result = HelperFunctions.Add <int>(result, opponentTablePart.cardArray[row][col].cardIndex);
                            }
                        }
                        break;

                    case ApplyToOpponent.ROW:
                        for (int col = 0; col < opponentTablePart.cardArray[thisCardPosition.row].Length; col++)
                        {
                            //TODO: !!!!!!!!!!!!!!!!!!!!!!
                            //opponentTablePart.cardArray[thisCardPosition.row][col].ApplyAbility(ability);
                        }
                        break;

                    case ApplyToOpponent.RANDOM:
                    {
                        //Debug.Log("Random applied");
                        int row = opponentTablePart.GetRandomRowWithCards();
                        if (row == -1)
                        {
                            break;
                        }
                        int col = UnityEngine.Random.Range(
                            0, opponentTablePart.cardArray[row].Length);
                        opponentTablePart.cardArray[row][col].ApplyAbility(ability);
                        result = HelperFunctions.Add <int>(result, opponentTablePart.cardArray[row][col].cardIndex);
                    }
                    break;

                    case ApplyToOpponent.NONE:
                        break;

                    default:
                        break;
                    }

                    Debug.Log("     ApplyPassiveAbilityToOpponent");
                }
            }
            return(result);
        }