public override void Update(GameTime gameTime, Game1 game)
        {
            base.Update(gameTime, game);
            goToBattleButton.Update(gameTime);

            if (goToBattleButton.ContainsMouse())
            {
                buttonSelected = true;

                if (Game1.bIsActive && Mouse.GetState().LeftButton == ButtonState.Pressed && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    buttonPressed = true;
                }
                else
                {
                    buttonPressed = false;
                }
            }
            else
            {
                buttonSelected = false;
            }

            if (buttonPressed)
            {
                HandleSelection();
            }
        }
Пример #2
0
        public override void Update(GameTime gameTime, Game1 game)
        {
            Vector2 EditorCursorPos = Mouse.GetState().Position.ToVector2();

            Step3Button.Update(gameTime);
            Step3Button.bButtonSelected = Step3Button.ButtonBox().Contains(EditorCursorPos);
            if (Step3Button.bButtonSelected && Mouse.GetState().LeftButton == ButtonState.Pressed && !KeyboardMouseUtility.bMousePressed)
            {
                selectedFile = "SKIP";
            }

            if (Game1.bIsDebug)
            {
                System.Windows.Forms.MessageBox.Show("Choose a texture file from within the application's Content folder please.");
                openCollisionTexture.Filter           = "Texture File|*.xnb";
                openCollisionTexture.InitialDirectory = Game1.rootContent;
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Choose a texture file from within the application's Content Mod folder please.");
                openCollisionTexture.Filter           = "Texture File|*.jpg;*.png;*.jpeg";
                openCollisionTexture.InitialDirectory = Game1.rootContentExtra;
            }
            openCollisionTexture.Title = "Load Base Texture";
            if (Game1.bIsDebug)
            {
                System.Windows.Forms.DialogResult dia = openCollisionTexture.ShowDialog();

                if (System.Windows.Forms.DialogResult.OK == dia && openCollisionTexture.FileName.Contains(Game1.rootContent))
                {
                    String fi = Path.GetFileNameWithoutExtension(openCollisionTexture.FileName);
                    String fo = Path.GetDirectoryName(openCollisionTexture.FileName.Replace(Game1.rootContent, ""));
                    Console.WriteLine(fo + fi);
                    selectedFile = Path.Combine(fo, fi);
                }
                else if (System.Windows.Forms.DialogResult.Cancel == dia)
                {
                    SpriteEditor.currentScene = (int)SpriteEditor.SpriteEditorScenes.SpritePicker;
                    System.Windows.Forms.MessageBox.Show("Cancelled, returning to base texture picker.");
                }
            }
            else
            {
                System.Windows.Forms.DialogResult dia = openCollisionTexture.ShowDialog();

                if (System.Windows.Forms.DialogResult.OK == dia && openCollisionTexture.FileName.Contains(Game1.rootContentExtra))
                {
                    String fi = Path.GetFileNameWithoutExtension(openCollisionTexture.FileName);
                    String fo = Path.GetDirectoryName(openCollisionTexture.FileName.Replace(Game1.rootContent, ""));
                    Console.WriteLine(fo + fi);
                    selectedFile = Path.Combine(fo, fi);
                }
                else if (System.Windows.Forms.DialogResult.Cancel == dia)
                {
                    SpriteEditor.currentScene = (int)SpriteEditor.SpriteEditorScenes.SpritePicker;
                    System.Windows.Forms.MessageBox.Show("Cancelled, returning to base texture picker.");
                }
            }
        }
Пример #3
0
        public override void Update(GameTime gameTime, Game1 game)
        {
            if (MapEditor.bIsRunning)
            {
                #region firstrun
                if (firstRun)
                {
                    mapXSizeInput = new ActiveInput("X-Size map: ", "0", Vector2.Zero, game);
                    mapYSizeInput = new ActiveInput("Y-Size map: ", "0", Vector2.Zero, game);
                    mapNameInput  = new ActiveInput("Map name: ", "Map", Vector2.Zero, game);
                    mapXSizeInput.bNumericInputOnly = true;
                    mapYSizeInput.bNumericInputOnly = true;
                    activeInputButtons.Add(mapXSizeInput);
                    activeInputButtons.Add(mapYSizeInput);
                    activeInputButtons.Add(mapNameInput);
                    mapXSizeInput.bHasMinValue = true;
                    mapXSizeInput.minValue     = 1;
                    mapYSizeInput.bHasMinValue = true;
                    mapYSizeInput.minValue     = 1;

                    firstRun = false;

                    localScenes.Add(mapBuilder);
                }
                #endregion

                if (Game1.bIsDebug)
                {
                    openMap.Filter           = "CGMAPC Files (.cgmapc)|*.cgmapc";
                    openMap.InitialDirectory = Game1.rootTBAGW;
                }
                else
                {
                    openMap.Filter           = "CGMAP Files (.cgmap)|*.cgmap";
                    openMap.InitialDirectory = Game1.rootContentExtra;
                }
                openMap.FilterIndex = 1;
                openMap.Multiselect = false;
                saveMap.Filter      = "CGMAP Files (.cgmap)|*.cgmap";
                saveMap.Title       = "Save a CGMAP File";
                if (Game1.bIsDebug)
                {
                    saveMap.InitialDirectory = Game1.rootTBAGW;
                }
                else
                {
                    saveMap.InitialDirectory = Game1.rootContentExtra;
                }

                bool usingActiveInput = false;

                Vector2 EditorCursorPos = Mouse.GetState().Position.ToVector2() + new Vector2(cameraPosX, -cameraPosY);
                loadMapButton.Update(gameTime);
                if (loadMapButton.buttonBox.Contains(EditorCursorPos))
                {
                    if (Mouse.GetState().LeftButton == ButtonState.Pressed && Game1.bIsActive && !KeyboardMouseUtility.AnyButtonsPressed())
                    {
                        System.Windows.Forms.DialogResult testDia = openMap.ShowDialog();

                        if (testDia == System.Windows.Forms.DialogResult.OK && openMap.FileName.Contains(openMap.InitialDirectory))
                        {
                            //  Console.WriteLine("You selected: " + openMap.FileName);
                            loadedMap = EditorFileWriter.MapReader(openMap.FileName);
                        }
                    }
                }

                #region MapEditor only logic

                foreach (var item in activeInputButtons)
                {
                    item.Update(gameTime);
                    item.Contains(EditorCursorPos);
                }

                foreach (var item in activeInputButtons)
                {
                    if (item.bEnableInput)
                    {
                        usingActiveInput = true;
                        break;
                    }
                }

                int i = 0;
                foreach (var item in activeInputButtons)
                {
                    item.position = new Vector2(100, 200 + 75 * i);
                    i++;
                }

                CreateMapButton.position = new Vector2(activeInputButtons[activeInputButtons.Count - 1].position.X, activeInputButtons[activeInputButtons.Count - 1].position.Y + 75);

                CreateMapButton.Update(gameTime);
                if (CreateMapButton.ButtonBox().Contains(EditorCursorPos) && Mouse.GetState().LeftButton == ButtonState.Pressed && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    bool bCorrectSave = false;
                    while (!bCorrectSave)
                    {
                        try
                        {
                            if (Game1.bIsDebug)
                            {
                                BasicMap newMap = new BasicMap();
                                newMap.mapName           = mapNameInput.ReturnInputString();
                                saveMap.InitialDirectory = Game1.rootTBAGW;
                                System.Windows.Forms.DialogResult dia = saveMap.ShowDialog();
                                if (saveMap.FileName != "" && dia == System.Windows.Forms.DialogResult.OK && saveMap.FileName.StartsWith(saveMap.InitialDirectory))
                                {
                                    newMap.mapName = Path.GetFileNameWithoutExtension(saveMap.FileName);
                                    mapNameInput.AssignInput(Path.GetFileNameWithoutExtension(saveMap.FileName));
                                    //  Console.WriteLine("Line= " + Path.GetDirectoryName(saveMap.FileName));
                                    EditorFileWriter.MapWriter(saveMap.FileName, newMap);
                                    Console.WriteLine(newMap.mapLocation);
                                    loadedMap    = EditorFileWriter.MapReader(saveMap.FileName);;
                                    bCorrectSave = true;
                                }
                                else if (dia == System.Windows.Forms.DialogResult.Cancel)
                                {
                                    bCorrectSave = true;
                                }
                                else
                                {
                                    //  Console.WriteLine("Yow");
                                    System.Windows.Forms.MessageBox.Show("Make sure you save the map within the application folder.");
                                }
                            }
                            else
                            {
                                BasicMap newMap = new BasicMap();
                                newMap.mapName           = mapNameInput.ReturnInputString();
                                saveMap.InitialDirectory = Game1.rootContentExtra;
                                System.Windows.Forms.DialogResult dia = saveMap.ShowDialog();
                                if (saveMap.FileName != "" && dia == System.Windows.Forms.DialogResult.OK && saveMap.FileName.StartsWith(Game1.rootContentExtra))
                                {
                                    newMap.mapName = Path.GetFileNameWithoutExtension(saveMap.FileName);
                                    mapNameInput.AssignInput(Path.GetFileNameWithoutExtension(saveMap.FileName));
                                    //  Console.WriteLine("Line= " + Path.GetDirectoryName(saveMap.FileName));
                                    EditorFileWriter.MapWriter(saveMap.FileName, newMap);
                                    Console.WriteLine(newMap.mapLocation);
                                    loadedMap    = EditorFileWriter.MapReader(saveMap.FileName);;
                                    bCorrectSave = true;
                                }
                                else if (dia == System.Windows.Forms.DialogResult.Cancel)
                                {
                                    bCorrectSave = true;
                                }
                                else
                                {
                                    //  Console.WriteLine("Yow");
                                    System.Windows.Forms.MessageBox.Show("Make sure you save the map within the application folder.");
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Console.Out.WriteLine("Error:\n" + e);
                        }
                    }
                }

                if (currentScene == 0 && !usingActiveInput)
                {
                    if (Keyboard.GetState().IsKeyDown(Keys.S))
                    {
                        cameraPosY -= cameraSpeed;
                    }

                    if (Keyboard.GetState().IsKeyDown(Keys.Z))
                    {
                        cameraPosY += cameraSpeed;
                    }

                    if (Keyboard.GetState().IsKeyDown(Keys.Q))
                    {
                        cameraPosX -= cameraSpeed;
                    }

                    if (Keyboard.GetState().IsKeyDown(Keys.D))
                    {
                        cameraPosX += cameraSpeed;
                    }
                }
                #endregion

                if (loadedMap != default(BasicMap))
                {
                    currentScene     = (int)MapEditor.MapEditorScenes.MapBuilder;
                    bRerunFileLoader = true;
                    mapBuilder.Start(game, loadedMap);
                    loadedMap  = default(BasicMap);
                    bIsRunning = false;
                }



                if (Mouse.GetState().RightButton == ButtonState.Pressed && !KeyboardMouseUtility.AnyButtonsPressed() && currentScene > 0)
                {
                    switch (currentScene)
                    {
                    case (int)MapEditorScenes.MapEditor:
                        System.Windows.Forms.DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("You sure want to exit Map editing? NOTE: be sure to save first!", "Leaving", System.Windows.Forms.MessageBoxButtons.YesNo);
                        if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                        {
                            currentScene--;
                        }
                        else if (dialogResult == System.Windows.Forms.DialogResult.No)
                        {
                            //do something else
                        }

                        break;
                    }
                }
            }
            else if (!MapEditor.bIsRunning)
            {
                mapBuilder.Update(gameTime, game);
            }

            MapEditorMatrix = Matrix.CreateTranslation(-cameraPosX, cameraPosY, 1);
        }