public override void Decode(ByteStream stream) { this.m_newUnitData = (LogicCharacterData)ByteStreamHelper.ReadDataReference(stream, LogicDataType.CHARACTER); this.m_oldUnitData = (LogicCharacterData)ByteStreamHelper.ReadDataReference(stream, LogicDataType.CHARACTER); base.Decode(stream); }
public override void Destruct() { base.Destruct(); this.m_oldUnitData = null; this.m_newUnitData = null; }
public override void LoadFromJSON(LogicJSONObject jsonRoot) { LogicJSONObject baseObject = jsonRoot.GetJSONObject("base"); if (baseObject == null) { Debugger.Error("Replay LogicPlaceAttackerCommand load failed! Base missing!"); } base.LoadFromJSON(baseObject); LogicJSONNumber dataNumber = jsonRoot.GetJSONNumber("d"); if (dataNumber != null) { this.m_data = (LogicCharacterData)LogicDataTables.GetDataById(dataNumber.GetIntValue(), LogicDataType.CHARACTER); } if (this.m_data == null) { Debugger.Error("Replay LogicPlaceAttackerCommand load failed! Character is NULL!"); } this.m_x = jsonRoot.GetJSONNumber("x").GetIntValue(); this.m_y = jsonRoot.GetJSONNumber("y").GetIntValue(); }
public override void LoadFromJSON(LogicJSONObject jsonRoot) { LogicJSONObject baseObject = jsonRoot.GetJSONObject("base"); if (baseObject == null) { Debugger.Error("Replay LogicChangeUnitVillage2Command load failed! Base missing!"); } base.LoadFromJSON(baseObject); LogicJSONNumber newDataNumber = jsonRoot.GetJSONNumber("n"); if (newDataNumber != null) { this.m_newUnitData = (LogicCharacterData)LogicDataTables.GetDataById(newDataNumber.GetIntValue(), LogicDataType.CHARACTER); } LogicJSONNumber oldDataNumber = jsonRoot.GetJSONNumber("o"); if (oldDataNumber != null) { this.m_oldUnitData = (LogicCharacterData)LogicDataTables.GetDataById(oldDataNumber.GetIntValue(), LogicDataType.CHARACTER); } }
public override void Decode(ByteStream stream) { this.m_x = stream.ReadInt(); this.m_y = stream.ReadInt(); this.m_data = (LogicCharacterData)ByteStreamHelper.ReadDataReference(stream, LogicDataType.CHARACTER); base.Decode(stream); }
/// <summary> /// Decodes this instnace. /// </summary> public override void Decode(ByteStream stream) { this._x = stream.ReadInt(); this._y = stream.ReadInt(); this._data = (LogicCharacterData)stream.ReadDataReference(3); base.Decode(stream); }
/// <summary> /// Initializes a new instance of the <see cref="LogicCharacter" /> class. /// </summary> public LogicCharacter(LogicData data, LogicLevel level, int villageType) : base(data, level, villageType) { LogicCharacterData characterData = (LogicCharacterData)data; this.AddComponent(new LogicHitpointComponent(this, characterData.GetHitpoints(0), 0)); this.AddComponent(new LogicCombatComponent(this)); this.AddComponent(new LogicMovementComponent(this, characterData.GetSpeed(), characterData.IsHealerTrigger(), characterData.IsUnderground())); this.SetUpgradeLevel(0); }
public void SetDefenceTroops(LogicCharacterData defenceTroopCharacter1, LogicCharacterData defenceTroopCharacter2, int defenceTroopCount, int defenceTroopLevel, int defenseTroopCooldownSecs) { this.m_defenceTroopData[0] = defenceTroopCharacter1; this.m_defenceTroopData[1] = defenceTroopCharacter2; this.m_maxDefenceTroopCount = defenceTroopCount; this.m_defenceTroopUpgradeLevel = defenceTroopLevel; this.m_defenceTroopCooldownSecs = defenseTroopCooldownSecs; }
public static void AddDebugTroopsPreset(LogicLevel level, int townHallLevel, LogicClientAvatar playerAvatar) { if (playerAvatar != null) { LogicDataTable characterTable = LogicDataTables.GetTable(LogicDataType.CHARACTER); LogicDataTable spellTable = LogicDataTables.GetTable(LogicDataType.SPELL); LogicBuildingData laboratoryData = LogicDataTables.GetBuildingByName("Laboratory", null); int laboratoryLevel = laboratoryData.GetMaxUpgradeLevelForTownHallLevel(townHallLevel); int totalHousing = LogicDebugUtil.GetTotalCharacterMaxHousing(townHallLevel, true) / 5; for (int i = 0; i < characterTable.GetItemCount(); i++) { playerAvatar.SetUnitCount((LogicCharacterData)characterTable.GetItemAt(i), 0); } for (int i = 0; i < spellTable.GetItemCount(); i++) { playerAvatar.SetUnitCount((LogicSpellData)spellTable.GetItemAt(i), 0); } for (int i = 0; i < 7; i++) { if (i != 2 && i != 5) { LogicCharacterData characterData = (LogicCharacterData)characterTable.GetItemAt(i); if (characterData.GetVillageType() == 0) { int upgradeLevel = 0; for (int j = characterData.GetUpgradeLevelCount(); j >= 2; j--) { int requiredLaboratoryLevel = characterData.GetRequiredLaboratoryLevel(j - 1); if (laboratoryLevel >= requiredLaboratoryLevel) { upgradeLevel = j - 1; break; } } playerAvatar.SetUnitCount(characterData, totalHousing / characterData.GetHousingSpace()); playerAvatar.SetUnitUpgradeLevel(characterData, upgradeLevel); } } } } else { Debugger.Warning("addDebugTroopsPreset: pAvatar is NULL"); } }
public bool HasEnoughFreeHousingSpace() { LogicCalendar calendar = this.m_level.GetCalendar(); LogicAvatar homeOwnerAvatar = this.m_level.GetHomeOwnerAvatar(); LogicUnitProduction unitProduction = this.m_level.GetGameObjectManagerAt(0).GetUnitProduction(); LogicDataTable characterTable = LogicDataTables.GetTable(LogicDataType.CHARACTER); int freeHousingSpace = unitProduction.GetMaxTrainCount() - (homeOwnerAvatar.GetUnitsTotalCapacity() - unitProduction.GetTotalCount()); int requiredHousingSpace = 0; for (int i = 0; i < characterTable.GetItemCount(); i++) { LogicCharacterData data = (LogicCharacterData)characterTable.GetItemAt(i); if (calendar.IsProductionEnabled(data) && !data.IsSecondaryTroop()) { int count = homeOwnerAvatar.GetUnitPresetCount(data, this.m_presetId); if (count > 0) { requiredHousingSpace += data.GetHousingSpace() * count; } } } if (requiredHousingSpace <= freeHousingSpace) { LogicUnitProduction spellProduction = this.m_level.GetGameObjectManagerAt(0).GetSpellProduction(); LogicDataTable spellTable = LogicDataTables.GetTable(LogicDataType.SPELL); int freeSpellHousingSpace = spellProduction.GetMaxTrainCount() - (homeOwnerAvatar.GetSpellsTotalCapacity() - spellProduction.GetTotalCount()); int requiredSpellHousingSpace = 0; for (int i = 0; i < spellTable.GetItemCount(); i++) { LogicSpellData data = (LogicSpellData)spellTable.GetItemAt(i); if (calendar.IsProductionEnabled(data)) { int count = homeOwnerAvatar.GetUnitPresetCount(data, this.m_presetId); if (count > 0) { requiredSpellHousingSpace += data.GetHousingSpace() * count; } } } return(requiredSpellHousingSpace <= freeSpellHousingSpace); } return(false); }
public void TrainUnits() { LogicAvatar homeOwnerAvatar = this.m_level.GetHomeOwnerAvatar(); LogicDataTable characterTable = LogicDataTables.GetTable(LogicDataType.CHARACTER); LogicDataTable spellTable = LogicDataTables.GetTable(LogicDataType.SPELL); LogicArrayList <LogicCombatItemData> productionUnits = new LogicArrayList <LogicCombatItemData>(characterTable.GetItemCount()); LogicArrayList <LogicCombatItemData> productionSpells = new LogicArrayList <LogicCombatItemData>(spellTable.GetItemCount()); for (int i = 0; i < characterTable.GetItemCount(); i++) { LogicCharacterData data = (LogicCharacterData)characterTable.GetItemAt(i); if (this.m_level.GetCalendar().IsProductionEnabled(data) && !data.IsSecondaryTroop()) { productionUnits.Add(data); } } this.SortProduction(productionUnits); for (int i = 0; i < productionUnits.Size(); i++) { int unitCount = homeOwnerAvatar.GetUnitPresetCount(productionUnits[i], this.m_presetId); if (unitCount > 0) { this.AddUnitsToQueue(productionUnits[i], unitCount); } } for (int i = 0; i < spellTable.GetItemCount(); i++) { LogicSpellData data = (LogicSpellData)spellTable.GetItemAt(i); if (this.m_level.GetCalendar().IsProductionEnabled(data)) { productionSpells.Add(data); } } this.SortProduction(productionSpells); for (int i = 0; i < productionSpells.Size(); i++) { int spellCount = homeOwnerAvatar.GetUnitPresetCount(productionSpells[i], this.m_presetId); if (spellCount > 0) { this.AddUnitsToQueue(productionSpells[i], spellCount); } } }
public int GetMaxUnitsInCamp(LogicCharacterData data) { LogicAvatar homeOwnerAvatar = this.m_parent.GetLevel().GetHomeOwnerAvatar(); if (homeOwnerAvatar != null) { return(data.GetUnitsInCamp(homeOwnerAvatar.GetUnitUpgradeLevel(data))); } Debugger.Error("AVATAR = NULL"); return(0); }
public void AddRewardUnits() { LogicCharacterData characterData = this.m_data.GetRewardCharacterData(); if (characterData != null) { int characterCount = this.m_data.GetRewardCharacterCount(); if (characterCount > 0) { LogicClientAvatar playerAvatar = this.m_level.GetPlayerAvatar(); LogicComponentFilter filter = new LogicComponentFilter(); for (int i = 0; i < characterCount; i++) { filter.RemoveAllIgnoreObjects(); while (true) { LogicUnitStorageComponent component = (LogicUnitStorageComponent)this.m_level.GetComponentManagerAt(this.m_level.GetVillageType()).GetClosestComponent(0, 0, filter); if (component != null) { if (component.CanAddUnit(characterData)) { playerAvatar.CommodityCountChangeHelper(0, characterData, 1); component.AddUnit(characterData); if (this.m_level.GetState() == 1 || this.m_level.GetState() == 3) { if (component.GetParentListener() != null) { component.GetParentListener().ExtraCharacterAdded(characterData, null); } } break; } filter.AddIgnoreObject(component.GetParent()); } else { break; } } } } } }
/// <summary> /// Gets the max unit count. /// </summary> public int GetMaxCapacity() { LogicAvatar homeOwnerAvatar = this._parent.GetLevel().GetHomeOwnerAvatar(); LogicCharacterData characterData = (LogicCharacterData)this._unit.GetData(); if (homeOwnerAvatar != null) { return(characterData.GetUnitsInCamp(homeOwnerAvatar.GetUnitUpgradeLevel(characterData))); } Debugger.Error("AVATAR = NULL"); return(0); }
public int GetResourceCost(LogicResourceData resourceData) { int cost = 0; LogicAvatar homeOwnerAvatar = this.m_level.GetHomeOwnerAvatar(); LogicCalendar calendar = this.m_level.GetCalendar(); LogicDataTable table = LogicDataTables.GetTable(LogicDataType.CHARACTER); for (int i = 0; i < table.GetItemCount(); i++) { LogicCharacterData data = (LogicCharacterData)table.GetItemAt(i); if (calendar.IsProductionEnabled(data) && !data.IsSecondaryTroop()) { int count = homeOwnerAvatar.GetUnitPresetCount(data, this.m_presetId); if (count > 0) { if (data.GetTrainingResource() == resourceData) { cost += count * calendar.GetTrainingCost(data, homeOwnerAvatar.GetUnitUpgradeLevel(data)); } } } } table = LogicDataTables.GetTable(LogicDataType.SPELL); for (int i = 0; i < table.GetItemCount(); i++) { LogicSpellData data = (LogicSpellData)table.GetItemAt(i); if (calendar.IsProductionEnabled(data)) { int count = homeOwnerAvatar.GetUnitPresetCount(data, this.m_presetId); if (count > 0) { if (data.GetTrainingResource() == resourceData) { cost += count * calendar.GetTrainingCost(data, homeOwnerAvatar.GetUnitUpgradeLevel(data)); } } } } return(cost); }
public void AlianceUnitDonated(LogicCharacterData data) { if (data != null) { LogicClientAvatar playerAvatar = this.m_level.GetPlayerAvatar(); LogicDataTable dataTable = LogicDataTables.GetTable(LogicDataType.ACHIEVEMENT); for (int i = 0; i < dataTable.GetItemCount(); i++) { LogicAchievementData achievementData = (LogicAchievementData)dataTable.GetItemAt(i); if (achievementData.GetActionType() == LogicAchievementData.ACTION_TYPE_DONATE_UNITS) { this.RefreshAchievementProgress(playerAvatar, achievementData, playerAvatar.GetAchievementProgress(achievementData) + data.GetHousingSpace()); } } } }
public override void DeathEvent() { LogicHitpointComponent hitpointComponent = this.GetHitpointComponent(); LogicCharacterData data = this.GetCharacterData(); if (hitpointComponent != null && hitpointComponent.GetTeam() == 1 && !this.IsHero() && !data.IsSecondaryTroop() && this.m_level.GetVillageType() == 0 && this.m_allianceUnit) { LogicAvatar homeOwnerAvatar = this.m_level.GetHomeOwnerAvatar(); homeOwnerAvatar.RemoveAllianceUnit(data, this.m_upgradeLevel); homeOwnerAvatar.GetChangeListener().AllianceUnitRemoved(data, this.m_upgradeLevel); } if (data.GetSpecialAbilityType() != LogicCharacterData.SPECIAL_ABILITY_TYPE_RESPAWN_AS_CANNON || data.GetSpecialAbilityLevel(this.m_upgradeLevel) <= 0) { if (data.GetSpecialAbilityType() == LogicCharacterData.SPECIAL_ABILITY_TYPE_SPAWN_UNITS) { if (data.GetSpecialAbilityLevel(this.m_upgradeLevel) > 0) { this.CheckSpawning(null, data.GetSpecialAbilityAttribute(this.m_upgradeLevel), 0, 0); } } else if (data.GetSecondaryTroop() != null) { this.CheckSpawning(null, 0, 0, 0); } } else if (!this.m_ejected) { this.CheckSpawning(LogicDataTables.GetCharacterByName("MovingCannonSecondary", null), 1, data.GetSpecialAbilityAttribute(this.m_upgradeLevel), 500); } this.AddTombstoneIfNeeded(); if (this.m_parent != null) { this.m_parent.RemoveChildren(this); this.m_parent = null; } base.DeathEvent(); }
private void SpawnCharacter(int x, int y) { int idx = this.m_defenceTroopCount % 2; if (this.m_defenceTroopData[idx] == null) { idx = 0; } LogicBuilding building = (LogicBuilding)this.m_parent; LogicBuildingData buildingData = building.GetBuildingData(); if (buildingData.IsEnabledInVillageType(this.m_parent.GetLevel().GetVillageType()) && this.m_parent.GetLevel().GetState() != 1 && this.m_parent.GetLevel().GetState() != 4) { LogicCharacterData data = this.m_defenceTroopData[idx]; LogicCharacter character = (LogicCharacter)LogicGameObjectFactory.CreateGameObject(data, this.m_parent.GetLevel(), this.m_parent.GetVillageType()); character.SetInitialPosition(x, y); character.SetUpgradeLevel(this.m_defenceTroopUpgradeLevel - 1); character.GetHitpointComponent()?.SetTeam(1); if (LogicDataTables.GetGlobals().EnableDefendingAllianceTroopJump()) { character.GetMovementComponent().EnableJump(3600000); } this.m_parent.GetGameObjectManager().AddGameObject(character, -1); character.GetCombatComponent().SetSearchRadius(LogicDataTables.GetGlobals().GetClanCastleRadius() >> 9); character.GetMovementComponent().GetMovementSystem().CreatePatrolArea(this.m_parent, this.m_parent.GetLevel(), true, this.m_defenceTroopCount); LogicDefenceUnitProductionComponent defenceUnitProductionComponent = building.GetDefenceUnitProduction(); if (defenceUnitProductionComponent != null) { defenceUnitProductionComponent.m_defenceTroops.Add(character); } ++this.m_defenceTroopCount; } }
public void SpawnUnit(int count) { LogicTrapData data = this.GetTrapData(); LogicCharacterData spawnData = this.m_useAirMode[this.m_level.GetActiveLayout(this.m_villageType)] ? data.GetSpawnedCharAir() : data.GetSpawnedCharGround(); if (spawnData != null) { LogicVector2 position = new LogicVector2(); for (int i = 0, j = 59, k = 0, l = 0; i < count; i++, j += 59, k += 128, l += 360) { int random = l / data.GetNumSpawns(this.m_upgLevel) + j * this.m_numSpawns % 360; int randomX = (byte)(k & 0x80) ^ 0x180; int posX = this.GetMidX() + LogicMath.GetRotatedX(randomX, 0, random); int posY = this.GetMidY() + LogicMath.GetRotatedY(randomX, 0, random); if (spawnData.IsFlying()) { position.m_x = posX; position.m_y = posY; } else { if (!this.m_level.GetTileMap().GetNearestPassablePosition(posX, posY, position, 1536)) { continue; } } LogicCharacter character = (LogicCharacter)LogicGameObjectFactory.CreateGameObject(spawnData, this.m_level, this.m_villageType); character.GetHitpointComponent().SetTeam(1); character.GetMovementComponent().EnableJump(3600000); character.SetInitialPosition(position.m_x, position.m_y); character.SetSpawnTime(200); this.GetGameObjectManager().AddGameObject(character, -1); } position.Destruct(); } }
public bool GetSpecialAbilityAvailable() { LogicCharacterData data = this.GetCharacterData(); if (data.GetSpecialAbilityLevel(this.m_upgradeLevel) <= 0) { return(false); } switch (data.GetSpecialAbilityType()) { case LogicCharacterData.SPECIAL_ABILITY_TYPE_BIG_FIRST_HIT: return(this.GetCombatComponent().GetHitCount() <= 0); case LogicCharacterData.SPECIAL_ABILITY_TYPE_SPECIAL_PROJECTILE: return(this.GetCombatComponent().GetHitCount() < data.GetSpecialAbilityAttribute(this.m_upgradeLevel)); } return(true); }
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); }
public void ObjectClose(LogicGameObject gameObject) { LogicHitpointComponent hitpointComponent = gameObject.GetHitpointComponent(); if (hitpointComponent == null || hitpointComponent.GetTeam() != 1) { if (gameObject.GetGameObjectType() == LogicGameObjectType.CHARACTER) { LogicCharacter character = (LogicCharacter)gameObject; LogicCharacterData data = character.GetCharacterData(); if (data.GetHousingSpace() < this.m_minTriggerHousingLimit) { return; } } LogicCombatComponent combatComponent = gameObject.GetCombatComponent(); if (combatComponent == null || combatComponent.GetUndergroundTime() <= 0) { if ((!gameObject.IsFlying() || this.m_airTrigger) && (gameObject.IsFlying() || this.m_groundTrigger)) { if (this.m_healerTrigger || combatComponent == null || !combatComponent.IsHealer()) { int distanceX = gameObject.GetX() - this.m_parent.GetMidX(); int distanceY = gameObject.GetY() - this.m_parent.GetMidY(); if (LogicMath.Abs(distanceX) <= this.m_triggerRadius && LogicMath.Abs(distanceY) <= this.m_triggerRadius && distanceX * distanceX + distanceY * distanceY < (uint)(this.m_triggerRadius * this.m_triggerRadius)) { this.Trigger(); } } } } } }
public bool DuplicateCharacter() { if (this.m_duplicateHousingSpace < 0) { this.m_duplicateHousingSpace = this.GetSpellData().GetDuplicateHousing(this.m_upgradeLevel); } if (this.m_duplicableCharacters != null) { if (this.m_duplicableCharacters.Size() > 0) { int minHousingSpace = ((LogicCharacter)this.m_duplicableCharacters[0]).GetCharacterData().GetHousingSpace(); for (int i = 0; i < this.m_duplicableCharacters.Size(); i++) { LogicCharacter character = (LogicCharacter)this.m_duplicableCharacters[(i + this.m_duplicateCharacterOffset) % this.m_duplicableCharacters.Size()]; LogicCharacterData data = character.GetCharacterData(); int housingSpace = data.GetHousingSpace(); if (minHousingSpace > housingSpace) { minHousingSpace = housingSpace; } if (this.DuplicateCharacter(data, character.GetUpgradeLevel())) { return(true); } } return(false); } return(this.DuplicateCharacter(this.m_duplicateCharacterData, this.m_duplicateCharacterUpgradeLevel)); } return(this.m_duplicateCharacterData != null && this.DuplicateCharacter(this.m_duplicateCharacterData, this.m_duplicateCharacterUpgradeLevel)); }
public static float GetCharacterStrength(LogicCharacterData data, int upgLevel) { if (data.IsProductionEnabled()) { float attackStrength = data.GetHitpoints(upgLevel) * 0.04f + LogicMath.Abs(data.GetAttackerItemData(upgLevel).GetDamagePerMS(0, false)) * 0.2f; if (data.GetUnitsInCamp(upgLevel) > 0 && data.GetUnitsInCamp(0) > 0) { attackStrength = (float)data.GetUnitsInCamp(upgLevel) / data.GetUnitsInCamp(0) * attackStrength; } for (int i = data.GetSpecialAbilityLevel(upgLevel); i > 0; i--) { attackStrength *= 1.1f; } return(attackStrength * 0.01f * data.GetStrengthWeight(upgLevel) / data.GetHousingSpace() * 10f); } return(0f); }
/// <summary> /// Places the specified attacker. /// </summary> 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()); Int32 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()); } } character.SetUpgradeLevel(upgradeLevel); character.SetInitialPosition(x, y); return(character); }
public void AddUnit(LogicCharacterData data, int count) { int index = -1; for (int i = 0; i < this.m_unitCount.Size(); i++) { if (this.m_unitCount[i].GetData() == data) { index = i; break; } } if (index != -1) { this.m_unitCount[index].SetCount(this.m_unitCount[index].GetCount() + count); } else { this.m_unitCount.Add(new LogicDataSlot(data, count)); } }
public void CheckDieDamage(int damage, int radius) { LogicCharacterData data = (LogicCharacterData)this.m_data; if (data.GetSpecialAbilityType() == LogicCharacterData.SPECIAL_ABILITY_TYPE_DIE_DAMAGE) { if (data.GetSpecialAbilityLevel(this.m_upgradeLevel) <= 0) { return; } } if (damage > 0 && radius > 0) { LogicHitpointComponent hitpointComponent = this.GetHitpointComponent(); if (hitpointComponent != null) { this.m_level.AreaDamage(0, this.GetX(), this.GetY(), radius, damage, null, 0, null, hitpointComponent.GetTeam(), null, 1, 0, 0, true, false, 100, 0, this, 100, 0); } } }
public void DebugVillage2UnitAdded(bool updateComponents) { LogicAvatar homeOwnerAvatar = this.m_level.GetHomeOwnerAvatar(); if (homeOwnerAvatar != null) { if (updateComponents) { LogicArrayList <LogicComponent> components = this.m_components[(int)LogicComponentType.VILLAGE2_UNIT]; LogicArrayList <LogicDataSlot> units = homeOwnerAvatar.GetUnitsVillage2(); for (int i = 0; i < LogicMath.Min(components.Size(), units.Size()); i++) { LogicVillage2UnitComponent component = (LogicVillage2UnitComponent)components[i]; LogicDataSlot unitSlot = units[i]; LogicCharacterData characterData = (LogicCharacterData)unitSlot.GetData(); component.RemoveUnits(); component.SetUnit(characterData, component.GetMaxUnitsInCamp(characterData)); } } } }
public bool DuplicateCharacter(LogicCharacterData data, int upgLevel) { if (data != null) { int tick = this.m_level.GetLogicTime().GetTick(); int offset = 75 * this.GetSpellData().GetRadius(this.m_upgradeLevel) / 100 * (tick % 100) / 100; int posX = this.GetX() + ((offset * LogicMath.Sin(tick * 21 + 7 * this.m_duplicateCharacterPositionOffset)) >> 10); int posY = this.GetY() + ((offset * LogicMath.Cos(tick * 21 + 7 * this.m_duplicateCharacterPositionOffset)) >> 10); bool posNotFound = false; if (!data.IsFlying()) { posNotFound = !LogicGamePlayUtil.FindGoodDuplicatePosAround(this.m_level, posX, posY, out int outputX, out int outputY, 10); posX = outputX; posY = outputY; } if (!posNotFound) { if (this.m_duplicateHousingSpace >= data.GetHousingSpace()) { this.m_duplicateHousingSpace -= data.GetHousingSpace(); this.m_duplicateCharacters.Add(this.CreateDuplicateCharacter(data, upgLevel, posX, posY)); ++this.m_duplicateCharacterOffset; ++this.m_duplicateCharacterPositionOffset; return(true); } } } return(false); }
public LogicCharacter(LogicGameObjectData data, LogicLevel level, int villageType) : base(data, level, villageType) { LogicCharacterData characterData = (LogicCharacterData)data; this.m_flying = characterData.IsFlying(); this.AddComponent(new LogicHitpointComponent(this, characterData.GetHitpoints(0), 0)); this.AddComponent(new LogicCombatComponent(this)); this.AddComponent(new LogicMovementComponent(this, characterData.GetSpeed(), characterData.IsFlying(), characterData.IsUnderground())); this.SetUpgradeLevel(0); int childTroopCount = characterData.GetChildTroopCount(); if (childTroopCount > 0) { this.m_childrens = new LogicArrayList <LogicCharacter>(childTroopCount); for (int i = 0; i < childTroopCount; i++) { LogicCharacter character = new LogicCharacter(characterData.GetChildTroop(), level, villageType); character.SetTroopChild(this, i); character.GetCombatComponent().SetTroopChild(true); this.m_childrens.Add(character); this.GetGameObjectManager().AddGameObject(character, -1); } } this.m_ejectPosition = new LogicVector2(); this.m_summonTroops = new LogicArrayList <LogicCharacter>(); if (characterData.IsUnderground()) { this.GetCombatComponent().SetUndergroundTime(3600000); } }