Ejemplo n.º 1
0
 /// <summary>
 /// Creates the walls in the level.
 /// </summary>
 /// <param name="wallInput">JSON data for the walls in the level.</param>
 private void CreateWalls(List <WallInput> wallInput)
 {
     wallContainer = ObjectUtil.CreateNewObject("Walls");
     foreach (WallInput wall in wallInput)
     {
         Vector3        direction    = wall.endpoints[1] - wall.endpoints[0];
         Vector3        ortho        = VectorUtil.GetOrthonormal(direction) * wallThickness / 2;
         List <Vector3> wallPoints   = new List <Vector3>(4);
         Vector3        heightOffset = Vector3.up * wallHeight / 2;
         wallPoints.Add(wall.endpoints[0] + ortho + heightOffset);
         wallPoints.Add(wall.endpoints[0] - ortho + heightOffset);
         wallPoints.Add(wall.endpoints[1] - ortho + heightOffset);
         wallPoints.Add(wall.endpoints[1] + ortho + heightOffset);
         PlatformInput wallSurface = new PlatformInput(wallPoints);
         GameObject    wallObject  = CreatePlatform(wallSurface, wallHeight);
         wallObject.layer = LayerMask.NameToLayer("Wall");
         wallObject.name  = "Wall";
         wallObject.GetComponent <Renderer>().material = wallMaterial;
         wallObject.transform.parent = wallContainer.transform;
     }
 }