Пример #1
0
 public void InitInventory(Player player, GAMESTATE returnState) // could be changed into an input method to open inventory, currently player opens inventory: OpenInventoryOutput()
 {
     returnto = returnState;                                     // sets return state
     CreateBackground();                                         // creates a new background for inventory upon opening it
     hud.Update(player, this);                                   // init stats for inventory hud
     hud.ReloadText();
 }
Пример #2
0
 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);
 }
Пример #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);
 }
Пример #4
0
        public GAMESTATE Update(Player player, GAMESTATE gameState, Item item, Inventory inventory)
        {
            hud.Update(player, inventory);
            Draw();
            ChooseItem(inventory, player);

            ConsoleKeyInfo exitDecision = Console.ReadKey(true);

            if (exitDecision.Key == ConsoleKey.Escape)
            {
                return(ExitTrade());
            }
            return(gameState);
        }
Пример #5
0
        public GAMESTATE Update(Player player, GAMESTATE gameState, Item item, Inventory inventory)
        {
            hud.Update(player, inventory);
            Fight(player, opponent, item, inventory);

            // ends fight
            if (player.Health()[(int)STATUS.CURRENT] == 0)
            {
                return(GameOver());
            }
            if (opponent.Health()[(int)STATUS.CURRENT] == 0)
            {
                opponent.CheckForDying(camera, hud);
                hud.DisplayText($"< " + player.Name() + " has picked up $" + opponent.currentMoney + " that the " + opponent.Name() + " dropped! >");
                player.currentMoney = player.currentMoney + opponent.currentMoney;
                return(End());
            }
            return(gameState);
        }
        // ----- 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;
            }
        }