public LogicCharacter CreateDuplicateCharacter(LogicCharacterData data, int upgLevel, int x, int y) { LogicCharacter character = (LogicCharacter)LogicGameObjectFactory.CreateGameObject(data, this.m_level, this.m_villageType); character.SetUpgradeLevel(upgLevel); character.SetDuplicate(true, this.GetSpellData().GetDuplicateLifetime(this.m_upgradeLevel) / 64 + 1); character.SetInitialPosition(x, y); if (data.IsJumper()) { character.GetMovementComponent().EnableJump(3600000); character.GetCombatComponent().RefreshTarget(true); } if (data.IsUnderground()) { LogicCombatComponent combatComponent = character.GetCombatComponent(); combatComponent.SetUndergroundTime(3600000); combatComponent.RefreshTarget(true); } if (LogicDataTables.IsSkeleton(data)) { LogicCombatComponent combatComponent = character.GetCombatComponent(); if (combatComponent != null) { combatComponent.SetSkeletonSpell(); } } this.GetGameObjectManager().AddGameObject(character, -1); // Listener. return(character); }
public LogicCharacter ClosestAttacker(bool flyingTroop) { LogicGameObjectManager gameObjectManager = this.m_parent.GetLevel().GetGameObjectManagerAt(0); LogicArrayList <LogicGameObject> gameObjects = gameObjectManager.GetGameObjects(LogicGameObjectType.CHARACTER); int closestDistance = 0x7fffffff; LogicCharacter closestCharacter = null; for (int i = 0; i < gameObjects.Size(); i++) { LogicCharacter character = (LogicCharacter)gameObjects[i]; LogicHitpointComponent hitpointComponent = character.GetHitpointComponent(); LogicCombatComponent combatComponent = character.GetCombatComponent(); bool deployTime = combatComponent != null && combatComponent.GetUndergroundTime() > 0; if (!deployTime && (LogicDataTables.GetGlobals().SkeletonOpenClanCastle() || !LogicDataTables.IsSkeleton(character.GetCharacterData()))) { if (hitpointComponent != null) { if (character.IsAlive() && character.IsFlying() == flyingTroop && hitpointComponent.GetTeam() == 0) { int distance = character.GetPosition().GetDistanceSquaredTo(this.m_parent.GetMidX(), this.m_parent.GetMidY()); if (distance < closestDistance) { closestDistance = distance; closestCharacter = character; } } } } } return(closestCharacter); }