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); } }