public virtual bool TestGameObject(LogicGameObject gameObject)
        {
            if (this.m_gameObjectTypes != null && !this.m_gameObjectTypes[(int)gameObject.GetGameObjectType()])
            {
                return(false);
            }
            if (this.m_ignoreGameObjects != null && this.m_ignoreGameObjects.IndexOf(gameObject) != -1)
            {
                return(false);
            }

            if (this.m_team != -1)
            {
                LogicHitpointComponent hitpointComponent = gameObject.GetHitpointComponent();

                if (hitpointComponent != null)
                {
                    if (hitpointComponent.GetHitpoints() > 0)
                    {
                        bool isEnemy = hitpointComponent.IsEnemyForTeam(this.m_team);

                        if (isEnemy || !this.m_enemyOnly)
                        {
                            return(this.m_enemyOnly || !isEnemy);
                        }
                    }

                    return(false);
                }
            }

            return(true);
        }
示例#2
0
        /// <summary>
        ///     Test the specified gameobject.
        /// </summary>
        public virtual bool TestGameObject(LogicGameObject gameObject)
        {
            if (this._gameObjectTypes != null)
            {
                if (!this._gameObjectTypes[gameObject.GetGameObjectType()])
                {
                    return(false);
                }
            }

            if (this._ignoreGameObjects != null)
            {
                for (int i = 0; i < this._ignoreGameObjects.Count; i++)
                {
                    if (this._ignoreGameObjects[i] == gameObject)
                    {
                        return(false);
                    }
                }
            }

            if (this._team != -1)
            {
                LogicHitpointComponent hitpointComponent = gameObject.GetHitpointComponent();

                if (hitpointComponent != null)
                {
                    bool isEnemy = hitpointComponent.IsEnemyForTeam(this._team);

                    if (gameObject.IsAlive())
                    {
                        if (isEnemy || !this._enemyOnly)
                        {
                            return(!this._enemyOnly || !isEnemy);
                        }
                    }

                    return(false);
                }
            }

            return(true);
        }
示例#3
0
        public void UpdateBounces()
        {
            LogicArrayList <LogicGameObject> gameObjects = this.GetGameObjectManager().GetGameObjects(LogicGameObjectType.BUILDING);

            int closestBuildingDistance = 0x7FFFFFFF;
            int closestWallDistance     = 0x7FFFFFFF;

            LogicBuilding closestBuilding = null;
            LogicBuilding closestWall     = null;

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

                if (building != this.m_target && building.IsAlive())
                {
                    LogicHitpointComponent hitpointComponent = building.GetHitpointComponent();

                    if (hitpointComponent != null && hitpointComponent.IsEnemyForTeam(this.m_myTeam) && !building.IsHidden() && !building.IsWall())
                    {
                        int distanceSquared = this.GetDistanceSquaredTo(building);

                        if (distanceSquared <= 26214400 && distanceSquared < (building.IsWall() ? closestWallDistance : closestBuildingDistance))
                        {
                            int idx = -1;

                            for (int j = this.m_bounceCount; j < LogicProjectile.MAX_BOUNCES; j++)
                            {
                                if (this.m_bounceTargets[j] == building)
                                {
                                    idx = j;
                                    break;
                                }
                            }

                            if (idx == -1)
                            {
                                if (this.m_level.GetTileMap().GetWallInPassableLine(this.GetMidX(), this.GetMidY(), building.GetMidX(), building.GetMidY(), new LogicVector2()))
                                {
                                    if (building.IsWall())
                                    {
                                        closestWallDistance = distanceSquared;
                                        closestWall         = building;
                                    }
                                    else
                                    {
                                        closestBuildingDistance = distanceSquared;
                                        closestBuilding         = building;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            LogicBuilding nextTarget = closestBuilding ?? closestWall;

            if (nextTarget != null)
            {
                this.m_bounceCount  -= 1;
                this.m_targetReached = false;
                this.m_damage       /= 2;

                this.SetTarget(this.GetMidX(), this.GetMidY(), this.m_bounceCount, nextTarget, false);
                this.SetInitialPosition(this.m_groups, this.GetMidX(), this.GetMidY());
            }
        }