Пример #1
0
        // Updates camera position relative to players position if camera is within bounds of screen
        public void CameraUpdate(GameTime gameTime, PlayerOverworld player)
        {
            // Camera panning
            if (ZoomMap.MapState == MapState.On)
            {
                if (ControlManager.CheckHold(RebindableKeys.Right))
                {
                    cameraPos.X += CameraPanSpeed * MathFunctions.FPSSyncFactor(gameTime);
                }

                else if (ControlManager.CheckHold(RebindableKeys.Left))
                {
                    cameraPos.X -= CameraPanSpeed * MathFunctions.FPSSyncFactor(gameTime);
                }

                if (ControlManager.CheckHold(RebindableKeys.Up))
                {
                    cameraPos.Y -= CameraPanSpeed * MathFunctions.FPSSyncFactor(gameTime);
                }

                else if (ControlManager.CheckHold(RebindableKeys.Down))
                {
                    cameraPos.Y += CameraPanSpeed * MathFunctions.FPSSyncFactor(gameTime);
                }
            }

            else
            {
                originalCameraPos = cameraPos;
            }

            if (ZoomMap.MapState != MapState.On &&
                ((cameraPos.X - (Game1.ScreenSize.X / 2) >= 0 && (cameraPos.X + Game1.ScreenSize.X / 2) <= WorldWidth) ||
                 (cameraPos.Y - (Game1.ScreenSize.Y / 2) >= 0 && cameraPos.Y + (Game1.ScreenSize.Y / 2) <= WorldHeight)))
            {
                Position = player.position;
            }
        }
Пример #2
0
        protected override void Initialize()
        {
            Game1.GameRestarted = false;

            CreateDirectories();
            SetAvailableResolutions();
            GameStarted = false;

            settingsFile = new SaveFile(this);
            settingsFile.Load(SaveFilePath, "settings.ini");

            Vector2 defaultResolution = GetDefaultResolution();

            resolution = new Vector2(settingsFile.GetPropertyAsFloat("visual", "resolutionx", defaultResolution.X),
                                     settingsFile.GetPropertyAsFloat("visual", "resolutiony", defaultResolution.Y));

            random = new Random(DateTime.Now.Millisecond);

            showFPS = settingsFile.GetPropertyAsBool("visual", "showfps", false);

            // MAC CHANGE - Fullscreen before resolution
            graphics.IsFullScreen = settingsFile.GetPropertyAsBool("visual", "fullscreen", !IsDualMonitor());
            //
            graphics.PreferredBackBufferWidth       = (int)resolution.X;
            graphics.PreferredBackBufferHeight      = (int)resolution.Y;
            graphics.SynchronizeWithVerticalRetrace = true;

            // Uncomment to unlock FPS
            //IsFixedTimeStep = false;
            //graphics.SynchronizeWithVerticalRetrace = false;

            graphics.ApplyChanges();

            // MAC CHANGE - Set ScreenSize to clientbounds after applyChanges
            ScreenSize = new Point((int)Window.ClientBounds.Width, (int)Window.ClientBounds.Height);

            CenterScreenWindow();

            IsMouseVisible = settingsFile.GetPropertyAsBool("game options", "showmouse", true);

            menuBGController = new MenuBackdropController(this);
            menuBGController.Initialize();

            musicManager = new MusicManager(this);
            musicManager.Initialize();

            soundEffectsManager = new SoundEffectsManager(this);
            soundEffectsManager.Initialize();

            fontManager = new FontManager(this);
            fontManager.Initialize();

            ControlManager.LoadControls(settingsFile);

            spriteSheetOverworld       = new Sprite(Content.Load <Texture2D>("Overworld-Sprites/smallObjectSpriteSheet"));
            spriteSheetVerticalShooter = new Sprite(Content.Load <Texture2D>("Vertical-Sprites/shooterSheet"));
            messageBoxSpriteSheet      = new Sprite(Content.Load <Texture2D>("Overworld-Sprites/messageBoxSpriteSheet"));
            spriteSheetItemDisplay     = new Sprite(Content.Load <Texture2D>("itemVisualSheet"));
            beaconMenuSprite           = new Sprite(Content.Load <Texture2D>("Overworld-Sprites/BeaconMenu"));
            CollisionHandlingOverWorld.LoadLineTexture(this);

            shipInventoryManager = new ShipInventoryManager(this);
            shipInventoryManager.Initialize();

            statsManager = new StatsManager(this);
            statsManager.Initialize();

            player = new PlayerOverworld(this, spriteSheetOverworld);
            player.Initialize();

            beaconMenu = new BeaconMenu(this, beaconMenuSprite);
            beaconMenu.Initialize();

            stateManager = new GameStateManager(this);
            stateManager.Initialize();

            missionManager = new MissionManager(this);
            missionManager.Initialize();

            tutorialManager = new TutorialManager(this);
            tutorialManager.Initialize();
            tutorialManager.TutorialsUsed = settingsFile.GetPropertyAsBool("game options", "tutorials", true);

            shopManager = new ShopManager();

            saveFile = new SaveFile(this);

            Portrait.InitializePortraitSpriteSheet(this);
            popupHandler = new PopupHandler(this, messageBoxSpriteSheet);
            popupHandler.Initialize();

            helper = new HelperBox(this);

            ShopManager.SetShopUpdateTime(ShopManager.PRESET_SHOPTIME);

            base.Initialize();
        }