示例#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);
        }
        public static LogicCharacter PlaceHero(LogicHeroData data, LogicLevel level, int x, int y, int hitpoints, int upgLevel)
        {
            LogicCharacter character = (LogicCharacter)LogicGameObjectFactory.CreateGameObject(data, level, level.GetVillageType());

            character.SetUpgradeLevel(upgLevel);
            character.GetHitpointComponent().SetHitpoints(hitpoints);
            character.SetInitialPosition(x, y);

            if (data.IsJumper())
            {
                character.GetMovementComponent().EnableJump(3600000);
                character.GetCombatComponent().RefreshTarget(true);
            }

            level.GetGameObjectManager().AddGameObject(character, -1);
            level.GetGameListener().AttackerPlaced(data);

            LogicBattleLog battleLog = level.GetBattleLog();

            if (battleLog != null)
            {
                battleLog.IncrementDeployedAttackerUnits(data, 1);
                battleLog.SetCombatItemLevel(data, upgLevel);
            }

            return(character);
        }
示例#3
0
        public static LogicCharacter PlaceAttacker(LogicAvatar avatar, LogicCharacterData characterData, LogicLevel level, int x, int y)
        {
            avatar.CommodityCountChangeHelper(level.GetVillageType() == 1 ? 7 : 0, characterData, -1);

            LogicCharacter character    = (LogicCharacter)LogicGameObjectFactory.CreateGameObject(characterData, level, level.GetVillageType());
            int            upgradeLevel = avatar.GetUnitUpgradeLevel(characterData);

            if (level.GetMissionManager().GetMissionByCategory(2) != null && level.GetVillageType() == 1 && level.GetHomeOwnerAvatar() != null)
            {
                LogicAvatar homeOwnerAvatar = level.GetHomeOwnerAvatar();

                if (homeOwnerAvatar.IsNpcAvatar())
                {
                    upgradeLevel = LogicMath.Clamp(LogicDataTables.GetGlobals().GetVillage2StartUnitLevel(), 0, characterData.GetUpgradeLevelCount() - 1);
                }
            }

            character.SetUpgradeLevel(upgradeLevel);
            character.SetInitialPosition(x, y);

            if (characterData.IsJumper())
            {
                character.GetMovementComponent().EnableJump(3600000);
                character.GetCombatComponent().RefreshTarget(true);
            }

            level.GetGameObjectManager().AddGameObject(character, -1);
            level.GetGameListener().AttackerPlaced(characterData);

            LogicBattleLog battleLog = level.GetBattleLog();

            if (battleLog != null)
            {
                battleLog.IncrementDeployedAttackerUnits(characterData, 1);
                battleLog.SetCombatItemLevel(characterData, upgradeLevel);
            }

            character.UpdateAutoMerge();
            return(character);
        }