void ReturnGameEntrySelected(object sender, EventArgs e) { if (!MapEngine.IsMapNull()) { ScreenManager.RemoveScreen(this); } }
static public void SaveMap() { string testStr = "test.xml"; MapLoader.MapToSavedMap(ref MapEngine.currMap, ref testStr); MapEngine.ClearMap(); }
static public void Update(GameTime gt) { if (singleton.mapLoaded) { MapEngine.Update(gt); } curPlayer.Update(gt); }
static public void centerViewport(Point char_pos) { int x_char_pos = char_pos.X; int y_char_pos = char_pos.Y; int x_offset = -440; int y_offset = -440; MapEngine.SetMapEngineViewportLocation(x_char_pos + x_offset, y_char_pos + y_offset); }
private void LoadContent(ref ContentManager contentMan) { normalmapEffect = ScreenManager.contentMan.Load <Effect>("normalmap"); MapEngine.LoadContent(ScreenManager.contentMan); InfoWriter.LoadContent(); MapEngine.NewMap(); MapEngine.LoadMap(); mapLoaded = true; curPlayer = new Player(ref ScreenManager.contentMan, "test_hero", MapEngine.currMap.startPoint, Directions.S, CharacterLoader.LoadCharacter(ref ScreenManager.contentMan, "test_hero", "Player")); curPlayer.MapSprite.texture = ScreenManager.contentMan.Load <Texture2D>(curPlayer.MapSprite.textureName); curPlayer.MapSprite.FrameDimensions = new Point(55, 55); curPlayer.MapSprite.ResetAnimation(); }
public override void Draw(GameTime gameTime) { SpriteBatch sb = ScreenManager.spriteBatch; if (playerMoved) { VisionHelper.getVisibleSqrs(GameSession.curPlayer.tilePosition, GameSession.curPlayer.vision); } sb.Begin(); HUDHelper.Draw(ref sb); MapEngine.Draw(sb); sb.End(); // draw altitude tiles //if (singleton.mapLoaded) // MapEngine.Draw(sb, ref ScreenManager.graphicDevMan, ref singleton.normalmapEffect); sb.Begin(); GameSession.curPlayer.Draw(ref sb, ref MapEngine.mEngVportWLoc); sb.End(); }
/// <summary> /// Private constructor of a Session object. /// </summary> /// <remarks> /// The lack of public constructors forces the singleton model. /// </remarks> private GameSession()//ScreenManager screenManager, TempGamePlayScreen gameplayScreen) { MapEngine.Initialize(ScreenManager.graphicDevMan); InfoWriter.Initialize(); // check the parameter //if (screenManager == null) //{ // throw new ArgumentNullException("screenManager"); //} //if (gameplayScreen == null) //{ // throw new ArgumentNullException("gameplayScreen"); //} // assign the parameter //this.screenManager = screenManager; //this.gameplayScreen = gameplayScreen; // create the HUD interface //this.hud = new Hud(screenManager); //this.hud.LoadContent(); }
public override void HandleInput() { prevPlayerPos = curPlayerPos; if (InputManager.IsActionTriggered(InputManager.Action.Back)) { ScreenManager.AddScreen(new MainMenuStartScreen(Color.Blue, Fonts.normFont, GameMain.VPCenter)); return; } // player input if (InputManager.IsActionPressedTimed(InputManager.Action.MoveCharN, 100)) { if (!VisionHelper.isBlocked(GameSession.curPlayer.tilePosition, 0, -1)) { GameSession.curPlayer.SetMapPosition(0, -55, MapEngine.currMap.widthTiles, MapEngine.currMap.heightTiles); VisionHelper.centerViewport(GameSession.curPlayer.mapPosition); } } if (InputManager.IsActionPressedTimed(InputManager.Action.MoveCharNE, 100)) { if (!VisionHelper.isBlocked(GameSession.curPlayer.tilePosition, 1, -1)) { GameSession.curPlayer.SetMapPosition(55, -55, MapEngine.currMap.widthTiles, MapEngine.currMap.heightTiles); VisionHelper.centerViewport(GameSession.curPlayer.mapPosition); } } if (InputManager.IsActionPressedTimed(InputManager.Action.MoveCharE, 100)) { if (!VisionHelper.isBlocked(GameSession.curPlayer.tilePosition, 1, 0)) { GameSession.curPlayer.SetMapPosition(55, 0, MapEngine.currMap.widthTiles, MapEngine.currMap.heightTiles); VisionHelper.centerViewport(GameSession.curPlayer.mapPosition); } } if (InputManager.IsActionPressedTimed(InputManager.Action.MoveCharSE, 100)) { if (!VisionHelper.isBlocked(GameSession.curPlayer.tilePosition, 1, 1)) { GameSession.curPlayer.SetMapPosition(55, 55, MapEngine.currMap.widthTiles, MapEngine.currMap.heightTiles); VisionHelper.centerViewport(GameSession.curPlayer.mapPosition); } } if (InputManager.IsActionPressedTimed(InputManager.Action.MoveCharS, 100)) { if (!VisionHelper.isBlocked(GameSession.curPlayer.tilePosition, 0, 1)) { GameSession.curPlayer.SetMapPosition(0, 55, MapEngine.currMap.widthTiles, MapEngine.currMap.heightTiles); VisionHelper.centerViewport(GameSession.curPlayer.mapPosition); } } if (InputManager.IsActionPressedTimed(InputManager.Action.MoveCharSW, 100)) { if (!VisionHelper.isBlocked(GameSession.curPlayer.tilePosition, -1, 1)) { GameSession.curPlayer.SetMapPosition(-55, 55, MapEngine.currMap.widthTiles, MapEngine.currMap.heightTiles); VisionHelper.centerViewport(GameSession.curPlayer.mapPosition); } } if (InputManager.IsActionPressedTimed(InputManager.Action.MoveCharW, 100)) { if (!VisionHelper.isBlocked(GameSession.curPlayer.tilePosition, -1, 0)) { GameSession.curPlayer.SetMapPosition(-55, 0, MapEngine.currMap.widthTiles, MapEngine.currMap.heightTiles); VisionHelper.centerViewport(GameSession.curPlayer.mapPosition); } } if (InputManager.IsActionPressedTimed(InputManager.Action.MoveCharNW, 100)) { if (!VisionHelper.isBlocked(GameSession.curPlayer.tilePosition, -1, -1)) { GameSession.curPlayer.SetMapPosition(-55, -55, MapEngine.currMap.widthTiles, MapEngine.currMap.heightTiles); VisionHelper.centerViewport(GameSession.curPlayer.mapPosition); } } // move mapEngineViewport up if (InputManager.IsActionPressedTimed(InputManager.Action.CursorUp, 100)) { MapEngine.MoveMapEngineViewportLocation(0, -55); } // move mapEngineViewport right if (InputManager.IsActionPressedTimed(InputManager.Action.PageRight, 100)) { MapEngine.MoveMapEngineViewportLocation(55, 0); } // move mapEngineViewport down if (InputManager.IsActionPressedTimed(InputManager.Action.CursorDown, 100)) { MapEngine.MoveMapEngineViewportLocation(0, 55); } // move mapEngineViewport left if (InputManager.IsActionPressedTimed(InputManager.Action.PageLeft, 100)) { MapEngine.MoveMapEngineViewportLocation(-55, 0); } //if (InputManager.IsActionTriggered(InputManager.Action.Ok)) // MapEngine.ShowBlankStates = true; // save if (InputManager.IsActionTriggered(InputManager.Action.Save)) { MapEngine.SaveMap(); } // load if (InputManager.IsActionTriggered(InputManager.Action.Load)) { MapEngine.LoadMap(); } // new if (InputManager.IsActionTriggered(InputManager.Action.New)) { MapEngine.NewMap(); MapEngine.LoadMap(); } if (InputManager.IsActionPressedTimed(InputManager.Action.Ok, 100)) { if (!drawingLOS) { drawingLOS = true; } else { drawingLOS = false; VisionHelper.clearLOS(); } } if (InputManager.IsActionTriggered(InputManager.Action.ShowDebug)) { Globals.GetMapData = (Globals.GetMapData) ? false : true; } //if(InputManager.IsActionPressedTimed(InputManager.Action.SpritePrev, 100)) //{ // GameSession.curPlayer.MapSprite. //} curPlayerPos = GameSession.curPlayer.tilePosition; if (drawingLOS) { VisionHelper.drawLOS(); } if (curPlayerPos != prevPlayerPos) { playerMoved = true; } else { playerMoved = false; } }
/// <summary> /// UnloadContent will be called once per game and is the place to unload /// all content. /// </summary> protected override void UnloadContent() { Fonts.UnloadContent(); MapEngine.UnloadContent(); }