Exemplo n.º 1
0
    // Use this for initialization

    void Awake()
    {
        instanse = this;
        DontDestroyOnLoad(gameObject);
    }
Exemplo n.º 2
0
        /// <summary>
        /// Handles All Card Battles
        /// Returns damage to player
        /// </summary>
        /// <param name="atkInst">Attacking card</param>
        /// <param name="blockInstance">Blocking Card Instances</param>
        /// <param name="mainData"></param>
        public int CardBattle(CreatureCard atkInst, BlockInstance blockInstance, MainDataHolder mainData)
        {
            int     result     = -1;
            Element atkElement = mainData.AttackElement;
            Element defElement = mainData.HealthElement;
            //Element abilityElement = maindData.AbilityElement;

            int atkLife   = atkInst.CreatureData.Defend;
            int atkAttack = atkInst.CreatureData.Attack;

            //CardProperties atkAbility = atkInst.viz.card.GetProperties(abilityElement);


            if (atkLife == 0)
            {
                Debug.LogError("Attacking card don't have Life element");
                return(result);
            }
            if (atkAttack == 0)
            {
                Debug.LogError("Attacking card don't have attack element");
                return(result);
            }


            if (blockInstance != null)
            {
                for (int index = 0; index < blockInstance.defenders.Count; index++)
                {
                    CreatureCard defInst   = blockInstance.defenders[index];
                    int          defLife   = defInst.CreatureData.Defend;
                    int          defAttack = defInst.CreatureData.Attack;
                    if (defLife == 0)
                    {
                        Debug.LogWarning("You are trying to block with a card with no health element");
                        continue;
                    }


                    Debug.LogFormat("CARD BATTLE STARTS: Attcker({0}) Health: {1} Attack: {2} VS Defender({3}) Health: {4} Attack: {5}",
                                    atkInst.User.PlayerProfile.UniqueId, atkLife, atkAttack,
                                    defInst.User.PlayerProfile.UniqueId, defLife, defAttack);



                    int tmpAtk = atkAttack;
                    atkAttack -= defLife;

                    defLife -= tmpAtk;
                    atkLife -= defAttack;

                    Debug.LogFormat("CARD BATTLE RESULT: Attcker({0}) Health: {1}. Defender({2}) Health: {3}",
                                    atkInst.User.PlayerProfile.UniqueId, atkLife,
                                    defInst.User.PlayerProfile.UniqueId, defLife);
                    if (defLife <= atkAttack)
                    {
                        Debug.LogFormat("CardBattle: Defender( {0} )'s Card {1} Killed by {2}",
                                        defInst.User.PlayerProfile.UniqueId, defInst.GetCardData.Name, atkInst.GetCardData.Name);
                        SetCardToGrave(defInst);
                    }
                    if (atkLife <= 0)
                    {
                        Debug.LogFormat("CardBattle: Attacker( {0} )'s Card {1} is Killed by {2} during attack ",
                                        atkInst.User.PlayerProfile.UniqueId, atkInst.GetCardData.Name, defInst.GetCardData.Name);
                        atkLife = 0;
                        SetCardToGrave(atkInst);
                        break;
                    }
                }
            }
            else
            {
                Debug.Log("BattleLogicCardBattle: Block Instance of attacking card is null");
            }

            result = atkAttack;
            return(result);
        }