private void DrawRooms() //limit map to 50*50 and move the "camera" around the map
 {
     for (int i = XDrawingStart; i < XDrawingEnd; i++)
     {
         Console.Write("        ");
         for (int x = YDrawingStart; x < YDrawingEnd; x++)
         {
             if ((SingleTon.GetCursor().GetCords()[0] == i && SingleTon.GetCursor().GetCords()[1] == x))
             {
                 Console.ForegroundColor = ConsoleColor.Blue;
                 Console.Write("O");
                 Console.ForegroundColor = ConsoleColor.White;
             }
             else if (SingleTon.GetRooms()[i, x] == null)
             {
                 Console.ForegroundColor = ConsoleColor.Red;
                 Console.Write("#");
                 Console.ForegroundColor = ConsoleColor.White;
             }
             else
             {
                 Console.ForegroundColor = ConsoleColor.Green;
                 Console.Write("@");
                 Console.ForegroundColor = ConsoleColor.White;
             }
             Console.Write("   ");
         }
         Console.WriteLine("\n");
     }
 }
 private void DrawStats()
 {
     Console.WriteLine("World");
     Console.Write("X: " + SingleTon.GetRooms().GetLength(0) + "          ");
     Console.WriteLine("Y: " + SingleTon.GetRooms().GetLength(1));
     Console.WriteLine("Cursor X: " + SingleTon.GetCursor().GetX() + "     Y: " + SingleTon.GetCursor().GetY());
     Console.WriteLine("Rooms: " + (SingleTon.GetRooms().GetLength(0) * SingleTon.GetRooms().GetLength(1)));
 }
        private void CalculateDrawPos()
        {
            XDrawingStart = 0;
            YDrawingStart = 0;
            XDrawingEnd   = 0;
            YDrawingEnd   = 0;
            if (SingleTon.GetRooms().GetLength(0) < ScreenRes && SingleTon.GetRooms().GetLength(1) < ScreenRes)
            {
                XDrawingStart = 0;
                YDrawingStart = 0;
                XDrawingEnd   = SingleTon.GetRooms().GetLength(0);
                YDrawingEnd   = SingleTon.GetRooms().GetLength(1);
            }
            else
            {
                if ((SingleTon.GetCursor().GetX() - (ScreenRes / 2)) > 0)
                {
                    XDrawingStart += SingleTon.GetCursor().GetX() - (ScreenRes / 2);
                }
                else
                {
                    XDrawingEnd   += (ScreenRes / 2) - SingleTon.GetCursor().GetX();
                    XDrawingStart += 0;
                }

                if ((SingleTon.GetCursor().GetX() + (ScreenRes / 2)) < SingleTon.GetRooms().GetLength(0))
                {
                    XDrawingEnd = SingleTon.GetCursor().GetX() + (ScreenRes / 2);
                }
                else
                {
                    XDrawingStart += (ScreenRes / 2) - (SingleTon.GetRooms().GetLength(0) - SingleTon.GetCursor().GetX());
                    XDrawingEnd   += SingleTon.GetCursor().GetX() + (SingleTon.GetRooms().GetLength(0) - SingleTon.GetCursor().GetX());
                }

                if ((SingleTon.GetCursor().GetY() - (ScreenRes / 2)) > 0)
                {
                    YDrawingStart += SingleTon.GetCursor().GetY() - (ScreenRes / 2);
                }
                else
                {
                    YDrawingEnd  += (ScreenRes / 2) - SingleTon.GetCursor().GetY();
                    YDrawingStart = 0;
                }

                if ((SingleTon.GetCursor().GetY() + (ScreenRes / 2)) < SingleTon.GetRooms().GetLength(1))
                {
                    YDrawingEnd += SingleTon.GetCursor().GetY() + (ScreenRes / 2);
                }
                else
                {
                    YDrawingStart += (ScreenRes / 2) - (SingleTon.GetRooms().GetLength(1) - SingleTon.GetCursor().GetY());;
                    YDrawingEnd   += SingleTon.GetCursor().GetY() + (SingleTon.GetRooms().GetLength(1) - SingleTon.GetCursor().GetY());
                }
            }
        }
Example #4
0
        private void CheckRoomConnection() //check where there is unreachable areas
        {
            Room LastusedRoom;

            AllRooms       = SingleTon.GetRooms();
            RoomsConnected = new Room[SingleTon.GetRooms().GetLength(0), SingleTon.GetRooms().GetLength(1)];
            LastusedRoom   = AllRooms[SingleTon.GetCursor().GetX(), SingleTon.GetCursor().GetY()];
            RoomsConnected[SingleTon.GetCursor().GetX(), SingleTon.GetCursor().GetY()] = AllRooms[SingleTon.GetCursor().GetX(), SingleTon.GetCursor().GetY()];
            for (int i = 0; i < 50; i++)//maybe make it all rooms as amount of times to check or do a while loop to check for when some bool get's check for being stuck
            {
                LastusedRoom = CheckNeightboors(LastusedRoom);
            }
        }
        public bool KeyCommands(ConsoleKey key)
        {
            if (cursor == null)
            {
                cursor = SingleTon.GetCursor();
            }
            Console.WriteLine("Controls need a rework");
            switch (key)
            {
            case ConsoleKey.UpArrow:
                if (cursor.GetCords()[0] == 0)
                {
                    cursor.SetX(SingleTon.GetRooms().GetLength(0) - 1);
                    return(true);
                }
                else if (SingleTon.GetRooms()[cursor.GetX() - 1, cursor.GetY()] != null)
                {
                    cursor.SetX(cursor.GetX() - 1);
                    return(true);
                }
                cursor.SetCurrentRoom(SingleTon.GetRooms()[cursor.GetX(), cursor.GetY()]);
                break;

            case ConsoleKey.DownArrow:
                if (cursor.GetCords()[0] == (SingleTon.GetRooms().GetLength(0) - 1))
                {
                    cursor.SetX(0);
                    return(true);
                }
                else if (SingleTon.GetRooms()[cursor.GetX() + 1, cursor.GetY()] != null)
                {
                    cursor.SetX(cursor.GetX() + 1);
                    return(true);
                }
                cursor.SetCurrentRoom(SingleTon.GetRooms()[cursor.GetX(), cursor.GetY()]);

                break;

            case ConsoleKey.RightArrow:
                if (cursor.GetCords()[1] == (SingleTon.GetRooms().GetLength(1) - 1))
                {
                    cursor.SetY(SingleTon.GetRooms().GetLength(1) - 1);
                    return(true);
                }
                else if (SingleTon.GetRooms()[cursor.GetX(), cursor.GetY() + 1] != null)
                {
                    cursor.SetY(cursor.GetY() + 1);
                    return(true);
                }
                cursor.SetCurrentRoom(SingleTon.GetRooms()[cursor.GetX(), cursor.GetY()]);
                break;

            case ConsoleKey.LeftArrow:
                if (cursor.GetCords()[1] == 0)
                {
                    cursor.SetY(SingleTon.GetRooms().GetLength(0) - 1);
                    return(true);
                }
                else if (SingleTon.GetRooms()[cursor.GetX(), cursor.GetY() - 1] != null)
                {
                    cursor.SetY(cursor.GetY() - 1);
                    return(true);
                }
                cursor.SetCurrentRoom(SingleTon.GetRooms()[cursor.GetX(), cursor.GetY()]);
                return(true);
            }
            return(false);
        }