Place() public méthode

public Place ( ) : void
Résultat void
Exemple #1
0
 private void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         objectPlacer.Place();
     }
 }
Exemple #2
0
        public bool TryPlaceBuilding(IEnumerable <BuildingTile> tileList, StructureData structureData)
        {
            var tl = tileList.ToArray();

            if (tl.Any(t => t.hasBuilding))
            {
                return(false);
            }

            var buildingCoord = tl
                                .OrderBy(t => t.bounds.min.x)
                                .ThenBy(t => t.bounds.min.z)
                                .First()
                                .GetBuildingCoord();

            if (structureData.modelName != null)
            {
                var modelObject = LoadObject(structureData);
                ObjectPlacer.Place(chunks, modelObject, buildingCoord, Time.frameCount % 4);
            }

            var grids = structureData.numGrids;

            var structureGo = Instantiate(structurePrefab, transform);

            structureGo.transform.position = buildingCoord + new Vector3(grids.x * this.tiles.gridSize / 2f, 0,
                                                                         grids.y * this.tiles.gridSize / 2.0f);

            var structure = structureGo.GetComponent <Structure>();

            structure.chunks        = chunks;
            structure.ground        = ground;
            structure.origin        = buildingCoord;
            structure.gridSize      = tiles.gridSize;
            structure.numGrids      = structureData.numGrids;
            structure.structureType = structureData.type;
            var y = Mathf.Max(buildingCoord.y, water.config.waterLevel);

            structure.wallHeight = (Mathf.CeilToInt(y / (float)wallHeightMultiplier) + 3)
                                   * wallHeightMultiplier;
            _structures.Add(buildingCoord, structureGo);

            foreach (var tile in tl)
            {
                tile.hasBuilding = true;
            }

            return(true);
        }