Exemplo n.º 1
0
    private void OnPlayed()
    {
        if (!AssertState(State.Playing))
        {
            return;
        }

        if (cardModel.prototype.inLanePrefab != null)
        {
            GameObject laneObject = GameObject.Instantiate(cardModel.prototype.inLanePrefab);

            laneObject.transform.position = currSlot.transform.position;
            CardInLane card = laneObject.GetComponent <CardInLane>();
            card.SetOwner(owner);
            card.SetCardModel(cardModel);
            card.SetSlot(currSlot);
            card.cardType = cardType; //TODO should probably be in CardPrototype
            SpellInLane spell = laneObject.GetComponent <SpellInLane>();
            if (spell != null)
            {
                spell.SetOwner(owner);
                spell.SetCardModel(cardModel);
                spell.SetSlot(currSlot);
            }

            currSlot.Occupy(laneObject);

            //TODO sound effects or whatever (maybe configed on card prototype)
        }
        else
        {
            currSlot.Release();
            currSlot = null;
        }

        Destroy(gameObject);
    }
Exemplo n.º 2
0
    public void Attack()
    {
        // Reset dmg queues
        for (int i = 0; i < 5; i++)
        {
            playerDamageArray[i] = 0;
            enemyDamageArray[i]  = 0;
        }

        for (int i = 0; i < 5; i++)
        {
            var playerSlot = playerSlots.slots[i];
            var enemySlot  = enemySlots.slots[i];

            GameObject playerCard = playerSlot.occupied ? playerSlot.objectInSlot : null;
            GameObject enemyCard  = enemySlot.occupied ? enemySlot.objectInSlot : null;

            if (playerCard == null && enemyCard == null)
            {
                continue;
            }
            if (playerCard != null)
            {
                CardInLane card = playerCard.GetComponent <CardInLane>();
                if (card.cardType == Card.CardType.Spell)
                {
                    SpellInLane spell = playerCard.GetComponent <SpellInLane>();
                    spell.CountdownSpell(i, true);
                    if (spell.timeToCast == 0)
                    {
                        Remove(spell);
                    }
                }
                else
                {
                    enemyDamageArray[i] += card.GetAttackDamage();
                }
            }
            if (enemyCard != null)
            {
                CardInLane card = enemyCard.GetComponent <CardInLane>();
                if (card.cardType == Card.CardType.Spell)
                {
                    SpellInLane spell = enemyCard.GetComponent <SpellInLane>();
                    spell.CountdownSpell(i, false);
                    if (spell.timeToCast == 0)
                    {
                        Remove(spell);
                    }
                }
                else
                {
                    playerDamageArray[i] += card.GetAttackDamage();
                }
            }
        }
        // Resolve damage queues
        for (int i = 0; i < 5; i++)
        {
            AttackSlot(i, enemySlots, enemyDamageArray[i], enemyHp);
            AttackSlot(i, playerSlots, playerDamageArray[i], playerHp);
        }

        // track a victory!
        if (enemyHp.current <= 0 && playerHp.current <= 0)
        {
            GameManager.instance.Draw();
        }
        else if (playerHp.current <= 0)
        {
            GameManager.instance.Lose();
        }
        //TODO this should do... something else for the boss capture scene
        else if (enemyHp.current <= 0)
        {
            GameManager.instance.Win();
        }
    }