Ejemplo n.º 1
0
        private static bool Hit(GameCharacter attacker, GameCharacter defender, BattleGame game, Ammo ammo)
        {
            int bonusDamage = 0;

            if (ammo != null)
            {
                bonusDamage = ammo.bonusDamage;

                if (ammo.activeEffects != null)
                {
                    foreach (var ae in ammo.activeEffects)
                    {
                        defender.AddActiveEffect(AbilityHelper.cloneActiveEffect(ae), game);
                    }
                }
            }

            int dmg = game.r.Next(attacker.weapon.minDamage, attacker.weapon.maxDamage) + bonusDamage;

            defender.Damage(dmg, game);

            game.battleLog.AddEntry(string.Format("{0} hit {1} for {2} damage.", attacker.name, defender.name, dmg));
            game.gameControllerScript.StartTempTextOnChar(defender, dmg, true);
            game.gameControllerScript.StartTempSpriteOnChar(defender, "DamageEffects", 1);

            if (attacker.weapon.activeEffects != null)
            {
                foreach (var ae in attacker.weapon.activeEffects)
                {
                    defender.AddActiveEffect(AbilityHelper.cloneActiveEffect(ae), game);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public bool UseItem(GameCharacter character, UsableItem item, Tile targetTile)
        {
            bool usedItem = false;

            if (!CoreHelper.checkEffect(character.activeEffects, character.passiveEffects, StatType.Stun))
            {
                if (character.CheckAP(item.actionPoints))
                {
                    if (item.activeEffects != null)
                    {
                        foreach (var a in item.activeEffects)
                        {
                            character.AddActiveEffect(a, this);
                        }
                        usedItem = true;
                        character.SpendAP(item.actionPoints);
                        item.uses--;
                    }

                    else if (item.itemAbility != null)
                    {
                        bool usedAbility = AbilityHelper.UseAbility(ActiveCharacter, item.itemAbility, targetTile, this);
                        if (usedAbility)
                        {
                            usedItem = true;
                            character.SpendAP(item.actionPoints);
                            item.uses--;
                        }
                    }

                    if (item.uses <= 0)
                    {
                        //should this logic be here?
                        battleLog.AddEntry(string.Format("{0} has no more uses.", item.name));

                        ActiveCharacter.removeUsableItem(item);
                        //ActiveCharacter.inventory.Remove(item);
                    }
                }

                if (usedItem)
                {
                    battleLog.AddEntry(string.Format("{0} used item {1}", character.name, item.name));
                    return(true);
                }
                else
                {
                    battleLog.AddEntry(string.Format("{0} was unable to use item {1}", character.name, item.name));
                    return(false);
                }
            }
            else
            {
                battleLog.AddEntry(string.Format("{0} is stunned and unable to use {1}.", character.name, item.name));
            }

            return(false);
        }
Ejemplo n.º 3
0
        private static bool Hit(GameCharacter attacker, GameCharacter defender, BattleGame game, Ammo ammo)
        {
            int bonusDamage = 0;
            if(ammo != null)
            {
                bonusDamage = ammo.bonusDamage;

                if (ammo.activeEffects != null)
                {
                    foreach (var ae in ammo.activeEffects)
                    {
                        defender.AddActiveEffect(AbilityHelper.cloneActiveEffect(ae), game);
                    }
                }
            }

            int dmg = game.r.Next(attacker.weapon.minDamage, attacker.weapon.maxDamage) + bonusDamage;

            defender.Damage(dmg, game);

            game.battleLog.AddEntry(string.Format("{0} hit {1} for {2} damage.", attacker.name, defender.name, dmg));
            game.gameControllerScript.StartTempTextOnChar(defender, dmg, true);
            game.gameControllerScript.StartTempSpriteOnChar(defender, "DamageEffects", 1);

            if(attacker.weapon.activeEffects != null)
            {
                foreach(var ae in attacker.weapon.activeEffects)
                {
                    defender.AddActiveEffect(AbilityHelper.cloneActiveEffect(ae), game);
                }
            }

            return true;
        }
Ejemplo n.º 4
0
        public bool UseItem(GameCharacter character, UsableItem item, Tile targetTile)
        {

            bool usedItem = false;

            if (!CoreHelper.checkEffect(character.activeEffects, character.passiveEffects, StatType.Stun))
            {
                if (character.CheckAP(item.actionPoints))
                {
                    if (item.activeEffects != null)
                    {
                        foreach (var a in item.activeEffects)
                        {
                            character.AddActiveEffect(a, this);
                        }
                        usedItem = true;
                        character.SpendAP(item.actionPoints);
                        item.uses--;
                    }

                    else if(item.itemAbility != null)
                    {
                        bool usedAbility = AbilityHelper.UseAbility(ActiveCharacter, item.itemAbility, targetTile, this);
                        if(usedAbility)
                        {
                            usedItem = true;
                            character.SpendAP(item.actionPoints);
                            item.uses--;
                        }
                    }

                    if (item.uses <= 0)
                    {
                        //should this logic be here?
                        battleLog.AddEntry(string.Format("{0} has no more uses.", item.name));

                        ActiveCharacter.removeUsableItem(item);
                        //ActiveCharacter.inventory.Remove(item);
                    }
                }
               
                if(usedItem)
                {
                    battleLog.AddEntry(string.Format("{0} used item {1}", character.name, item.name));
                    return true;
                }
                else
                {
                    battleLog.AddEntry(string.Format("{0} was unable to use item {1}", character.name, item.name));
                    return false;
                }
               
            }
            else{
                battleLog.AddEntry(string.Format("{0} is stunned and unable to use {1}.", character.name, item.name));
            }
            
            return false;

        }