Exemple #1
0
 public MenuScreen(SpriteBatch spriteBatch, GraphicsDevice graphicsDevice, GameWindow Window, ContentManager Content, newMap NewMap)
 {
     this.spriteBatch    = spriteBatch;
     this.graphicsDevice = graphicsDevice;
     this.Window         = Window;
     this.Content        = Content;
     this.NewMap         = NewMap;
 }
Exemple #2
0
        public void Update(out State state, out newMap NewMap, EditScreen editScreen)
        {
            mouseState = Mouse.GetState();
            System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
            state  = State.menuScreen;
            NewMap = this.NewMap;

            for (int i = 0; i < menuItems.Count; i++)
            {
                if (mouseState.X > Window.ClientBounds.Width / 2 - menuFont.MeasureString(menuItems[i]).X / 2 && mouseState.X < Window.ClientBounds.Width / 2 + menuFont.MeasureString(menuItems[i]).X / 2 && mouseState.Y > 150 + i * sepSpace && mouseState.Y < 150 + i * sepSpace + menuFont.MeasureString(menuItems[i]).Y)
                {
                    magnifyIndex = i;
                    break;
                }
                else
                {
                    magnifyIndex = -1;
                }
            }

            for (int i = 0; i < menuItems.Count; i++)
            {
                if (mouseState.X > Window.ClientBounds.Width / 2 - menuFont.MeasureString(menuItems[i]).X / 2 && mouseState.X < Window.ClientBounds.Width / 2 + menuFont.MeasureString(menuItems[i]).X / 2 && mouseState.Y > 150 + i * sepSpace && mouseState.Y < 150 + i * sepSpace + menuFont.MeasureString(menuItems[i]).Y&& menuItems[i] == "Exit" && mouseState.LeftButton == ButtonState.Pressed)
                {
                    state = State.exit;
                }
                else if (mouseState.X > Window.ClientBounds.Width / 2 - menuFont.MeasureString(menuItems[i]).X / 2 && mouseState.X < Window.ClientBounds.Width / 2 + menuFont.MeasureString(menuItems[i]).X / 2 && mouseState.Y > 150 + i * sepSpace && mouseState.Y < 150 + i * sepSpace + menuFont.MeasureString(menuItems[i]).Y&& menuItems[i] == "NewMap" && mouseState.LeftButton == ButtonState.Pressed)
                {
                    state       = State.newMap;
                    this.NewMap = new newMap();
                    NewMap      = this.NewMap;
                    NewMap.Show();
                }

                else if (mouseState.X > Window.ClientBounds.Width / 2 - menuFont.MeasureString(menuItems[i]).X / 2 && mouseState.X < Window.ClientBounds.Width / 2 + menuFont.MeasureString(menuItems[i]).X / 2 && mouseState.Y > 150 + i * sepSpace && mouseState.Y < 150 + i * sepSpace + menuFont.MeasureString(menuItems[i]).Y&& menuItems[i] == "LoadMap" && mouseState.LeftButton == ButtonState.Pressed)
                {
                    openFileDialog.ShowDialog();
                }
            }

            if (openFileDialog.FileName != "")
            {
                state = State.editScreen;
                Stream          stream = File.Open(openFileDialog.FileName, FileMode.Open);
                BinaryFormatter bin    = new BinaryFormatter();
                var             obj    = (object[])bin.Deserialize(stream);
                var             map    = (int[][][][][])(obj[0]);
                editScreen.map = map;
                editScreen.InitializeMap();
                stream.Close();
            }
        }