public void CreateProjectile(LogicProjectileData data) { LogicTrapData trapData = this.GetTrapData(); LogicVector2 position = new LogicVector2(); LogicArrayList <LogicGameObject> characters = this.GetGameObjectManager().GetGameObjects(LogicGameObjectType.CHARACTER); LogicGameObject closestGameObject = null; for (int i = 0, minDistance = 0; i < characters.Size(); i++) { LogicCharacter character = (LogicCharacter)characters[i]; LogicHitpointComponent hitpointComponent = character.GetHitpointComponent(); if (hitpointComponent != null && hitpointComponent.GetTeam() == 0) { if (character.IsFlying() && character.IsAlive()) { int housingSpace = character.GetCharacterData().GetHousingSpace(); if (housingSpace >= trapData.GetMinTriggerHousingLimit() && character.GetChildTroops() == null) { if (trapData.GetHealerTrigger() || character.GetCombatComponent() == null || !character.GetCombatComponent().IsHealer()) { position.m_x = character.GetPosition().m_x - this.GetMidX(); position.m_y = character.GetPosition().m_y - this.GetMidY(); int lengthSquared = position.GetLengthSquared(); if (minDistance == 0 || lengthSquared < minDistance) { minDistance = lengthSquared; closestGameObject = character; } } } } } } position.Destruct(); if (closestGameObject != null) { LogicProjectile projectile = (LogicProjectile)LogicGameObjectFactory.CreateGameObject(data, this.m_level, this.m_villageType); projectile.SetInitialPosition(null, this.GetMidX(), this.GetMidY()); projectile.SetTarget(this.GetMidX(), this.GetMidY(), 0, closestGameObject, data.GetRandomHitPosition()); projectile.SetDamage(trapData.GetDamage(this.m_upgLevel)); projectile.SetDamageRadius(trapData.GetDamageRadius(this.m_upgLevel)); projectile.SetPushBack(trapData.GetPushback(), !trapData.GetDoNotScalePushByDamage()); projectile.SetMyTeam(1); projectile.SetHitEffect(trapData.GetDamageEffect(), null); this.GetGameObjectManager().AddGameObject(projectile, -1); } }
public void SelectDuplicableCharacters() { if (this.m_duplicableCharacters == null) { this.m_duplicableCharacters = new LogicArrayList <LogicGameObject>(20); } if (this.m_duplicateCharacters == null) { this.m_duplicateCharacters = new LogicArrayList <LogicGameObject>(20); } int radius = this.GetSpellData().GetRadius(this.m_upgradeLevel); LogicArrayList <LogicComponent> components = this.GetComponentManager().GetComponents(LogicComponentType.MOVEMENT); for (int i = 0; i < components.Size(); i++) { LogicMovementComponent movementComponent = (LogicMovementComponent)components[i]; LogicGameObject parent = movementComponent.GetParent(); if (parent.GetGameObjectType() == LogicGameObjectType.CHARACTER) { LogicCharacter character = (LogicCharacter)parent; LogicCharacterData characterData = character.GetCharacterData(); LogicHitpointComponent hitpointComponent = character.GetHitpointComponent(); if (hitpointComponent != null && hitpointComponent.GetTeam() == 0 && character.IsAlive() && !character.IsHero() && characterData.GetHousingSpace() <= this.m_duplicateHousingSpace) { int distanceX = character.GetPosition().m_x - this.GetMidX(); int distanceY = character.GetPosition().m_y - this.GetMidY(); if (LogicMath.Abs(distanceX) <= radius && LogicMath.Abs(distanceY) <= radius && distanceX * distanceX + distanceY * distanceY < (uint)(radius * radius)) { int idx = -1; for (int j = 0, size = this.m_duplicableCharacters.Size(); j < size; j++) { if (this.m_duplicableCharacters[j] == character) { idx = j; break; } } if (idx == -1) { this.m_duplicateCharacterData = characterData; this.m_duplicateCharacterUpgradeLevel = character.GetUpgradeLevel(); this.m_duplicableCharacters.Add(character); // Listener. } } } } } }
public void UpdateAutoMerge() { if (this.m_autoMergeTime > 0) { int autoMergeGroupSize = this.GetCharacterData().GetAutoMergeGroupSize(); int autoMergeDistance = this.GetCharacterData().GetAutoMergeDistance(); if (autoMergeGroupSize > 0) { LogicArrayList <LogicGameObject> characters = this.GetGameObjectManager().GetGameObjects(LogicGameObjectType.CHARACTER); LogicCharacter closestCharacter = null; for (int i = 0; i < characters.Size(); i++) { LogicCharacter character = (LogicCharacter)characters[i]; if (character != this) { if (character.GetData() == this.GetData()) { if (this.m_autoMergeSize == 0 && character.m_autoMergeSize >= autoMergeGroupSize) { if (character.GetHitpointComponent().GetTeam() == this.GetHitpointComponent().GetTeam() && character.IsAlive()) { if (character.m_autoMergeTime > 0) { int distanceSquared = this.GetPosition().GetDistanceSquared(character.GetPosition()); if (distanceSquared <= autoMergeDistance * autoMergeDistance) { closestCharacter = character; } } } } } } } if (closestCharacter != null) { closestCharacter.m_autoMergeSize += 1; closestCharacter.GetCombatComponent().SetMergeDamage(90 * closestCharacter.m_autoMergeSize); closestCharacter.GetHitpointComponent() .SetMaxHitpoints(closestCharacter.GetCharacterData().GetHitpoints(this.m_upgradeLevel) * (closestCharacter.m_autoMergeSize + 1)); closestCharacter.GetHitpointComponent() .SetHitpoints(closestCharacter.GetCharacterData().GetHitpoints(this.m_upgradeLevel) * (closestCharacter.m_autoMergeSize + 1)); this.GetGameObjectManager().RemoveGameObject(this); } } } }