Hooking Up the Level

The rest of the interaction with the player has already been implemented inside the code for the Level object, so for now you are done with this object. However, you do need to add the level into the game engine. Go ahead and declare some variables for it:

// The current level
private Level currentLevel = null;
// What level are we currently playing
private int levelNumber = 1;
// Is the level currently being loaded
private bool isLoadingLevel = false;
// Current camera position
private Vector3 currentCameraPosition;
// The amount of time the 'winning' screen is displayed
private float winningLevelTime = 0.0f;

The first two variables are pretty obvious: you need to know which level number you're currently playing as well ...

Get Beginning 3D Game Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.