示例#1
0
        static void Main(string[] args)
        {
            player = Player.getInstance();

            createStartRoom();
            CIO.Initialize();
            currentRoom = Room.AllRooms[typeof(GameContent.Rooms.Forest_start)];
            GlobalCommands.GiveSword();
            player.LearnSpell(Spell.Flames);


            while (true)
            {
                Console.WriteLine("#########################");
                Room r = currentRoom;
                if (r.OnEnter())
                {
                    Room nextroom = null;
                    while (nextroom == null)
                    {
                        Optionhandler h;
                        if (r.ActivitiesInRoom != null)//print activities if there are any
                        {
                            h = new Optionhandler(r.name + ". Activities:");
                            h.AddOptions(r.ActivitiesInRoom);
                            h.AddHeading("Next Rooms:");
                        }
                        else
                        {
                            h = new Optionhandler(r.name + ". next room?");
                        }
                        h.AddOptions(Optionhandler.RoomsToOption(r.nextRooms));
                        Option selectedOpt = h.selectOption();
                        if (selectedOpt.GetType().IsSubclassOf(typeof(Room)))
                        {
                            nextroom = (Room)selectedOpt;
                        }
                    }
                    CIO.Clear();
                    currentRoom.OnExit();
                    currentRoom = nextroom;
                }
                else
                {
                    CIO.Clear();
                    r.OnExit();
                }
            }
        }