Exemplo n.º 1
0
        /// <summary>
        /// default constructor to create the console view objects
        /// </summary>
        public ConsoleView(Survivor gameSurvivor, WorldContents worldContents)
        {
            _gameSurvivor  = gameSurvivor;
            _worldContents = worldContents;

            _viewStatus = ViewStatus.PlayingGame;

            InitializeDisplay();
        }
Exemplo n.º 2
0
        public static List <string> StatusBox(Survivor survivor, WorldContents _worldContents)
        {
            List <string> statusBoxText = new List <string>();

            statusBoxText.Add($"Experience Points: {survivor.Exp}\n");
            statusBoxText.Add($"Health: {survivor.Health}\n");

            return(statusBoxText);


            #endregion
        }
Exemplo n.º 3
0
        /// <summary>
        /// initialize the major game objects
        /// </summary>
        private void InitializeGame()
        {
            _gameSurvivor    = new Survivor();
            _worldContents   = new WorldContents();
            _gameConsoleView = new ConsoleView(_gameSurvivor, _worldContents);
            _gameConsoleView.DisplayStatusBox();
            SurvivorObject survivorObject;
            Friendly       friendly;

            _playingGame = true;

            //add event handler for adding/subtracting to/from inventory
            foreach (GameObject gameObject in _worldContents.GameObjects)
            {
                if (gameObject is SurvivorObject)
                {
                    survivorObject = gameObject as SurvivorObject;
                    survivorObject.ObjectAddedToInventory += HandleObjectAddedToInventory;
                }
            }

            //event handler for speaking with and unlocking room
            foreach (Npc npc in _worldContents.Npcs)
            {
                if (npc is Friendly)
                {
                    friendly = npc as Friendly;
                    friendly.FriendlyTalkedTo += HandleNpcTalkedTo;
                }
            }

            //add initial items to the survivor's inventory
            _gameSurvivor.Inventory.Add(_worldContents.GetGameOjbectById(5) as SurvivorObject);
            _gameSurvivor.Inventory.Add(_worldContents.GetGameOjbectById(6) as SurvivorObject);

            Console.CursorVisible = false;
        }