Beispiel #1
0
        /// <summary>
        /// Elaborates on the player command, writing the results of command to window
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public string GetPlayerSubject(GameController.Commands command)
        {
            string output = "";

            switch (command)    //  Switch based on inputed command
            {
                case GameController.Commands.Go:    //  Player wants to go somewhere
                    //  Move to game controller
                    break;

                case GameController.Commands.Look:  //  Player wants to look at something

                    Console.WriteLine("Look at what?"); //  Prompt player for clarification
                    string targetInput = Console.ReadLine().ToLower();

                    //  Create string array's of valid  objects to look at
                    string[] self = { "me", "myself" };
                    string[] guards;
                    string[] staff;

                    #region Getting subjects
                    {   //  Get all the guards

                        List<Guard> guardList = new List<Guard>();
                        foreach (Guard g in _guardList.Guards)
                        {   //  If a guard is in the same room as the player, add them to the list
                            if (g.CurrentRoom[0] == _player.CurrentRoom[0] & g.CurrentRoom[1] == _player.CurrentRoom[1])
                            {
                                guardList.Add(g);
                            }
                        }
                        guards = new string[guardList.Count];   //  Add the guard's name from the list to the array
                        for (int i = 0; i < guardList.Count; i++)
                        {
                            guards[i] = guardList.ElementAt(i).Name.ToLower();
                        }
                    }

                    {   //  Get all the staff

                        List<Staff> staffList = new List<Staff>();
                        foreach (Staff s in _staffList.Staff)
                        {   //  If a staff is in the same room as the player, add them to the list
                            if (s.CurrentRoom[0] == _player.CurrentRoom[0] & s.CurrentRoom[1] == _player.CurrentRoom[1])
                            {
                                staffList.Add(s);
                            }
                        }
                        staff = new string[staffList.Count];    //  Add the staff's name from the list to the array
                        for (int i = 0; i < staffList.Count; i++)
                        {
                            staff[i] = staffList.ElementAt(i).Name.ToLower();
                        }
                    }
                    #endregion

                    if (self.Contains(targetInput)) //  Player says "me" or "myself"
                    {
                        output = "I look awesome, obviously.";
                    }
                    else if (guards.Contains(targetInput))  //  Player says name of guard
                    {
                        foreach (Guard g in _guardList.Guards)
                        {
                            if (g.Name.ToLower() == targetInput)
                                output = g.Decription();
                        }
                    }
                    else if (staff.Contains(targetInput))   //  Player says name of staff
                    {
                        foreach (Staff s in _staffList.Staff)
                        {
                            if (s.Name.ToLower() == targetInput)
                                output = s.Decription();
                        }
                    }
                    else   //   Player says something that is not there
                    {
                        output = string.Format("There is no {0} here", targetInput);
                    }

                    break;

                //  The remaining commands don't need clarification
                default:
                    break;
            }

            return output;
        }
Beispiel #2
0
 static void Main(string[] args)
 {
     GameController gameController = new GameController();
 }