public void UpdateHeroHealthToAvatar(int hitpoint)
        {
            LogicAvatar   avatar = this.m_team == 1 ? this.m_parent.GetLevel().GetHomeOwnerAvatar() : this.m_parent.GetLevel().GetVisitorAvatar();
            LogicHeroData data   = null;

            int upgLevel = 0;

            if (this.m_parent.IsHero())
            {
                LogicCharacter character = (LogicCharacter)this.m_parent;

                data     = (LogicHeroData)character.GetCharacterData();
                upgLevel = character.GetUpgradeLevel();
            }
            else if (this.m_parent.GetGameObjectType() == LogicGameObjectType.BUILDING)
            {
                LogicBuilding          building          = (LogicBuilding)this.m_parent;
                LogicHeroBaseComponent heroBaseComponent = building.GetHeroBaseComponent();

                if (heroBaseComponent == null)
                {
                    return;
                }

                LogicBuildingData buildingData = building.GetBuildingData();

                if (!buildingData.GetShareHeroCombatData())
                {
                    return;
                }

                LogicCombatComponent combatComponent = building.GetCombatComponent();

                if (combatComponent == null || !combatComponent.IsEnabled())
                {
                    return;
                }

                data     = buildingData.GetHeroData();
                upgLevel = avatar.GetUnitUpgradeLevel(data);
            }

            if (data != null)
            {
                int secs = LogicMath.Min(data.GetSecondsToFullHealth(hitpoint, upgLevel), data.GetFullRegenerationTimeSec(upgLevel));

                if (avatar != null)
                {
                    avatar.GetChangeListener().CommodityCountChanged(0, data, secs);
                    avatar.SetHeroHealth(data, secs);
                }
            }
        }
        public override int Execute(LogicLevel level)
        {
            LogicArrayList <LogicGameObject> gameObjects = level.GetGameObjectManager().GetGameObjects(LogicGameObjectType.CHARACTER);

            for (int i = 0; i < gameObjects.Size(); i++)
            {
                LogicCharacter character = (LogicCharacter)gameObjects[i];

                if (character.GetHitpointComponent().GetTeam() == 0 && character.IsHero() && character.GetData() == this.m_data && character.GetHitpointComponent().GetHitpoints() > 0)
                {
                    if (this.m_data.HasAbility(character.GetUpgradeLevel()))
                    {
                        if (!this.m_data.HasOnceAbility() && character.GetAbilityCooldown() == 0 || this.m_data.HasOnceAbility() && !character.IsAbilityUsed())
                        {
                            character.StartAbility();
                        }
                    }
                }
            }

            return(0);
        }
Beispiel #3
0
        public override int Execute(LogicLevel level)
        {
            if (level.IsReadyForAttack())
            {
                int tileX = this.m_x >> 9;
                int tileY = this.m_y >> 9;

                if (level.GetTileMap().GetTile(tileX, tileY) != null)
                {
                    if (level.GetTileMap().IsPassablePathFinder(this.m_x >> 8, this.m_y >> 8))
                    {
                        if (level.GetTileMap().IsValidAttackPos(tileX, tileY))
                        {
                            LogicClientAvatar playerAvatar = level.GetPlayerAvatar();

                            if (playerAvatar != null)
                            {
                                int unitCount = level.GetVillageType() == 1 ? playerAvatar.GetUnitCountVillage2(this.m_data) : playerAvatar.GetUnitCount(this.m_data);

                                if (unitCount > 0)
                                {
                                    if (level.GetBattleLog() != null)
                                    {
                                        if (!level.GetBattleLog().HasDeployedUnits() && level.GetTotalAttackerHeroPlaced() == 0)
                                        {
                                            level.UpdateLastUsedArmy();
                                        }
                                    }

                                    if (level.GetGameMode().IsInAttackPreparationMode())
                                    {
                                        level.GetGameMode().EndAttackPreparation();
                                    }

                                    LogicCharacter character = LogicPlaceAttackerCommand.PlaceAttacker(playerAvatar, this.m_data, level, this.m_x, this.m_y);

                                    if (character != null && character.HasSpecialAbility())
                                    {
                                        if (this.m_data.GetSpecialAbilityType() == LogicCharacterData.SPECIAL_ABILITY_TYPE_START_RAGE)
                                        {
                                            LogicSpellData specialAbilitySpellData = this.m_data.GetSpecialAbilitySpell();

                                            level.BoostGameObject(character, specialAbilitySpellData.GetSpeedBoost(0), specialAbilitySpellData.GetSpeedBoost2(0),
                                                                  specialAbilitySpellData.GetDamageBoostPercent(0), specialAbilitySpellData.GetAttackSpeedBoost(0),
                                                                  60 * this.m_data.GetSpecialAbilityAttribute(character.GetUpgradeLevel()),
                                                                  specialAbilitySpellData.GetBoostLinkedToPoison());
                                        }
                                        else if (this.m_data.GetSpecialAbilityType() == LogicCharacterData.SPECIAL_ABILITY_TYPE_START_CLOAK)
                                        {
                                            character.SetStealthTime(15 * this.m_data.GetSpecialAbilityAttribute(character.GetUpgradeLevel()));
                                        }
                                    }

                                    return(0);
                                }

                                return(-7);
                            }

                            return(-5);
                        }

                        return(-4);
                    }

                    return(-2);
                }

                return(-3);
            }

            return(-1);
        }