/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { //if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) // Exit(); // TODO: Add your update logic here CONTENT_MANAGER.inputState = new InputState(Mouse.GetState(), Keyboard.GetState()); if (HelperFunction.IsKeyPress(Keys.F1)) { SCREEN_MANAGER.goto_screen("TestAnimationScreen"); } if (HelperFunction.IsKeyPress(Keys.F2)) { Unit.Load(); CONTENT_MANAGER.ShowMessageBox("Unit stats reloaded"); } if (HelperFunction.IsKeyPress(Keys.F3)) { SCREEN_MANAGER.goto_screen("TestConsole"); } SCREEN_MANAGER.Update(gameTime); lastInputState = inputState; base.Update(gameTime); }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.WhiteSmoke); SCREEN_MANAGER.Draw(CONTENT_MANAGER.spriteBatch, gameTime); base.Draw(gameTime); }
protected override void Update(GameTime gameTime) { CONTENT_MANAGER.CurrentInputState = new InputState(Mouse.GetState(), Keyboard.GetState()); SCREEN_MANAGER.Update(gameTime); base.Update(gameTime); }
private void InitScreen() { SCREEN_MANAGER.AddScreen(new Screens.GameScreen(GraphicsDevice)); SCREEN_MANAGER.GotoScreen("GameScreen"); SCREEN_MANAGER.Init(); }
private void InitUI() { Button btn_create_room = new Button("Create Room", new Point(275, 150), new Vector2(170, 25), CONTENT_MANAGER.arcadefont); Button btn_goto_room = new Button("Go To Room", new Point(285, 200), new Vector2(150, 25), CONTENT_MANAGER.arcadefont); Label label_player_name = new Label(Player.Instance.Name, new Point(620, 0), null, CONTENT_MANAGER.arcadefont, 1); //bind event //Click to button go to room btn_goto_room.MouseClick += (sender, e) => { enterRoom.ShowDialog(); }; //Click to button create room btn_create_room.MouseClick += (sender, e) => { Player.Instance.CreateRoom(); }; //Click to ok button after enter room number enterRoom.button_OK.Click += (sender, e) => { if (enterRoom.textBox_Input.Text != "") { Player.Instance.GotoRoom(Convert.ToInt32(enterRoom.textBox_Input.Text)); } else { CONTENT_MANAGER.ShowMessageBox("You have't enter room number"); } }; //Cancel go to room enterRoom.button_Cancel.Click += (sender, e) => { enterRoom.Hide(); }; //Event enter success Player.Instance.entered_succeed += (sender, e) => { SCREEN_MANAGER.goto_screen("Room_Screen"); }; //Event create room success Player.Instance.created_room += (_sender, _e) => { SCREEN_MANAGER.goto_screen("Room_Screen"); }; canvas.AddElement("btn_create_room", btn_create_room); canvas.AddElement("btn_goto_room", btn_goto_room); canvas.AddElement("label_player_name", label_player_name); }
private static Behaviour ShowDialog(string content) { MainPlayScreen mainPlayScreen = (MainPlayScreen)SCREEN_MANAGER.GetScreen("MainPlayScreen"); return((activator, self) => { mainPlayScreen.timer.Stop(); mainPlayScreen.msgbox.Show(content.ProcessAnnotation()); mainPlayScreen.gameStates.Push(GameState.ShowDialog); }); }
private void InitScreens() { SCREEN_MANAGER.AddScreen(new MainScreen(GraphicsDevice)); SCREEN_MANAGER.AddScreen(new FileBrowserScreen(GraphicsDevice)); SCREEN_MANAGER.GotoScreen("MainScreen"); //SCREEN_MANAGER.GotoScreen("FileBrowserScreen"); SCREEN_MANAGER.Init(); }
public static void oldVersion(string filename) { //a copy of the original code from 0.8 version of the game LoadingWorldScreen loadingWorldScreen = SCREEN_MANAGER.get_screen("loadWorld") as LoadingWorldScreen; loadingWorldScreen.mode = LoadScreenType.nuke_load_game; loadingWorldScreen.loadSelectName = filename; loadingWorldScreen.loadSelectSet = true; SCREEN_MANAGER.goto_screen("loadWorld"); }
public override void Update(GameTime gameTime) { var inputState = CONTENT_MANAGER.inputState; var lastInputState = CONTENT_MANAGER.lastInputState; if (inputState.keyboardState.IsKeyUp(Keys.E) && lastInputState.keyboardState.IsKeyDown(Keys.E)) { SCREEN_MANAGER.goto_screen("RedScreen"); } }
private static Behaviour ExitGame() { MainPlayScreen mainPlayScreen = (MainPlayScreen)SCREEN_MANAGER.GetScreen("MainPlayScreen"); return((a, s) => { mainPlayScreen.isExit = true; mainPlayScreen.CurrentGameState = GameState.Exit; mainPlayScreen.msgbox.Show("Exitting game.", "OK"); }); }
public override void Update(GameTime gameTime) { var inputState = CONTENT_MANAGER.inputState; var lastInputState = CONTENT_MANAGER.lastInputState; if (Utility.HelperFunction.IsKeyPress(Keys.E)) { SCREEN_MANAGER.goto_screen("BlueScreen"); } }
public static void newVersion(string filename) { //a copy of the original code from 0.9 version of the game LoadingWorldScreen loadingWorldScreen = SCREEN_MANAGER.get_screen("loadWorld") as LoadingWorldScreen; loadingWorldScreen.mode = LoadScreenType.database_continue; CHARACTER_DATA.continueFileName = loadingWorldScreen.loadSelectName; loadingWorldScreen.loadSelectName = filename; loadingWorldScreen.loadSelectSet = true; SCREEN_MANAGER.goto_screen("loadWorld"); }
protected override void Update(GameTime gameTime) { //if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) // Exit(); CONTENT_MANAGER.CurrentInputState = new InputState(Mouse.GetState(), Keyboard.GetState()); SCREEN_MANAGER.Update(gameTime); base.Update(gameTime); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); // TODO: Add your drawing code here CONTENT_MANAGER.spriteBatch.Begin(SpriteSortMode.FrontToBack); { SCREEN_MANAGER.Draw(gameTime); } CONTENT_MANAGER.spriteBatch.End(); base.Draw(gameTime); }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); CONTENT_MANAGER.spriteBatch.Begin(SpriteSortMode.FrontToBack, transformMatrix: camera.TransformMatrix); { SCREEN_MANAGER.Draw(CONTENT_MANAGER.spriteBatch, gameTime); //DrawingHelper.Draw(CONTENT_MANAGER.spriteBatch); CONTENT_MANAGER.ShowFPS(gameTime); } CONTENT_MANAGER.spriteBatch.End(); base.Draw(gameTime); }
private static Behaviour Win(string nextlvl = null) { MainPlayScreen mainPlayScreen = (MainPlayScreen)SCREEN_MANAGER.GetScreen("MainPlayScreen"); return((activator, self) => { mainPlayScreen.isWin = true; if (!string.IsNullOrEmpty(nextlvl)) { mainPlayScreen.isBehaviourChangeMap = true; mainPlayScreen.MapName = nextlvl; } }); }
private static Behaviour ShowDialog() { MainPlayScreen mainPlayScreen = (MainPlayScreen)SCREEN_MANAGER.GetScreen("MainPlayScreen"); return((activator, self) => { if (self.Memory.Count == 0) { return; } mainPlayScreen.timer.Stop(); var content = self.Memory.Pop(); mainPlayScreen.msgbox.Show(content.ProcessAnnotation()); mainPlayScreen.gameStates.Push(GameState.ShowDialog); }); }
private void InitScreen() { SCREEN_MANAGER.add_screen(new EditorScreen(GraphicsDevice)); SCREEN_MANAGER.add_screen(new MainMenuScreen(GraphicsDevice)); SCREEN_MANAGER.add_screen(new TestAnimationScreen(GraphicsDevice)); SCREEN_MANAGER.add_screen(new Screens.MainGameScreen.SetupScreen(GraphicsDevice)); SCREEN_MANAGER.add_screen(new Screens.MainGameScreen.GameScreen(GraphicsDevice)); SCREEN_MANAGER.add_screen(new Screens.MainGameScreen.Client_Screen(GraphicsDevice)); SCREEN_MANAGER.add_screen(new Screens.MainGameScreen.Room_Screen(GraphicsDevice)); SCREEN_MANAGER.add_screen(new TestConsole(GraphicsDevice)); //SCREEN_MANAGER.goto_screen("TestAnimationScreen"); //SCREEN_MANAGER.goto_screen("SetupScreen"); SCREEN_MANAGER.goto_screen("MainMenuScreen"); //SCREEN_MANAGER.goto_screen("EditorScreen"); SCREEN_MANAGER.Init(); }
private void InitUI() { SpriteFont spriteFont = CONTENT_MANAGER.arcadefont; //declare ui elements Label enter_name = new Label("Enter your name", new Point((this._device.Viewport.Width / 2) - (int)spriteFont.MeasureString("Enter your name").X / 2, this._device.Viewport.Height / 2 - 140), null, CONTENT_MANAGER.arcadefont, 1); InputBox player_name = new InputBox("", new Point(this._device.Viewport.Width / 2 - 75, this._device.Viewport.Height / 2 - 120), new Vector2(150, 20), CONTENT_MANAGER.hackfont, Color.Black, Color.White); Label enter_ip_address = new Label("Enter server ip address", new Point((this._device.Viewport.Width / 2) - (int)spriteFont.MeasureString("Enter server ip address").X / 2, this._device.Viewport.Height / 2 - 90), null, CONTENT_MANAGER.arcadefont, 1); InputBox ip_address = new InputBox("", new Point(this._device.Viewport.Width / 2 - 75, this._device.Viewport.Height / 2 - 70), new Vector2(150, 20), CONTENT_MANAGER.hackfont, Color.Black, Color.White); string text_conect = "Connect to server"; Point point_conect = new Point(this._device.Viewport.Width / 2 - (int)(spriteFont.MeasureString(text_conect).X + spriteFont.MeasureString(text_conect).X / 2) / 2, this._device.Viewport.Height / 2 - 20); Button button_connect = new Button(text_conect, point_conect, null, CONTENT_MANAGER.arcadefont); //bind event Player.Instance.connect_succeed += (sender, e) => { Player.Instance.Name = player_name.Text; SCREEN_MANAGER.goto_screen("Client_Screen"); }; button_connect.MouseClick += (sender, e) => { Player.Instance.ConnectToServer(ip_address.Text); }; //add to canvas canvas.AddElement("enter_name", enter_name); canvas.AddElement("enter_ip_address", enter_ip_address); canvas.AddElement("player_name", player_name); canvas.AddElement("ip_address", ip_address); canvas.AddElement("button_connect", button_connect); }
//go to game if both player ready //map can be load in two case: first if you are host, you choose map from your computer. //If you are't host, you must wait for host load map and send for you private void GoToGame() { if (map != null && is_another_ready && is_this_ready) { sessiondata = new SessionData(); sessiondata.map = new Map(); sessiondata.map.Clone(Storage.MapData.LoadMap(mapdata)); sessiondata.gameMode = GameMode.campaign; sessiondata.playerInfos = new PlayerInfo[2]; sessiondata.playerInfos[0] = new PlayerInfo(0, Owner.Red); sessiondata.playerInfos[1] = new PlayerInfo(1, Owner.Blue); if (Player.Instance.isHost) { ((GameScreen)SCREEN_MANAGER.get_screen("GameScreen")).InitSession(sessiondata, 0); } else { ((GameScreen)SCREEN_MANAGER.get_screen("GameScreen")).InitSession(sessiondata, 1); } SCREEN_MANAGER.goto_screen("GameScreen"); } }
private void InitScreen() { var playscreen = new MainPlayScreen(GraphicsDevice) { MapName = CONTENT_MANAGER.MapName ?? "menu" }; TransitionScreen transitionScreen = new TransitionScreen(GraphicsDevice) { StartingDirectory = Path.Combine(CONTENT_MANAGER.LocalRootPath, "map"), SearchPattern = "*.tmx", CallBack = x => { playscreen.MapName = x; SCREEN_MANAGER.GotoScreen("MainPlayScreen"); } }; SCREEN_MANAGER.AddScreen(playscreen); SCREEN_MANAGER.AddScreen(transitionScreen); SCREEN_MANAGER.GotoScreen("MainPlayScreen"); SCREEN_MANAGER.Init(); }
private void InitUI() { //declare ui element //khai báo 1 cái label để hiển thị fps Label label_fps = new Label(" ", new Point(0, 0), new Vector2(100, 50), CONTENT_MANAGER.defaultfont); label_fps.foregroundColor = Color.DarkBlue; label_fps.IsVisible = false; //TODO make button for main menu Button button_Campaign = new Button(ModeSelectDark, null, new Point(100, 275), 2); Button button_MapEditor = new Button(ModeSelectDark, null, new Point(300, 275), 2); Button button_OtherGamemode = new Button(ModeSelectDark, null, new Point(500, 275), 2); //bind action to ui event button_Campaign.MouseClick += (sender, e) => { if (selectedbutton != ButtonSelected.Campaign) { selectedbutton = ButtonSelected.Campaign; button_Campaign.Sprite = ModeSelectLight; button_MapEditor.Sprite = ModeSelectDark; button_OtherGamemode.Sprite = ModeSelectDark; } else { SCREEN_MANAGER.goto_screen("SetupScreen"); } }; button_MapEditor.MouseClick += (sender, e) => { if (selectedbutton != ButtonSelected.MapEditor) { selectedbutton = ButtonSelected.MapEditor; button_Campaign.Sprite = ModeSelectDark; button_MapEditor.Sprite = ModeSelectLight; button_OtherGamemode.Sprite = ModeSelectDark; } else { SCREEN_MANAGER.goto_screen("EditorScreen"); } }; button_OtherGamemode.MouseClick += (sender, e) => { if (selectedbutton != ButtonSelected.Other) { selectedbutton = ButtonSelected.Other; button_Campaign.Sprite = ModeSelectDark; button_MapEditor.Sprite = ModeSelectDark; button_OtherGamemode.Sprite = ModeSelectLight; } else { //SCREEN_MANAGER.goto_screen("OtherGamemode"); } }; //add ui element to canvas canvas.AddElement("label_fps", label_fps); canvas.AddElement("button_Campaign", button_Campaign); canvas.AddElement("button_MapEditor", button_MapEditor); canvas.AddElement("button_OtherGameMode", button_OtherGamemode); }