The code used in this chapter
Here are the pieces of code used in the chapter:
The code for LevelPiece.cs
:
using UnityEngine; using System.Collections; public class LevelPiece : MonoBehaviour { public Transform exitPoint; }
The code for LevelGenerator.cs
:
using UnityEngine; using System.Collections; using System.Collections.Generic; public class LevelGenerator : MonoBehaviour { public static LevelGenerator instance; //all level pieces blueprints used to copy from public List<LevelPiece> levelPrefabs = new List<LevelPiece>(); //starting point of the very first level piece public Transform levelStartPoint; //all level pieces that are currently in the level public List<LevelPiece> pieces = new List<LevelPiece>(); void Awake() { instance = this; } void Start() { GenerateInitialPieces(); } public void GenerateInitialPieces() { for (int i=0; i<2; i++) { AddPiece(); } } public void AddPiece() { //pick...