Пример #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 KillCombatant(CombatantBehavior combatant)
    {
        int index = combatant.GetSessionId();

        combatantScripts[index].Die();
        activeCombatants[index] = null;
        combatantScripts[index] = null;
        combatant         = null;
        selectedCombatant = null;
    }
Пример #3
0
    void EndTurn()
    {
        sideTurn++;
        if (sideTurn > sidesAmount - 1)
        {
            sideTurn = 0;
        }

        turnCount++;

        for (int k = 0; k < amtCombatants; k++)
        {
            if (activeCombatants[k] != null)
            {
                FillHand(activeCombatants[k]);
                combatantScripts[k].ResetAp(sideTurn); //Fill combatant AP to max AP if it is the beginning of their turn.
            }
        }

        //Change Turn Text
        if (sideTurn == 0)
        {
            turnText0.text = "Turn";
            turnText1.text = "";
        }
        else
        {
            turnText0.text = "";
            turnText1.text = "Turn";
        }

        //Deselect Cards and Combatants
        if (selectedCard != null)
        {
            selectedCard.Reset();
            selectedCard = null;
        }

        if (selectedCombatant != null)
        {
            selectedCombatant.Select(false);
            selectedCombatant = null;
        }

        //Tell AI it's their turn.
        if (AI_Enabled)
        {
            if (sideTurn == enemyScript.GetSide())
            {
                enemyScript.IsTurn(true);
            }
        }
    }
Пример #4
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()));
        }
    }
Пример #5
0
    void Hover(Vector3 mposition)
    {
        RaycastHit hit;
        Ray        ray = camera.ScreenPointToRay(mposition);

        if (Physics.Raycast(ray, out hit))
        {
            Transform objectHit = hit.transform;
            if (objectHit.tag == "Card")
            {
                if (highlightedCard != null)
                {
                    highlightedCard.Highlight(false);
                }
                highlightedCard = objectHit.gameObject.GetComponent <CardBehavior>();
                highlightedCard.Highlight(true);
            }

            else if (objectHit.tag == "Button")
            {
                highlightedButton = objectHit.gameObject.GetComponent <ButtonBehavior>();
                highlightedButton.Highlight(true);
            }

            else if (objectHit.tag == "Combatant")
            {
                highlightedCombatant = objectHit.gameObject.GetComponent <CombatantBehavior>();
                highlightedCombatant.Highlight(true);
            }

            else
            {
                if (highlightedCard != null)
                {
                    highlightedCard.Highlight(false);
                    highlightedCard = null;
                }
                if (highlightedButton != null)
                {
                    highlightedButton.Highlight(false);
                    highlightedButton = null;
                }
                if (highlightedCombatant != null)
                {
                    highlightedCombatant.Highlight(false);
                    highlightedCombatant = null;
                }
            }
        }
    }
Пример #6
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();
            }
        }
    }
Пример #7
0
 public void AIUse(int combatant)
 {
     selectedCombatant = combatantScripts[combatant];
     PlayCard();
 }
Пример #8
0
    void Click(Vector3 mposition)
    {
        RaycastHit hit;
        Ray        ray = camera.ScreenPointToRay(mposition);

        if (Physics.Raycast(ray, out hit))
        {
            Transform objectHit = hit.transform;
            if (objectHit.tag == "Card")
            {
                updateMousePos = true;
                if (selectedCard != null)
                {
                    selectedCard.Select(false);
                }
                selectedCard = objectHit.gameObject.GetComponent <CardBehavior>();
                selectedCard.Select(true);
                oldCardPosition = selectedCard.transform.localPosition;
            }

            else if (objectHit.tag == "Button")
            {
                selectedButton = objectHit.gameObject.GetComponent <ButtonBehavior>();
                selectedButton.Select(true);
            }


            else if (objectHit.tag == "Combatant")
            {
                if (selectedCombatant != null)
                {
                    selectedCombatant.Select(false);
                }
                selectedCombatant = objectHit.gameObject.GetComponent <CombatantBehavior>();
                selectedCombatant.Select(true);

                if (playAreaCard != null)
                {
                    PlayCard();
                }
            }

            else if (objectHit.tag == "PlayArea")
            {
                if (playAreaCard != null)
                {
                    playAreaCard.Reset();
                    playAreaCard = null;
                }
            }

            else
            {
                if (selectedCard != null)
                {
                    selectedCard.Select(false);
                    selectedCard = null;
                }

                if (selectedCombatant != null)
                {
                    selectedCombatant.Select(false);
                    selectedCombatant = null;
                }
            }
        }
    }
Пример #9
0
 public void AttachBehavior(CombatantBehavior behavior)
 {
     behavior.Combatant = this;
     CombatantBehaviors.Add(behavior);
 }