Example #1
0
        public void FixModifyedConsole(HUD hud) // resets the display if the console is modifyed
        {
            //only activates if console is modifyed
            if (Console.WindowHeight != savedHeight || Console.WindowWidth != savedWidth)
            {
                // reset range check to current size
                savedHeight = Console.WindowHeight;
                savedWidth  = Console.WindowWidth;

                // if console is too small, fixes itself
                if (Console.WindowHeight < minConsoleSizeHeight || Console.WindowWidth < minConsoleSizeWidth)
                {
                    Console.WindowHeight = minConsoleSizeHeight; Console.WindowWidth = minConsoleSizeWidth;
                    FixModifyedConsole(hud);
                }

                //set up display if console isnt too small
                if (Console.WindowHeight >= minConsoleSizeHeight || Console.WindowWidth >= minConsoleSizeWidth)
                {
                    // set up display for new size
                    Console.Clear();
                    DrawBorder(); // border
                    hud.DrawTextBox();
                }
            }
        }
 public GAMESTATE Begin(Player player, Vendor vendor, Inventory inventory, bool isPlayer = false)
 {
     vendorBeingTradedWith = vendor;
     hud = new HUD(player.Name());
     Console.Clear();
     hud.Update(player, inventory);
     hud.DrawTextBox();
     return(GAMESTATE.TRADING);
 }
Example #3
0
 public GAMESTATE Begin(Player player, Enemy enemy, Inventory inventory, bool isPlayer = false)
 {
     turn     = isPlayer;
     opponent = enemy;
     hud      = new HUD(player.Name());
     Console.Clear();
     hud.Update(player, inventory);
     hud.DrawTextBox();
     return(GAMESTATE.BATTLE);
 }
        // ----- Game loop
        public void Game()
        {
            Toolkit.FixDisplay(camera, hud);

            // check for gameover
            GameOverPlayerDeath(player, _gameState);
            GameOverWinCondition(player, hud, _gameState);

            // game loop
            switch (_gameState)
            {
            //update what the screen displays
            case GAMESTATE.CHANGEMAP:
                #region Change Map
                //clear console & objects
                Console.Clear();
                items.Clear();
                enemies.Clear();
                doors.Clear();
                vendors.Clear();
                //read new map info/ load it into the camera
                map.loadMap();
                camera.GameWorldGetMap(map);
                //create camera border /reload TextBox(change to create new hud for every map)
                camera.DrawBorder();
                hud.DrawTextBox();
                // creating object managers
                enemies = manageEnemies.Init(map.getEnemyHold().Split('|'), dataLoader);
                items   = (manageObjects[(int)OBJECTS.ITEM] as ItemManager).Init(map.getItemHold().Split('|'));
                doors   = (manageObjects[(int)OBJECTS.DOOR] as DoorManager).Init(map.getDoorHold().Split('|'));
                vendors = manageVendors.Init(map.getVendorHold().Split('|'));

                //change state to display the freshly loaded map & objects
                _gameState = GAMESTATE.MAP;
                #endregion
                break;

            case GAMESTATE.MAP:
                #region Play Map
                //DRAW
                //gameplay elements to gameworld, Heirarchy: bottomlayer is on top
                (manageObjects[(int)OBJECTS.ITEM] as ItemManager).Draw(items, camera);
                (manageObjects[(int)OBJECTS.DOOR] as DoorManager).Draw(doors, camera);
                manageEnemies.Draw(enemies, camera);
                manageVendors.Draw(vendors, camera);
                player.Draw(camera);
                //GameWorld / including objects added above
                camera.Draw(player);

                //UPDATE
                //by prioity, Heirarchy: highest is on top
                hud.Update(player, inventory);
                _gameState = player.Update(enemies, doors, items, map, camera, hud, battle, inventory, _gameState, vendors, tradeMenu);
                _gameState = manageEnemies.Update(enemies, player, map, camera, hud, battle, inventory, _gameState);
                _gameState = manageVendors.Update(vendors, player, map, camera, hud, battle, inventory, _gameState);
                (manageObjects[(int)OBJECTS.ITEM] as ItemManager).Update(items, player, inventory, hud);
                camera.Update(map);     // updated last to catch all character and object updates on gameworld
                #endregion
                break;

            case GAMESTATE.BATTLE:
                //DRAW
                battle.Draw();
                //UPDATE
                _gameState = battle.Update(player, _gameState, items[0], inventory);
                break;

            case GAMESTATE.INVENTORY:
                //DRAW
                inventory.Draw();
                //UPDATE
                _gameState = inventory.Update(_gameState, player, items[0], inventory, tradeMenu);
                break;

            case GAMESTATE.GAMEOVER:
                GameOverMessage();
                break;

            case GAMESTATE.TRADING:
                //tradeMenu.Draw();
                _gameState = tradeMenu.Update(player, _gameState, items[0], inventory);
                break;
            }
        }