Example #1
0
    // Function that adds on object to all gridtiles in a certian circle radius around a tile with position point.
    void AddToGridTiles(GameObject something, Vector3 point, float circleRadius, GridTileOccupant.OccupantType type)
    {
        List <GridTile> gridtiles = GridTile.FindGridTilesAround(point, circleRadius + 2 * TerrainController.thisTerrainController.tileSize);

        foreach (GridTile tile in gridtiles)
        {
            TerrainController.thisTerrainController.RemoveTerrainTileOccupant(tile);
            tile.occupants.Add(new GridTileOccupant(something, type));
        }
        //tile.type = type;
    }
Example #2
0
    // Builder function, some class wants the world to add an object
    public void AddTurbine(GameObject t, Vector3 pos, Quaternion rotation, float scale, GridTileOccupant.OccupantType type, Transform parent)
    {
        float diameter = t.GetComponent <SizeController>().diameter;

        pos.y = BuildingHeight(pos, diameter * scale);
        t.transform.position = pos;
        t.transform.rotation = rotation;
        t.transform.SetParent(parent);
        AddToGridTiles(t, pos, diameter * scale, type);
        EqualTerrain(pos, (diameter * scale), false);
        TurbineManager turbManager = TurbineManager.GetInstance();

        turbManager.AddTurbine(t);

        if (TileInfomationMenu.instance != null && TileInfomationMenu.instance.toggle.isOn)
        {
            WindVisualizer.instance.UpdateChunks();
        }
    }
Example #3
0
    public GameObject AddOther(GameObject something, Vector3 pos, Quaternion rotation, float scale, GridTileOccupant.OccupantType type, Transform parent)
    {
        float diameter = something.GetComponent <SizeController>().diameter;

        pos.y = BuildingHeight(pos, diameter * scale);

        GameObject t = (GameObject)Instantiate(something, pos, rotation, parent);

        t.transform.localScale = Vector3.one * scale;

        AddToGridTiles(something, pos, diameter * scale, type);
        EqualTerrain(pos + Vector3.up * 0.5f, diameter * scale, false);

        if (TileInfomationMenu.instance != null && TileInfomationMenu.instance.toggle.isOn)
        {
            WindVisualizer.instance.UpdateChunks();
        }

        return(t);
    }