Mastering Unity 2017 Game Development with C#(Second Edition)
上QQ阅读APP看书,第一时间看更新

Level Design and Structure

This chapter is about designing and building playable levels for Dead Keys. More accurately, Dead Keys consists of multiple levels, and in this chapter, our focus will be on the creation of one of those levels in detail. Only one needs be considered because the level creation process is merely repeated creatively, after creating the first level, to produce all the remaining levels at increasing difficulty levels. By level, I mean a scene in Unity terms--a complete and integrated 3D world where the game evolves according to its internal rules and logic. We'll look, in depth, at using and reusing modular assets, such as environment meshes, to build interesting levels of any size needed; we'll also see lightmapping and lighting overall to enhance realism as well as NavMesh generation for artificial intelligence and Occlusion Culling for rendering optimization, among other issues. By the end of this chapter, we'll have constructed an integrated and atmospheric level, complete with final lighting, which has furnishings and navigation data. However, we'll still be missing agents, that is, the player character and Non-Player Characters (NPCs). These are considered in the later chapters. So, having now imported our assets (covered in the last chapter), we'll start work on creating the first playable level for Dead Keys (not the menu screen), beginning from an empty scene, created by choosing File | New Scene (Ctrl + N) from the application menu.

If you want to follow along step by step, the starting point for this chapter is found in this book's companion files, in the Chapter02/Start  folder; this features a starting Unity project.
Getting started with a New Scene

Before building any level inside the editor, it's worthwhile getting very clear, conceptually, about the level to create as a whole, in terms of layout and mechanics. For our level (and all levels), we may identify the following key points:

  • The objective for the player is to traverse a maze-like network of dark, industrial corridors to reach an end point. On reaching the end point, the next level is accessed; except, of course, for the final level in which the game is completed.
  • The player provides input only through keystrokes on the keyboard, typing in letters that match whatever word appears above the closest attacking zombie. When the entered combination matches the word exactly and in full, the zombie is killed. Otherwise, zombies continue attacking until the player is killed.
  • The player does not freely control their movement through the level, as with regular first-person controls (W A S D). Instead, the player experiences a prescripted and prepathed camera that only moves forward, to the next stopping point, when all attacking zombies are dispatched. This matches the camera and gameplay style of House of the Dead, The Typing of the Dead, Lethal Enforcers, and others.
  • The level is made from modular environment pieces, allowing many possible combinations and layouts. It should be dark, eerie, and tense.
  • Most objects in the scene (such as walls, floors, and props) will be non-movable. The only movable elements are the player, enemies, and a selection of special effects, such as particle systems and image effects.

This level description is, by no means, comprehensive or complete. However, it offers us a platform good enough to get started to build a level that supports our core gameplay. In many cases, artists and designers construct levels from concept art, mood boards, and storyboards; but here, we'll improvise using assets made specifically for this book.