Esempio n. 1
0
    public void UpdateValuesFromCardAsset()
    {
        if (myCard != null)
        {
            if (myCard.cardType == CardType.Creature)
            {
                myCreatureCard = myCard as SO_Creature;
                buildingCardFront.SetActive(false);
                creatureCardFront.SetActive(true);
                spellCardFront.SetActive(false);

                c_cardNameTextObj.text        = myCard.cardName;
                c_cardTitleTintImageObj.color = myCard.cardTint;
                c_cardCostTextObj.text        = myCard.cost.ToString();
                c_cardImageObj.sprite         = myCard.cardImage;
                c_cardDescTextObj.text        = myCard.cardText;
                c_cardDescTintImageObj.color  = myCard.cardTint;
                c_cardFlavorTextObj.text      = myCard.cardFlavorText;

                c_cardAttackRangeTextObj.text = myCreatureCard.attackRange.ToString();
                c_cardMovementTextObj.text    = myCreatureCard.movement.ToString();
                c_cardDamageTextObj.text      = myCreatureCard.damage.ToString();
                c_cardHealthTextObj.text      = myCreatureCard.health.ToString();
            }

            if (myCard.cardType == CardType.Building)
            {
                myBuildingCard = myCard as SO_Building;
                buildingCardFront.SetActive(true);
                creatureCardFront.SetActive(false);
                spellCardFront.SetActive(false);


                b_cardNameTextObj.text        = myCard.cardName;
                b_cardTitleTintImageObj.color = myCard.cardTint;
                b_cardCostTextObj.text        = myCard.cost.ToString();
                b_cardImageObj.sprite         = myCard.cardImage;
                b_cardDescTextObj.text        = myCard.cardText;
                b_cardDescTintImageObj.color  = myCard.cardTint;
                b_cardFlavorTextObj.text      = myCard.cardFlavorText;
            }

            if (myCard.cardType == CardType.Spell)
            {
                mySpellCard = myCard as SO_Spell;
                buildingCardFront.SetActive(false);
                creatureCardFront.SetActive(false);
                spellCardFront.SetActive(true);

                s_cardNameTextObj.text        = myCard.cardName;
                s_cardTitleTintImageObj.color = myCard.cardTint;
                s_cardCostTextObj.text        = myCard.cost.ToString();
                s_cardImageObj.sprite         = myCard.cardImage;
                s_cardDescTextObj.text        = myCard.cardText;
                s_cardDescTintImageObj.color  = myCard.cardTint;
                s_cardFlavorTextObj.text      = myCard.cardFlavorText;
            }
        }
    }
    public void Cast()
    {
        SO_Spell combo1, combo2;

        currentSpell.CastSpell(out combo1, out combo2);
        activeCanCombo1 = combo1;
        activeCanCombo2 = combo2;

        activeSpell = currentSpell;
    }
Esempio n. 3
0
    private void HighlightSpellEffectArea()
    {
        List <Node> myAffectedArea = new List <Node>();
        ArenaGrid   myBattleGrid   = FindObjectOfType <ArenaGrid>();

        mySpellCard    = myCard as SO_Spell;
        myAffectedArea = myBattleGrid.GetNeighboursInRangeVariableSize(hoveredNode, mySpellCard.xMin, mySpellCard.xMax, mySpellCard.yMin, mySpellCard.yMax);
        myAffectedArea.Add(hoveredNode);
        foreach (Node node in myAffectedArea)
        {
            node.HighlightMoveNow();
        }
    }
Esempio n. 4
0
    public void SwitchSpell(int index)
    {
        spellSlotsList[index].Blink();

        if (spellsList[index] != null)
        {
            tempSpell         = spellsList[0];
            spellsList[0]     = spellsList[index];
            spellsList[index] = tempSpell;

            spellController.currentSpell = spellsList[0].activeBlank;

            UpdateSlots();
        }
    }
    private void GetBestSpell(out SO_Spell _Spell, out float spellRatio)
    {
        float    bestSpellRatio = 0;
        SO_Spell bestSpell      = null;

        for (int i = 0; i < spellsList.Count; i++)
        {
            float thisSpellRatio = spellsList[i].healthDamage + spellsList[i].manaDamage /
                                   spellsList[i].healthCost + spellsList[i].manaCost;

            if (thisSpellRatio > bestSpellRatio)
            {
                bestSpellRatio = thisSpellRatio;
                bestSpell      = spellsList[i];
            }
        }

        _Spell     = bestSpell;
        spellRatio = bestSpellRatio;
    }
Esempio n. 6
0
    private void RunSpellFunction()
    {
        ClearPathHighlights();

        if (mySpellCard.spellType == SpellType.Damage)
        {
            //Find nodes in affected area
            List <Node> myAffectedArea = new List <Node>();
            ArenaGrid   myBattleGrid   = FindObjectOfType <ArenaGrid>();
            mySpellCard    = myCard as SO_Spell;
            myAffectedArea = myBattleGrid.GetNeighboursInRangeVariableSize(ReturnNodeIAmOn(), mySpellCard.xMin, mySpellCard.xMax, mySpellCard.yMin, mySpellCard.yMax);
            myAffectedArea.Add(ReturnNodeIAmOn());

            //Check for enemies on each node
            List <TokenManager> enemiesInRange = new List <TokenManager>();
            foreach (Node node in myAffectedArea)
            {
                if (node.occupied)
                {
                    if (node.ReturnTokenOnNode().myTeam != myTeam)
                    {
                        enemiesInRange.Add(node.ReturnTokenOnNode());
                    }
                }
            }

            //Deal Damage to them
            foreach (TokenManager token in enemiesInRange)
            {
                StartCoroutine(DealDamageAfterTime(mySpellCard.damageAmount, 0, token));
            }
            StartCoroutine(DestroyAfterTime(1));
        }

        if (mySpellCard.spellType == SpellType.Buff)
        {
            //Find nodes in affected area
            List <Node> myAffectedArea = new List <Node>();
            ArenaGrid   myBattleGrid   = FindObjectOfType <ArenaGrid>();
            mySpellCard    = myCard as SO_Spell;
            myAffectedArea = myBattleGrid.GetNeighboursInRangeVariableSize(ReturnNodeIAmOn(), mySpellCard.xMin, mySpellCard.xMax, mySpellCard.yMin, mySpellCard.yMax);
            myAffectedArea.Add(ReturnNodeIAmOn());

            //Check for allies on each node
            List <TokenManager> alliesInRange = new List <TokenManager>();
            foreach (Node node in myAffectedArea)
            {
                if (node.occupied)
                {
                    if (node.ReturnTokenOnNode().myTeam == myTeam)
                    {
                        alliesInRange.Add(node.ReturnTokenOnNode());
                    }
                }
            }

            foreach (TokenManager ally in alliesInRange)
            {
                if (mySpellCard.rangeBuff != 0)
                {
                    ally.AddBuff(StatType.Range, mySpellCard.rangeBuff, mySpellCard.buffLength);
                }
                if (mySpellCard.movementBuff != 0)
                {
                    ally.AddBuff(StatType.Movement, mySpellCard.movementBuff, mySpellCard.buffLength);
                }
                if (mySpellCard.attackBuff != 0)
                {
                    ally.AddBuff(StatType.Attack, mySpellCard.attackBuff, mySpellCard.buffLength);
                }
                if (mySpellCard.healthBuff != 0)
                {
                    ally.AddBuff(StatType.Health, mySpellCard.healthBuff, mySpellCard.buffLength);
                }

                ally.RecalcBuffs();
            }
            StartCoroutine(DestroyAfterTime(0));
        }

        if (mySpellCard.spellType == SpellType.Debuff)
        {
            //Find nodes in affected area
            List <Node> myAffectedArea = new List <Node>();
            ArenaGrid   myBattleGrid   = FindObjectOfType <ArenaGrid>();
            mySpellCard    = myCard as SO_Spell;
            myAffectedArea = myBattleGrid.GetNeighboursInRangeVariableSize(ReturnNodeIAmOn(), mySpellCard.xMin, mySpellCard.xMax, mySpellCard.yMin, mySpellCard.yMax);
            myAffectedArea.Add(ReturnNodeIAmOn());

            //Check for enemies on each node
            List <TokenManager> enemiesInRange = new List <TokenManager>();
            foreach (Node node in myAffectedArea)
            {
                if (node.occupied)
                {
                    if (node.ReturnTokenOnNode().myTeam != myTeam)
                    {
                        enemiesInRange.Add(node.ReturnTokenOnNode());
                    }
                }
            }

            foreach (TokenManager enemy in enemiesInRange)
            {
                if (mySpellCard.rangeBuff != 0)
                {
                    enemy.AddBuff(StatType.Range, mySpellCard.rangeBuff, mySpellCard.buffLength); Debug.Log("Added DeBuff : Range");
                }
                if (mySpellCard.movementBuff != 0)
                {
                    enemy.AddBuff(StatType.Movement, mySpellCard.movementBuff, mySpellCard.buffLength); Debug.Log("Added DeBuff : Movement");
                }
                if (mySpellCard.attackBuff != 0)
                {
                    enemy.AddBuff(StatType.Attack, mySpellCard.attackBuff, mySpellCard.buffLength); Debug.Log("Added DeBuff : Attack");
                }
                if (mySpellCard.healthBuff != 0)
                {
                    enemy.AddBuff(StatType.Health, mySpellCard.healthBuff, mySpellCard.buffLength); Debug.Log("Added DeBuff : Health");
                }

                enemy.RecalcBuffs();
            }
        }

        if (mySpellCard.spellType == SpellType.Resource)
        {
            if (mySpellCard.goldPerAllyCreature > 0)
            {
                TokenManager[] activeTokens = FindObjectsOfType <TokenManager>();
                foreach (TokenManager token in activeTokens)
                {
                    if (token.myTeam == myTeam && token.myCreatureCard != null)
                    {
                        CurrencyManager.instance.AlterGold(mySpellCard.goldPerAllyCreature);
                        FindObjectOfType <BattleArenaUIManager>().UpdateGoldDisplay();
                    }
                }
            }
            StartCoroutine(DestroyAfterTime(0));
        }

        if (mySpellCard.spellType == SpellType.Stun)
        {
            //Find nodes in affected area
            List <Node> myAffectedArea = new List <Node>();
            ArenaGrid   myBattleGrid   = FindObjectOfType <ArenaGrid>();
            mySpellCard    = myCard as SO_Spell;
            myAffectedArea = myBattleGrid.GetNeighboursInRangeVariableSize(ReturnNodeIAmOn(), mySpellCard.xMin, mySpellCard.xMax, mySpellCard.yMin, mySpellCard.yMax);
            myAffectedArea.Add(ReturnNodeIAmOn());

            //Check for enemies on each node
            List <TokenManager> enemiesInRange = new List <TokenManager>();
            foreach (Node node in myAffectedArea)
            {
                if (node.occupied)
                {
                    if (node.ReturnTokenOnNode().myTeam != myTeam)
                    {
                        enemiesInRange.Add(node.ReturnTokenOnNode());
                    }
                }
            }

            foreach (TokenManager enemy in enemiesInRange)
            {
                enemy.AddBuff(StatType.Stun, 0, mySpellCard.buffLength); Debug.Log("Added DeBuff : Stun");
            }
            StartCoroutine(DestroyAfterTime(0));
        }
    }
Esempio n. 7
0
    protected virtual void TokenSetUp()
    {
        haveSetUp     = true;
        myTokensImage = myCard.cardImage;

        if (myTokenImageObj != null)
        {
            myTokenImageObj.sprite = myTokensImage;
        }

        if (myCard.cardType == CardType.Creature)
        {
            myCreatureCard = myCard as SO_Creature;

            maxHealth     = myCreatureCard.health;
            currentHealth = maxHealth;

            maxMovement = myCreatureCard.movement;
            if (myCreatureCard.hasHaste)
            {
                remainingMovement = maxMovement;
            }
            else
            {
                remainingMovement = 0;
            }

            attackRange  = myCreatureCard.attackRange;
            attackDamage = myCreatureCard.damage;

            GetComponent <MeshRenderer>().material = TokenMaterial();
        }

        if (myCard.cardType == CardType.Building)
        {
            myBuildingCard = myCard as SO_Building;

            maxHealth     = myBuildingCard.health;
            currentHealth = maxHealth;

            attackRange  = myBuildingCard.attackRange;
            attackDamage = myBuildingCard.damage;

            if (myBuildingCard.impactsGoldPerTurn)
            {
                CurrencyManager.instance.IncreaseGoldPerTurn(myBuildingCard.goldPerTurnIncrease);
            }
            if (myBuildingCard.canSpawnToken)
            {
                countToAction = myBuildingCard.tokenSpawnEveryXTturns;
            }
            if (myBuildingCard.canChangeNodeType)
            {
                List <Node> changeNodes = new List <Node>();
                Node        myNode      = ReturnNodeIAmOn();

                myBattleGrid = FindObjectOfType <ArenaGrid>();
                changeNodes  = myBattleGrid.GetNeighboursInRange(myNode, 1);

                foreach (Node node in changeNodes)
                {
                    node.tileType = myBuildingCard.nodeTypeToAdd;
                    node.tileTeam = myTeam;
                    node.UpdateMaterial(node.tileTeam, node.tileType, node.walkable);
                }
            }

            GetComponent <MeshRenderer>().material = TokenMaterial();
        }

        if (myCard.cardType == CardType.Spell)
        {
            mySpellCard = myCard as SO_Spell;
        }

        RecalcBuffs();
    }