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(); }
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 void SetUpgradeLevel(int upgLevel) { this.m_upgradeLevel = upgLevel; LogicCharacterData data = this.GetCharacterData(); LogicHitpointComponent hitpointComponent = this.GetHitpointComponent(); LogicCombatComponent combatComponent = this.GetCombatComponent(); int hp = data.GetHitpoints(upgLevel); int damagePercentage = 100; if (data.GetScaleByTH()) { LogicAvatar avatar = this.m_level.GetHomeOwnerAvatar(); if (hitpointComponent != null && hitpointComponent.GetTeam() == 0) { avatar = this.m_level.GetVisitorAvatar(); } int tmp1 = 700 * avatar.GetTownHallLevel() / (LogicDataTables.GetTownHallLevelCount() - 1); damagePercentage = tmp1 / 10 + 30; hp = damagePercentage * hp / 100; if (damagePercentage * hp < 200) { hp = 1; } if (tmp1 < -289) { damagePercentage = 1; } } hitpointComponent.SetMaxHitpoints(hp); hitpointComponent.SetHitpoints(data.GetHitpoints(upgLevel)); hitpointComponent.SetDieEffect(data.GetDieEffect(upgLevel), data.GetDieEffect2(upgLevel)); if (combatComponent != null) { combatComponent.SetAttackValues(data.GetAttackerItemData(upgLevel), damagePercentage); } if (this.m_childrens != null) { for (int i = 0; i < this.m_childrens.Size(); i++) { this.m_childrens[i].SetUpgradeLevel(upgLevel); } } if (this.IsHero()) { LogicHeroData heroData = (LogicHeroData)this.m_data; LogicAvatar avatar = this.m_level.GetHomeOwnerAvatar(); if (hitpointComponent.GetTeam() == 0) { avatar = this.m_level.GetVisitorAvatar(); } this.m_flying = heroData.IsFlying(avatar.GetHeroMode(heroData)); this.GetMovementComponent().SetFlying(this.m_flying); } if (data.GetAutoMergeDistance() > 0) { this.m_autoMergeTime = 2000; } int speed = data.GetSpeed(); if (data.GetSpecialAbilityLevel(this.m_upgradeLevel) > 0 && data.GetSpecialAbilityType() == LogicCharacterData.SPECIAL_ABILITY_TYPE_SPEED_BOOST) { speed = speed * data.GetSpecialAbilityAttribute(this.m_upgradeLevel) / 100; } this.GetMovementComponent().SetSpeed(speed); }