public bool IsEnemy(LogicGameObject gameObject)
        {
            LogicHitpointComponent hitpointComponent = (LogicHitpointComponent)gameObject.GetComponent(LogicComponentType.HITPOINT);

            if (hitpointComponent != null && hitpointComponent.GetTeam() != this.m_team)
            {
                return(this.m_hp > 0);
            }

            return(false);
        }
Ejemplo n.º 2
0
        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();
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public int GetRecommendedMax(int idx)
        {
            int max = this.GetMax(idx);

            LogicHitpointComponent hitpointComponent = this.m_parent.GetHitpointComponent();

            if (hitpointComponent != null)
            {
                int hp    = hitpointComponent.GetHitpoints();
                int maxHp = hitpointComponent.GetMaxHitpoints();

                if (hp <= 10000)
                {
                    if (hp <= 1000)
                    {
                        return(max * hp / maxHp);
                    }
                    return(100 * (max * (hp / 100) / maxHp));
                }
                return(1000 * (max * (hp / 1000) / maxHp));
            }

            return(max);
        }
Ejemplo n.º 4
0
        public LogicCharacter ClosestAttacker(bool flyingTroop)
        {
            LogicGameObjectManager           gameObjectManager = this.m_parent.GetLevel().GetGameObjectManagerAt(0);
            LogicArrayList <LogicGameObject> gameObjects       = gameObjectManager.GetGameObjects(LogicGameObjectType.CHARACTER);

            int            closestDistance  = 0x7fffffff;
            LogicCharacter closestCharacter = null;

            for (int i = 0; i < gameObjects.Size(); i++)
            {
                LogicCharacter         character         = (LogicCharacter)gameObjects[i];
                LogicHitpointComponent hitpointComponent = character.GetHitpointComponent();
                LogicCombatComponent   combatComponent   = character.GetCombatComponent();

                bool deployTime = combatComponent != null && combatComponent.GetUndergroundTime() > 0;

                if (!deployTime && (LogicDataTables.GetGlobals().SkeletonOpenClanCastle() || !LogicDataTables.IsSkeleton(character.GetCharacterData())))
                {
                    if (hitpointComponent != null)
                    {
                        if (character.IsAlive() && character.IsFlying() == flyingTroop && hitpointComponent.GetTeam() == 0)
                        {
                            int distance = character.GetPosition().GetDistanceSquaredTo(this.m_parent.GetMidX(), this.m_parent.GetMidY());

                            if (distance < closestDistance)
                            {
                                closestDistance  = distance;
                                closestCharacter = character;
                            }
                        }
                    }
                }
            }

            return(closestCharacter);
        }
Ejemplo n.º 5
0
        public bool MoveTo(int x, int y, LogicTileMap tileMap, bool defaultEndPoint)
        {
            this.ClearPath();

            if (this.m_parent != null)
            {
                if (this.m_parent.GetParent().IsFrozen())
                {
                    return(false);
                }
            }

            this.m_wall      = null;
            this.m_wallCount = 0;

            this.m_pathStartPosition.m_x = this.m_position.m_x >> 8;
            this.m_pathStartPosition.m_y = this.m_position.m_y >> 8;
            this.m_pathEndPosition.m_x   = x >> 8;
            this.m_pathEndPosition.m_y   = y >> 8;

            this.m_pathStartPosition.m_x = LogicMath.Clamp(this.m_pathStartPosition.m_x, 0, 99);
            this.m_pathStartPosition.m_y = LogicMath.Clamp(this.m_pathStartPosition.m_y, 0, 99);
            this.m_pathEndPosition.m_x   = LogicMath.Clamp(this.m_pathEndPosition.m_x, 0, 99);
            this.m_pathEndPosition.m_y   = LogicMath.Clamp(this.m_pathEndPosition.m_y, 0, 99);

            LogicPathFinder pathFinder;

            if (this.m_parent == null)
            {
                pathFinder = this.m_pathFinder;
                pathFinder.ResetCostStrategyToDefault();
            }
            else
            {
                bool resetStrategyCost = true;
                int  strategyCost      = 256;

                LogicGameObject        parent            = this.m_parent.GetParent();
                LogicHitpointComponent hitpointComponent = parent.GetHitpointComponent();

                if (hitpointComponent != null)
                {
                    if (hitpointComponent.GetTeam() == 1)
                    {
                        resetStrategyCost = false;
                        strategyCost      = 768;
                    }
                }

                if (this.m_parent.CanJumpWall())
                {
                    resetStrategyCost = false;
                    strategyCost      = 16;
                }

                if (parent.GetGameObjectType() == LogicGameObjectType.CHARACTER)
                {
                    LogicCharacter character = (LogicCharacter)parent;

                    if (character.IsWallBreaker())
                    {
                        resetStrategyCost = false;
                        strategyCost      = 128;
                    }
                }

                pathFinder = tileMap.GetPathFinder();

                if (resetStrategyCost)
                {
                    pathFinder.ResetCostStrategyToDefault();
                }
                else
                {
                    pathFinder.SetCostStrategy(true, strategyCost);
                }

                pathFinder.FindPath(this.m_pathStartPosition, this.m_pathEndPosition, true);
                pathFinder.GetPathLength();

                int pathLength = pathFinder.GetPathLength();

                this.m_path.EnsureCapacity(pathLength + 1);

                if (pathLength != 0 && defaultEndPoint)
                {
                    LogicVector2 pathPoint = new LogicVector2(x, y);

                    this.CheckWall(pathPoint);
                    this.m_path.Add(pathPoint);
                }

                if (LogicDataTables.GetGlobals().UseNewPathFinder())
                {
                    LogicTileMap pathFinderTileMap = pathFinder.GetTileMap();

                    int width  = 2 * pathFinderTileMap.GetSizeX();
                    int height = 2 * pathFinderTileMap.GetSizeY();

                    int startTileIdx = this.m_pathStartPosition.m_x + width * this.m_pathStartPosition.m_y;
                    int endTileIdx   = this.m_pathEndPosition.m_x + width * this.m_pathEndPosition.m_y;

                    if (!defaultEndPoint)
                    {
                        LogicVector2 pathPoint = new LogicVector2((endTileIdx % width) << 8, (endTileIdx / height) << 8);

                        this.CheckWall(pathPoint);
                        this.m_path.Add(pathPoint);
                    }

                    if (pathLength > 0 && !pathFinder.IsLineOfSightClear())
                    {
                        int iterationCount = 0;

                        while (endTileIdx != startTileIdx && endTileIdx != -1)
                        {
                            endTileIdx = pathFinder.GetParent(endTileIdx);

                            if (endTileIdx != startTileIdx && endTileIdx != -1)
                            {
                                LogicVector2 pathPoint = new LogicVector2((endTileIdx % width) << 8, (endTileIdx / height) << 8);

                                pathPoint.m_x += 128;
                                pathPoint.m_y += 128;

                                this.CheckWall(pathPoint);
                                this.m_path.Add(pathPoint);

                                if (iterationCount >= 100000)
                                {
                                    Debugger.Warning("LMSystem: iteration count > 100000");
                                    break;
                                }
                            }

                            iterationCount += 1;
                        }
                    }
                }
                else
                {
                    for (int i = -pathLength, j = 0; j + i != 0; j++)
                    {
                        LogicVector2 pathPoint = new LogicVector2();

                        pathFinder.GetPathPoint(pathPoint, i + j);

                        if (i + j == -1 && this.m_pathStartPosition.Equals(pathPoint))
                        {
                            pathPoint.Destruct();
                            pathPoint = null;
                        }
                        else
                        {
                            if (j != 0 || !this.m_pathStartPosition.Equals(pathPoint))
                            {
                                pathPoint.m_x = (pathPoint.m_x << 8) | 128;
                                pathPoint.m_y = (pathPoint.m_y << 8) | 128;
                            }
                            else
                            {
                                pathPoint.m_x = x;
                                pathPoint.m_y = y;
                            }

                            this.CheckWall(pathPoint);
                            this.m_path.Add(pathPoint);
                        }
                    }
                }
            }

            this.CalculatePathLength();

            if (this.m_path.Size() > 0)
            {
                this.CalculateDirection(this.m_pathDistance);
                return(true);
            }

            return(false);
        }