public TransitionRoomState(Physics.Direction direction) { // initialize the variables and directions we need to check for a transition oldObjects = LoZGame.Instance.GameObjects; newObjects = new GameObjectManager(); done = false; transitionDistance = 0; dungeon = LoZGame.Instance.Dungeon; currentRoomLocation = new Point(dungeon.CurrentRoomX, dungeon.CurrentRoomY); currentRoomBorderOffset = Vector2.Zero; puzzleDoors = new List <IDoor>(); specialDoors = new List <IDoor>(); foreach (IPlayer player in LoZGame.Instance.Players) { player.Physics.KnockbackVelocity = Vector2.Zero; } // finds the room we are transitioning to, and sets the variables needed to transition to it switch (direction) { case Physics.Direction.North: transitionDistance = YTransition; nextRoomLocation = new Point(currentRoomLocation.X, currentRoomLocation.Y - 1); nextRoomOffset = new Point(0, -YTransition); break; case Physics.Direction.South: transitionDistance = YTransition; nextRoomLocation = new Point(currentRoomLocation.X, currentRoomLocation.Y + 1); nextRoomOffset = new Point(0, YTransition); break; case Physics.Direction.East: transitionDistance = XTransition; nextRoomLocation = new Point(currentRoomLocation.X + 1, currentRoomLocation.Y); nextRoomOffset = new Point(XTransition, 0); break; case Physics.Direction.West: transitionDistance = XTransition; nextRoomLocation = new Point(currentRoomLocation.X - 1, currentRoomLocation.Y); nextRoomOffset = new Point(-XTransition, 0); break; } // loads the nextroom NextRoom = dungeon.GetRoom(nextRoomLocation.Y, nextRoomLocation.X); nextRoomBorderOffset = nextRoomOffset.ToVector2(); // checks that the next room actually exists before transitioning if (NextRoom.Exists) { MasterMovement = new Vector2((float)(-1 * nextRoomOffset.X) / transitionSpeed, (float)(-1 * nextRoomOffset.Y) / transitionSpeed); oldObjects.Entities.Clear(); dungeon.LoadNewRoom(newObjects, nextRoomLocation, nextRoomOffset); // assigns players movement velocity based on transition direction foreach (IPlayer player in LoZGame.Instance.Players) { switch (direction) { case Physics.Direction.North: player.MoveUp(); player.Physics.MovementVelocity = new Vector2(0, -(float)maxPlayerMovement / transitionSpeed); break; case Physics.Direction.South: player.MoveDown(); player.Physics.MovementVelocity = new Vector2(0, (float)maxPlayerMovement / transitionSpeed); break; case Physics.Direction.East: player.MoveRight(); player.Physics.MovementVelocity = new Vector2((float)maxPlayerMovement / transitionSpeed, 0); break; case Physics.Direction.West: player.MoveLeft(); player.Physics.MovementVelocity = new Vector2(-(float)maxPlayerMovement / transitionSpeed, 0); break; } player.Physics.MovementVelocity += MasterMovement; } // sets moveement velocity for all other objects apart from player; oldObjects.SetObjectMovement(MasterMovement); newObjects.SetObjectMovement(MasterMovement); // sets doors to draw on the top level foreach (IDoor door in oldObjects.Doors.DoorList) { door.Physics.Depth = 1; } foreach (IDoor door in newObjects.Doors.DoorList) { door.Physics.Depth = 1; } // opens all special and puzzle doors in the room we are entering foreach (IDoor door in newObjects.Doors.DoorList) { if (door.DoorType == Door.DoorTypes.Special) { specialDoors.Add(door); door.Open(); } } foreach (IDoor door in newObjects.Doors.DoorList) { if (door.DoorType == Door.DoorTypes.Puzzle) { puzzleDoors.Add(door); door.Open(); } } } // plays game if the room does not exist else { PlayGame(); } }