Esempio n. 1
0
        private void Initialize()
        {
            LoadState = MapLoadState.Preparing;
            Mode      = GameMode.Paused;

            Content = Global.Content;

            NewGameSetup();

            MapContainer = new MapContainer();

            InputManager.StartPressed     += OnStartPressed;
            InputManager.SelectPressed    += OnSelectPressed;
            InputManager.InventoryPressed += OnInventoryPressed;

            Player                     = new ActorPlayer(0, PlayerIndex.One, new Vector2(224, 192));
            Player.PlayerMoved        += OnPlayerMove;
            Player.PlayerInteracted   += OnPlayerInteract;
            Player.PlayerClimbed      += OnPlayerClimb;
            Player.Inventory.ItemUsed += OnPlayerItemUsed;

            MapRenderer = new TiledMapRenderer(Global.Graphics.GraphicsDevice);

            GameViewport = new BoxingViewportAdapter(Global.Window, Global.Graphics, 512, 288, 0, 0);

            GameCamera          = new Camera2D(GameViewport);
            GameCamera.Origin   = new Vector2(0, 0);
            GameCamera.Position = new Vector2(0, 0);

            IsCameraMobile = false;

            MapContainer            = new MapContainer();
            MapContainer.MapLoaded += OnMapLoad;
            MapContainer.LoadMap("DebugRoom3");

            MaxCameraPosition = new Vector2(0);

            TileSceneObjects = new List <TileSceneObject>();

            PauseFont   = Content.Load <BitmapFont>("GFX/Fonts/PauseFont");
            PauseScreen = Content.Load <Texture2D>("GFX/SinglePixel");
            DebugFont   = Content.Load <BitmapFont>("GFX/Fonts/DebugFont");

            BGM = Content.Load <Song>("Audio/BGM/MansionFirstFloor");
            MediaPlayer.Volume      = 0.15f;
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Play(BGM);
        }
Esempio n. 2
0
        public void OnMapLoad(object source, EventArgs e)
        {
            GameCamera.Position = new Vector2(0, 0);

            int mapWidth, mapHeight;

            mapWidth  = MapContainer.ActiveMap.WidthInPixels;
            mapHeight = MapContainer.ActiveMap.HeightInPixels;

            if (mapWidth <= 512 && mapHeight <= 288)
            {
                IsCameraMobile = false;
            }
            else
            {
                SetMaxCameraPosition();
                IsCameraMobile = true;
            }

            LoadState = MapLoadState.Loaded;
            Mode      = GameMode.Normal;
        }