public static void Run() { Console.Clear(); Console.SetWindowSize(50, 25); Console.OutputEncoding = Encoding.UTF8; Console.CursorVisible = false; Console.Title = "Console Escape!"; FloorPlan floorPlan = new FloorPlan(1, 10); FloorPlan room2 = new FloorPlan(13, 49); Controller controller1 = new Controller(); Player user = new Player(1, 1, 'C'); user.InputReceived += controller1.UserInput; DateTime tickStart = DateTime.Now; DateTime now = DateTime.Now; SetMap(floorPlan, Environment.CurrentDirectory + @"\MapFiles\MainMap\"); SetMap(room2, Environment.CurrentDirectory + @"\MapFiles\SideMap\"); //testing doors, added a door on each side to go to the opposite side of the other room FloorDoor firstDoor = new FloorDoor(floorPlan, room2, 0, 10, room2.Rows - 1, 10); FloorDoor secondDoor = new FloorDoor(floorPlan, room2, floorPlan.Rows - 1, 10, 0, 10); FloorDoor thirdDoor = new FloorDoor(floorPlan, room2, 10, floorPlan.Columns - 1, 10, 0); FloorDoor fourthDoor = new FloorDoor(floorPlan, room2, 10, 0, 10, room2.Columns - 1); floorPlan.WallIn(); room2.WallIn(); firstDoor.Visible = false; secondDoor.Visible = false; floorPlan.AddPiece(user); CurrentFloor = floorPlan; while (user.X < Console.WindowHeight) { Console.SetWindowSize(50, 25); Console.CursorVisible = false; now = DateTime.Now; if ((now - tickStart).Ticks >= TICKS_PER_ROUND) { tickStart = DateTime.Now; user.Listen(); } //Update?.Invoke(); CurrentFloor.Draw(); } }
public void UserActivated(Player piece, int checkX, int checkY) { if (checkX >= 0 && checkX < Rows && checkY >= 0 && checkY < Columns && this.IsOccupied(checkX, checkY) && this[checkX, checkY] != null) { if (this[checkX, checkY].GetType() == typeof(FloorDoor)) { FloorDoor inbetween = ((FloorDoor)this[checkX, checkY]); RemovePiece(piece); if (inbetween.Side1 == this) { piece.Location = inbetween.ExitSide2; inbetween.Side2.AddPiece(piece); } else { piece.Location = inbetween.ExitSide1; inbetween.Side1.AddPiece(piece); } } this[checkX, checkY].Activate(this, new EventArgs()); } }