Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            Room StartingRoom = new Room(10, 10);
            //StartingRoom.AddWall(0, 0).AddWall(1, 0).AddWall(2, 0).AddWall(3, 0).AddWall(4, 0).AddWall(4, 1).AddWall(4, 2).AddWall(0, 1).AddWall(0, 2);
            Room NewRoom = new Room(5, 5);

            Player p = StartingRoom.AddPlayer(1, 1);
            Random r = new Random();

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    if (r.Next(100) < 10)
                    {
                        Entity e = new DefaultEntity(j, i, "nothing", NewRoom, new Key(1, p), true, '░', false);
                        StartingRoom.ImmutableMap[j][i] = e;
                        StartingRoom.map[j][i]          = e;
                    }
                }
            }
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    if (r.Next(100) < 25)
                    {
                        StartingRoom.AddWall(j, i);
                    }
                }
            }
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    if (r.Next(100) < 10)
                    {
                        Entity e = new Enemy(j, i, 10, "Monster", StartingRoom);
                        StartingRoom.ImmutableMap[j][i] = e;
                        StartingRoom.map[j][i]          = e;
                    }
                }
            }
            StartingRoom.AddPlayer(1, 1);
            StartingRoom.AddExit(4, 4, false, true, NewRoom, 1, 1, false, true);
            StartingRoom.ImmutableMap[4][4].item           = null;
            StartingRoom.ImmutableMap[4][4].Representation = 'Ɵ';
            Stream stream = Console.OpenStandardInput();

            p.GetInput(stream);

            while (p.Running)
            {
                ;
            }

            stream.Dispose();
        }
Exemplo n.º 2
0
        public static bool CanUse(string item)
        {
            bool result = true; // for testing
            Room room   = Game.currentRoom;

            switch (item)
            {
            case "red key":
                if (room.LocX == redRoomX && room.LocY == redRoomY)
                {
                    room.AddExit("right");
                    Console.WriteLine("\n    The key unlocks the Red door");
                }
                else
                {
                    Console.WriteLine("\n     This doenst seem to be the room to use the " + item + " in.");
                }
                break;

            case "blue key":
                if (room.LocX == blueRoomX && room.LocY == blueRoomY)
                {
                    room.AddExit("right");
                    Console.WriteLine("\n    The key unlocks the Blue door");
                }
                else
                {
                    Console.WriteLine("\n     This doenst seem to be the room to use the " + item + " in.");
                }
                break;

            case "yellow key":
                if (room.LocX == yellowRoomX && room.LocY == yellowRoomY)
                {
                    room.AddExit("up");
                    Console.WriteLine("\n    The key unlocks the Yellow door");
                }
                else
                {
                    Console.WriteLine("\n     This doenst seem to be the room to use the " + item + " in.");
                }
                break;
            }
            return(result);
        }
Exemplo n.º 3
0
        private void CreateSampleHouse()
        {
            Room r1 = new Room("ENTRY");
            Room r2 = new Room("BEDROOM");
            Room r3 = new Room("CORRIDOR");

            //Add the Exits for this building
            r1.AddExit(r3);
            r3.AddExit(r1);
            r3.AddExit(r2);
            r2.AddExit(r3);

            //Add Items
            r2.AddItem(new Item("TABLE"));
            r2.AddItem(new Item("CHAIR"));
            Item cup = new Item("CUP");

            r2.AddItem(cup);

            Key         = cup;
            CurrentRoom = r1;
        }