Пример #1
0
    void ShuffleCards(CombatantBehavior combatant, Transform combatantTransform)
    {
        bool keepGoing = true;

        while (keepGoing)
        {
            if (combatant.GetNextOpenSlot() < handAmount && combatant.GetNextOpenSlot() != -1)
            {
                int openSlot = combatant.GetNextOpenSlot();
                //Probably not good to try/catch this.
                try
                {
                    CardBehavior card = cardScripts[combatant.GetCardInSlot(openSlot + 1)];
                    card.MoveSlot(openSlot, combatantTransform.GetChild(openSlot));
                    combatant.SetOccupiedSlot(openSlot + 1, false, -1);
                    combatant.SetOccupiedSlot(card.GetSlot(), true, card.GetSessionId());
                }
                catch
                {
                    keepGoing = false;
                }
            }
            else
            {
                keepGoing = false;
            }
        }
    }
Пример #2
0
    void DrawCard(CombatantBehavior combatant)
    {
        //In cardbehavior
        int slot = combatant.GetNextOpenSlot();

        if (slot != -1)
        {
            combatant.SetOccupiedSlot(slot, true, SpawnCardRandomDeck(combatant.transform.GetChild(slot), slot, combatant.GetSessionId(), combatant.GetDeckLength()));
            //combatant.SetOccupiedSlot(slot, true, SpawnCardRandomDeck(combatant.transform.GetChild(slot), slot, combatant.GetId(), combatant.GetDeckLength()));
            //combatant.SetOccupiedSlot(slot, true, SpawnCardFullDeck(combatant.transform.GetChild(slot), slot, combatant.GetId()));
        }
    }
Пример #3
0
    /*
     * //PlayCard With Button
     * void PlayCard()
     * {
     *  if (selectedCard != null && selectedCombatant != null)
     *  {
     *      //Attack Card
     *      if (selectedCard.GetEffect() == 0 && selectedCombatant.side != sideTurn) //make side a getter.
     *      {
     *          if (selectedCombatant.Damage(selectedCard.GetDamageVal()) <= 0) //Call HPAdjust, do damage, if it brings the combatant's HP zero, kill it.
     *          {
     *              selectedCombatant.Die();
     *              selectedCombatant = null;
     *          }
     *          selectedCard.Die();
     *          selectedCard = null;
     *          EndTurn();
     *      }
     *      //Healer Card
     *      else if (selectedCard.GetEffect() == 1)
     *      {
     *          Debug.Log("Healing Card. Not yet implemented.");
     *          EndTurn();
     *      }
     *      else
     *      {
     *          Debug.Log("Card Has No Effect");
     *      }
     *      //EndTurn();
     *  }
     * }
     */

    //PlayCard With PlayArea
    void PlayCard()
    {
        if (playAreaCard != null && selectedCombatant != null)
        {
            //Attack Card
            if (playAreaCard.GetEffect() == 0 && selectedCombatant.side != sideTurn) //make side a getter.
            {
                CombatantBehavior owningCombatant = combatantScripts[playAreaCard.GetCombatant()];

                if (owningCombatant.EvalCardCost(playAreaCard.GetApCost()))         //Evaluate if we have enough AP to use card then remove action points based on card AP cost.
                {
                    if (selectedCombatant.Damage(playAreaCard.GetDamageVal()) <= 0) //Call HPAdjust, do damage, if it brings the combatant's HP zero, kill it.
                    {
                        KillCombatant(selectedCombatant);
                    }

                    //owningCombatant.SubtractAp(playAreaCard.GetApCost()); //Remove action points based on card AP cost.
                    owningCombatant.SetOccupiedSlot(playAreaCard.GetSlot(), false, -1); //Set slot's occupied slot to empty.

                    ShuffleCards(owningCombatant, activeCombatants[playAreaCard.GetCombatant()].transform);

                    activeCards[playAreaCard.GetSessionId()] = null;
                    cardScripts[playAreaCard.GetSessionId()] = null;
                    playAreaCard.Die();
                    playAreaCard = null;
                    //EndTurn();
                }
                //Healer Card
                else if (playAreaCard.GetEffect() == 1)
                {
                    Debug.Log("Healing Card. Not yet implemented.");
                    EndTurn();
                }
                else
                {
                    Debug.Log("Card Has No Effect");
                }
                //EndTurn();
            }
        }
    }