コード例 #1
0
        private void SetSlots(ModelClasses.Save a_save)
        {
            String[] f_strings = a_save.TryToGetSaves();

            int f_post = 0;

            if (m_page < 0)
            {
                m_page = 0;
            }
            else if (f_strings.Length > 0)
            {
                for (int i = 0; i < m_slotText.Length; i++)
                {
                    f_post = i + m_page;

                    if (f_post < f_strings.Length)
                    {
                        m_slotText[i] = f_strings[f_post];
                    }
                    else
                    {
                        m_slotText[i] = "Empty";
                    }
                }
            }
            else
            {
                for (int i = 0; i < m_slotText.Length; i++)
                {
                    m_slotText[i] = "Empty";
                }
            }
        }
コード例 #2
0
        public Menu(GameAssets a_gameAssets, ModelClasses.Save a_save)
        {
            //Creates and sets the width, height and position on screen of menu rectangles
            InitializeMenu();

            //Creates the button and checkboxes
            InitializeItems(a_gameAssets, a_save);
        }
コード例 #3
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            m_mapSize = 48;

            graphics.PreferredBackBufferHeight = 800;
            graphics.PreferredBackBufferWidth  = 1024;

            if (!m_debugView.m_debugOptions.m_withVS)
            {
                graphics.SynchronizeWithVerticalRetrace = false;
                IsFixedTimeStep = false;
            }

            graphics.ApplyChanges();

            //graphics.ToggleFullScreen();

            m_windowHeight = graphics.GraphicsDevice.Viewport.Height;
            m_windowWidth  = graphics.GraphicsDevice.Viewport.Width;

            m_save = new ModelClasses.Save();

            m_menu = new ViewClasses.Menu.Menu(m_gameAssets, m_save);

            m_game         = new ModelClasses.Game(m_gameAssets, m_mapSize, m_mapSize);
            m_game.m_state = ModelClasses.Game.GameState.Main;

            m_gameAssets.LoadHeightMap(graphics.GraphicsDevice, m_game.m_map);

            m_gameView = new ViewClasses.GameView(graphics.GraphicsDevice, m_gameAssets, m_game);

            m_game.SetParticleHandler(m_gameView.m_particleHandler);

            m_gameView.m_mapTransformer.LoadGraphicsContent(graphics.GraphicsDevice);

            m_debugView.InitilizePositions();

            //LOLOL  Mouse wasn't visible for a strategy game at first, LOLOL!!
            IsMouseVisible = true;
            Window.Title   = "Cubes are cute";

            ViewClasses.BoundingBoxBuffer.InitiliazeBuffers(graphics.GraphicsDevice);
        }
コード例 #4
0
        //Creates and setts text and assets for each button and checkbox
        public void InitializeItems(GameAssets a_gameAssets, ModelClasses.Save a_save)
        {
            //Set text for buttons and checkboxes
            SetText();

            SetButtons(m_mainButtons, m_mainText);

            SetButtons(m_menuButtons, m_menuText);

            SetSlots(a_save);

            SetButtons(m_saves, m_slotText);

            SetButtons(m_loaded, m_slotText);

            SetButtons(m_optionsButtons, m_optText);

            SetCheckBoxes(a_gameAssets, m_checkBoxes, m_checkText);

            SetName();
        }
コード例 #5
0
        public void Draw(SpriteBatch a_spriteBatch, GameAssets a_gameAssets, ModelClasses.Game a_game, GraphicsDevice a_gd, DebugView a_debugView, ModelClasses.Save a_save, float a_elapsedTime)
        {
            //Sets the view matrix that is used by the shader
            m_camera.SetViewMatrix();
            m_camera.SetElapsedTime(a_elapsedTime);

            //DrawBackground(a_gameAssets.m_ground);

            //Draws a unit foreach unit added to a_game.m_units List of type Unit.
            m_mapTransformer.DrawMap(a_gd, m_camera);
            DrawGame(a_game, a_gameAssets, a_elapsedTime);
            DrawSelectionBorder(a_game.m_player, a_gd);

            //Draws HUD
            m_HUD.Draw(a_spriteBatch, a_gameAssets, a_game);
        }
コード例 #6
0
 //Updates the save/load menus to populate new saves
 public void UpdateSlots(GameAssets a_assets, ModelClasses.Save a_save)
 {
     InitializeItems(a_assets, a_save);
 }
コード例 #7
0
        private void DrawMenu(SpriteBatch a_spriteBatch, ModelClasses.Game a_game, GameAssets a_gameAssets, ModelClasses.Save a_save)
        {
            if (m_menuState == MenuState.Main || m_menuState == MenuState.PreGame || m_menuState == MenuState.InGameMenu || m_menuState == MenuState.Options ||
                m_menuState == MenuState.DebugMenu || m_menuState == MenuState.Save || m_menuState == MenuState.Load ||
                m_menuState == MenuState.Win || m_menuState == MenuState.Lose)
            {
                if (a_game.m_state == ModelClasses.Game.GameState.Main)
                {
                    DrawObject(a_spriteBatch, a_gameAssets.m_main, m_mainBackground, Color.White);
                }

                DrawObject(a_spriteBatch, a_gameAssets.m_background, m_menu, Color.White);
            }

            if (m_menuState == MenuState.Main)
            {
                //Draws the items in the main screen
                DrawMenuItems(a_spriteBatch, a_gameAssets, m_mainButtons);
            }
            else if (m_menuState == MenuState.PreGame)
            {
                DrawMenuItems(a_spriteBatch, a_gameAssets, null);
            }
            else if (m_menuState == MenuState.InGameMenu)
            {
                //Draws the items in menu screen
                DrawMenuItems(a_spriteBatch, a_gameAssets, m_menuButtons);
            }
            else if (m_menuState == MenuState.Options)
            {
                //Draws the items in options screen
                DrawMenuItems(a_spriteBatch, a_gameAssets, m_optionsButtons);
            }
            else if (m_menuState == MenuState.DebugMenu)
            {
                //Draws the items in debug screen
                DrawMenuItems(a_spriteBatch, a_gameAssets, m_checkBoxes);
            }
            else if (m_menuState == MenuState.Save)
            {
                //Draws the saveslots
                DrawMenuItems(a_spriteBatch, a_gameAssets, m_saves);
            }
            else if (m_menuState == MenuState.Load)
            {
                DrawMenuItems(a_spriteBatch, a_gameAssets, m_loaded);
            }
            else if (m_menuState == MenuState.Win)
            {
                DrawMenuItems(a_spriteBatch, a_gameAssets, null);
            }
            else if (m_menuState == MenuState.Lose)
            {
                DrawMenuItems(a_spriteBatch, a_gameAssets, null);
            }
        }
コード例 #8
0
        public void Draw(SpriteBatch a_spritebatch, GameAssets a_gameAssets, ModelClasses.Game a_game, DebugView a_debugView, ModelClasses.Save a_save)
        {
            a_spritebatch.Begin();

            //Checks debugoptions and checks the options in Debug menu if they return true else unchecks them
            CheckState(a_debugView);

            //Draws differint screens depending on if u won or lost
            if (a_game.m_state == ModelClasses.Game.GameState.GameOver)
            {
                if (a_game.HasWon(a_game.m_player))
                {
                    m_menuState = ViewClasses.Menu.Menu.MenuState.Win;
                }
                else
                {
                    m_menuState = ViewClasses.Menu.Menu.MenuState.Lose;
                }
            }

            //Draws the pause overlay that is transparent (black) if state is Pause ^_^
            if (a_game.m_state == ModelClasses.Game.GameState.Pause)
            {
                DrawObject(a_spritebatch, a_gameAssets.m_pause, m_pause, Color.White);
            }

            //Draws the menu
            DrawMenu(a_spritebatch, a_game, a_gameAssets, a_save);

            a_spritebatch.End();
        }