Exemple #1
0
        public static LogicSpell CastSpell(LogicAvatar avatar, LogicSpellData spellData, bool allianceSpell, int upgLevel, LogicLevel level, int x, int y)
        {
            if (allianceSpell)
            {
                avatar.RemoveAllianceUnit(spellData, upgLevel);
            }
            else
            {
                avatar.CommodityCountChangeHelper(0, spellData, -1);
            }

            if (!allianceSpell)
            {
                upgLevel = avatar.GetUnitUpgradeLevel(spellData);
            }

            LogicSpell spell = (LogicSpell)LogicGameObjectFactory.CreateGameObject(spellData, level, level.GetVillageType());

            spell.SetUpgradeLevel(upgLevel);
            spell.SetInitialPosition(x, y);
            level.GetGameObjectManager().AddGameObject(spell, -1);
            level.GetGameListener().AttackerPlaced(spellData);

            LogicBattleLog battleLog = level.GetBattleLog();

            if (battleLog != null)
            {
                battleLog.IncrementCastedSpells(spellData, 1);
                battleLog.SetCombatItemLevel(spellData, upgLevel);
            }

            return(spell);
        }
        /// <summary>
        ///     Casts the specified spell.
        /// </summary>
        public static LogicSpell CastSpell(LogicAvatar avatar, LogicSpellData spellData, bool allianceSpell, int upgLevel, LogicLevel level, int x, int y)
        {
            if (allianceSpell)
            {
                avatar.RemoveAllianceUnit(spellData, upgLevel);
            }
            else
            {
                avatar.CommodityCountChangeHelper(0, spellData, -1);
            }

            LogicSpell spell = (LogicSpell)LogicGameObjectFactory.CreateGameObject(spellData, level, level.GetVillageType());

            spell.SetUpgradeLevel(upgLevel);
            return(spell);
        }