Ejemplo n.º 1
0
 private void NextTile(GameObject obj)
 {
     if (posY + 1 < MANAGER.CityManager.floorOccupied.GetLength(1) && !MANAGER.CityManager.floorOccupied[posX, posY + 1, posZ])
     {
         MANAGER.CityManager.floorOccupied[posX, posY + 1, posZ] = false;
         _child = Instantiate(obj,
                              new Vector3(this.transform.position.x,
                                          this.transform.position.y + (this.gameObject.GetComponent <MeshRenderer>().bounds.size.y / 2),
                                          this.transform.position.z),
                              Quaternion.Euler(this.transform.rotation.x, this.transform.rotation.y, this.transform.rotation.z), this.transform);
         BuildingScript bs = _child.GetComponent <BuildingScript>();
         if (centreMaterial != null)
         {
             bs.centreMaterial = centreMaterial;
         }
         bs.posX          = posX;
         bs.posY          = posY + 1;
         bs.posZ          = posZ;
         bs.currentHeight = currentHeight + 1;
         bs.structures    = structures;
         bs.Build();
     }
     else
     {
         if (posX == MANAGER.CityManager.floorOccupied.GetLength(0) - 1 && posZ == MANAGER.CityManager.floorOccupied.GetLength(2) - 1)
         {
             MANAGER.CityManager.finishedIteration = true;
         }
         Destroy(this);
     }
 }
        public void Build(int xPos, int yPos, int zPos, int x, int y, int z, int height)
        {
            GameObject     build = buildings[Random.Range(0, buildings.Length)];
            GameObject     con   = Instantiate(build, new Vector3((xPos * size), (y * size), (zPos * size)), (Quaternion.Euler(transform.rotation.eulerAngles + new Vector3(0, ((int)Random.Range(0, 3)) * 90, 0))));
            BuildingScript bs    = con.GetComponent <BuildingScript>();

            bs.structures = buildObjects[Random.Range(0, buildObjects.Length)];
            bs.posX       = x;
            bs.posY       = y;
            bs.posZ       = z;
            bs.scale      = size;
            bs.maxHeight  = height;
            bs.Build();
        }