public static GuiManager CreateHighScoresGui(GameCore game, GuiManager highScoresGui, InputListenerComponent inputManager) { //Create gui var guiInputService = new GuiInputService(inputManager); highScoresGui = new GuiManager(game.Services, guiInputService); highScoresGui.Screen = new GuiScreen(GameCore.SCREEN_WIDTH, GameCore.SCREEN_HEIGHT); highScoresGui.Screen.Desktop.Bounds = new UniRectangle(new UniScalar(0f, 0), new UniScalar(0f, 0), new UniScalar(1f, 0), new UniScalar(1f, 0)); //Create back button var buttonWidth = 150; var buttonHeight = 50; var buttonX = (GameCore.WINDOW_WIDTH / 2) - (buttonWidth / 2); var buttonY = (GameCore.WINDOW_HEIGHT - 70); var backButton = new GuiButtonControl { Name = "Back", Bounds = new UniRectangle(new UniScalar(buttonX), new UniScalar(buttonY), new UniScalar(buttonWidth), new UniScalar(buttonHeight)), Text = "Back" }; backButton.Pressed += game.BackButtonPressed; highScoresGui.Screen.Desktop.Children.Add(backButton); highScoresGui.Initialize(); return(highScoresGui); }
public static GuiManager CreateTitleGui(GameCore game, GuiManager titleGui, InputListenerComponent inputManager) { //Create GUI var guiInputService = new GuiInputService(inputManager); titleGui = new GuiManager(game.Services, guiInputService); titleGui.Screen = new GuiScreen(GameCore.SCREEN_WIDTH, GameCore.SCREEN_HEIGHT); titleGui.Screen.Desktop.Bounds = new UniRectangle(new UniScalar(0f, 0), new UniScalar(0f, 0), new UniScalar(1f, 0), new UniScalar(1f, 0)); titleGui.Initialize(); //Create buttons var buttonWidth = 150; var buttonHeight = 50; var buttonX = (GameCore.WINDOW_WIDTH / 2) - (buttonWidth / 2); var buttonY = 200; var buttonDivider = 100; var StartButton = new GuiButtonControl { Name = "Start", Bounds = new UniRectangle(new UniScalar(buttonX), new UniScalar(buttonY), new UniScalar(buttonWidth), new UniScalar(buttonHeight)), Text = "Start" }; var HighScoresButton = new GuiButtonControl { Name = "HighScores", Bounds = new UniRectangle(new UniScalar(buttonX), new UniScalar(buttonY + buttonDivider), new UniScalar(buttonWidth), new UniScalar(buttonHeight)), Text = "High Scores" }; var ExitButton = new GuiButtonControl { Name = "Exit", Bounds = new UniRectangle(new UniScalar(buttonX), new UniScalar(buttonY + (buttonDivider * 2)), new UniScalar(buttonWidth), new UniScalar(buttonHeight)), Text = "Exit" }; //Add functon to pressed StartButton.Pressed += game.StartButtonPressed; HighScoresButton.Pressed += game.HighScoresButtonPressed; ExitButton.Pressed += game.ExitButtonPressed; //Add buttons to gui titleGui.Screen.Desktop.Children.Add(StartButton); titleGui.Screen.Desktop.Children.Add(HighScoresButton); titleGui.Screen.Desktop.Children.Add(ExitButton); return(titleGui); }
public void Initialize() { var guiInputService = new GuiInputService(inputListener); gui = new GuiManager(game.Services, guiInputService); gui.Screen = new GuiScreen(GameCore.SCREEN_WIDTH, GameCore.SCREEN_HEIGHT); gui.Screen.Desktop.Bounds = new UniRectangle(new UniScalar(0f, 0), new UniScalar(0f, 0), new UniScalar(1f, 0), new UniScalar(1f, 0)); gui.Initialize(); }
public GameController(Minesweeper game) { Instance = this; _game = game; //Setup GUI _inputManager = new InputListenerComponent(game); var guiInputService = new GuiInputService(_inputManager); _gui = new GuiManager(game.Services, guiInputService); //Setup dictionary to hold tiles and their game objects _tileToGameObjectMap = new Dictionary <Tile, GameObject>(); _gameObjectToTileMap = new Dictionary <GameObject, Tile>(); }
public Game1() : base() { //_graphicsDeviceManager = new GraphicsDeviceManager(this); // Content.RootDirectory = "Content"; IsMouseVisible = true; Window.AllowUserResizing = true; _backgroundColor = Color.DarkKhaki; // First, we create an input manager. _inputManager = new InputListenerComponent(this); // Then, we create GUI. var guiInputService = new GuiInputService(_inputManager); _gui = new GuiManager(Services, guiInputService); }
public static GuiManager CreateInputHighScoreGui(GameCore game, GuiManager inputHighScoreGui, InputListenerComponent inputManager) { //Create gui var guiInputService = new GuiInputService(inputManager); inputHighScoreGui = new GuiManager(game.Services, guiInputService); inputHighScoreGui.Screen = new GuiScreen(GameCore.SCREEN_WIDTH, GameCore.SCREEN_HEIGHT); inputHighScoreGui.Screen.Desktop.Bounds = new UniRectangle(new UniScalar(0f, 0), new UniScalar(0f, 0), new UniScalar(1f, 0), new UniScalar(1f, 0)); //Create Submit button var buttonWidth = 150; var buttonHeight = 50; var buttonX = (GameCore.WINDOW_WIDTH / 2) - (buttonWidth / 2); var buttonY = (GameCore.WINDOW_HEIGHT - 200); var submitButton = new GuiButtonControl { Name = "Submit", Bounds = new UniRectangle(new UniScalar(buttonX), new UniScalar(buttonY), new UniScalar(buttonWidth), new UniScalar(buttonHeight)), Text = "Submit" }; var inputWidth = 200; var inputHeight = 20; var inputX = (GameCore.WINDOW_WIDTH / 2) - (inputWidth / 2); var inputY = (GameCore.WINDOW_HEIGHT - 400); var textInput = new GuiInputControl { Name = "Text Input", Bounds = new UniRectangle(new UniScalar(inputX), new UniScalar(inputY), new UniScalar(inputWidth), new UniScalar(inputHeight)), Text = "Name" }; submitButton.Pressed += game.SubmitButtonPressed; inputHighScoreGui.Screen.Desktop.Children.Add(submitButton); inputHighScoreGui.Screen.Desktop.Children.Add(textInput); inputHighScoreGui.Initialize(); return(inputHighScoreGui); }
public Game1() { // сначала наследуемые this.Window.AllowUserResizing = true; this.Window.AllowAltF4 = true; this.Window.ClientSizeChanged += this.Window_ClientSizeChanged; this.IsMouseVisible = true; this.Content.RootDirectory = "Content"; // объявленные нами this._graphicsDeviceManager = new GraphicsDeviceManager(this); this._backgroundColor = Color.CornflowerBlue; this._inputManager = new InputListenerComponent(this); // Then, we create GUI. this._inputService = new GuiInputService(_inputManager); this._gui = new GuiManager(this.Services, this._inputService); // Create a GUI screen and attach it as a default to GuiManager. // That screen will also act as a root parent for every other control that we create. this._gui.Screen = new GuiScreen(1280, 1024); this._gui.Screen.Desktop.Bounds = new UniRectangle( new UniScalar(0f, 0), new UniScalar(0f, 0), new UniScalar(1f, 0), new UniScalar(1f, 0)); /*BoxingViewportAdapter viewportAdapter = * new BoxingViewportAdapter(this.Window, this.GraphicsDevice, 800, 480); * this._camera = new Camera2D(viewportAdapter);*/ this._connection = new HubConnection("http://localhost:8080/signalr"); this._connection.DeadlockErrorTimeout = TimeSpan.FromSeconds(15); this._connection.TransportConnectTimeout = TimeSpan.FromSeconds(15); this._proxy = this._connection.CreateHubProxy("GlobalHub") .AsHubProxy <IServerContract, IClientContract>(); this._proxy.SubscribeOn <string>( c => c.OnShowMessage, s => { MessageScene msg = new MessageScene(); msg.SetText(s); this._gui.Screen.Desktop.Children.Add(msg); msg.BringToFront(); }); this._proxy.SubscribeOn <char>( c => c.OnCanDoStep, ch => this._gameWindow.AddNewChar(ch)); this._proxy.SubscribeOn <string, string, char>( c => c.OnGameStarted, (gameId, enemyNick, startChar) => { this.CurrentGameId = gameId; this.CurrentEnemyNick = enemyNick; this.ShowGameWindow(startChar, false); }); this._proxy.SubscribeOn <string, string>( c => c.OnGameFinished, (result, reason) => { MessageScene msg = new MessageScene(); msg.SetText(result + ":\n" + reason); this._gui.Screen.Desktop.Children.Add(msg); msg.BringToFront(); this._gameWindow?.Close(); }); }