示例#1
0
        public void Update(GameTime gameTime, List <GameObjectOverworld> objectsInOverworld, Vector2 cameraPos)
        {
            objectsVisibleOnRadar.Clear();
            missionArrows.Clear();
            availableMainMissionArrows.Clear();
            availableMainMissionLocationNames.Clear();

            availableMainMissionLocationNames = MissionManager.GetAvailableMainMissionLocationNames();

            colorSwapCounter += 1 * MathFunctions.FPSSyncFactor(gameTime);

            foreach (GameObjectOverworld obj in objectsInOverworld)
            {
                // Adds visible game objects
                if (CollisionDetection.IsPointInsideCircle(obj.position, game.player.position, viewRadius))
                {
                    objectsVisibleOnRadar.Add(obj);
                }

                // Adds mission arrows for non-visible mission coordinates
                else if (MissionManager.IsCurrentObjectiveDestination(obj) ||
                         MissionManager.IsFailedMissionDestination(obj))
                {
                    Boolean isMain = MissionManager.IsMainMissionDestination(obj);
                    missionArrows.Add(new DirectionArrow(spriteSheet, obj.position, playerpos, isMain));
                }

                else if (MissionManager.IsNoMainMissionActive())
                {
                    foreach (String str in availableMainMissionLocationNames)
                    {
                        if (obj.name.ToLower().Equals(str.ToLower()))
                        {
                            availableMainMissionArrows.Add(new DirectionArrow(spriteSheet, obj.position, playerpos, true));
                            break;
                        }
                    }
                }
            }

            playerpos = game.player.position;
            Origin    = new Vector2(cameraPos.X + Game1.ScreenSize.X / 2 - background.SourceRectangle.Value.Width,
                                    cameraPos.Y + Game1.ScreenSize.Y / 2 - background.SourceRectangle.Value.Height);
        }
示例#2
0
        private void DrawVisibleGameObjects(SpriteBatch spriteBatch)
        {
            float drawDistance = 0.91f;

            foreach (GameObjectOverworld obj in objectsVisibleOnRadar)
            {
                Color color = ImmovableObjectColor;
                float scale = 1f;
                activeSprite = objectSprite;
                drawDistance = 0.91f;
                bool isHidden = false;

                if (MissionManager.IsCurrentObjectiveDestination(obj) ||
                    MissionManager.IsFailedMissionDestination(obj))
                {
                    drawDistance = 0.92f;
                    if (colorSwapCounter <= 25)
                    {
                        if (MissionManager.IsMainMissionDestination(obj))
                        {
                            color = MainMissionColor;
                        }
                        else
                        {
                            color = SecondaryMissionColor;
                        }
                        activeSprite = blinkingSprite;
                        scale        = 1.25f;
                    }

                    else
                    {
                        color = Color.White;
                        scale = 1f;
                    }

                    if (colorSwapCounter >= 50)
                    {
                        colorSwapCounter = 0;
                    }
                }
                else if (IsObjectAvailableMainMissionLocation(obj) &&
                         MissionManager.IsNoMainMissionActive())
                {
                    drawDistance = 0.92f;
                    if (colorSwapCounter <= 25)
                    {
                        color        = MainMissionColor;
                        activeSprite = blinkingSprite;
                        scale        = 1.25f;
                    }

                    else
                    {
                        color = Color.White;
                        scale = 1f;
                    }

                    if (colorSwapCounter >= 50)
                    {
                        colorSwapCounter = 0;
                    }
                }
                else if (obj.isHidden)
                {
                    isHidden = true;
                }
                else if (obj is FreighterShip)
                {
                    color = FriendlyShipColor;
                }
                else if (obj is RebelShip)
                {
                    if (StatsManager.reputation >= 0)
                    {
                        color = HostileShipColor;
                    }
                    else
                    {
                        color = FriendlyShipColor;
                    }
                }
                else if (obj is AllianceShip ||
                         obj is HangarShip)
                {
                    if (StatsManager.reputation < 0)
                    {
                        color = HostileShipColor;
                    }
                    else
                    {
                        color = FriendlyShipColor;
                    }
                }
                else if (obj is SystemStar)
                {
                    color = Color.White;
                    scale = 1.25f;
                }
                else if (obj is Asteroid)
                {
                    activeSprite = asteroidSprite;
                    color        = AsteroidColor;
                    scale        = 1.5f;
                }
                else if (obj is ShopStation)
                {
                    activeSprite = shopSprite;
                    color        = Color.White;
                    drawDistance = 0.915f;
                }

                if (!isHidden)
                {
                    spriteBatch.Draw(activeSprite.Texture,
                                     new Vector2(Origin.X + ((obj.position.X - View.X) / scaleX), Origin.Y + ((obj.position.Y - View.Y) / scaleY)),
                                     activeSprite.SourceRectangle,
                                     color,
                                     0.0f,
                                     new Vector2(activeSprite.SourceRectangle.Value.Width / 2, activeSprite.SourceRectangle.Value.Height / 2),
                                     scale,
                                     SpriteEffects.None,
                                     drawDistance
                                     );
                }
            }
        }