예제 #1
0
    private Vector3 GetRandomSurfacePosition()
    {
        Vector3 randomPos;
        Vector3 terrainDimension = SurfaceManager.SurfaceDimension();

        do
        {
            randomPos = new Vector3(Random.Range(0, terrainDimension.x),
                                    0, Random.Range(0, terrainDimension.z)) + SurfaceManager.SurfacePosition();
            randomPos.y = SurfaceManager.GetSurfaceHeight(surface, randomPos);
        } while (!CouldTreeSpawnIn(randomPos));
        return(randomPos);
    }
예제 #2
0
    private void CreateHouseInPosition(Vector3 position)
    {
        if (SurfaceManager.IsWater(surface, position))
        {
            return;
        }

        position.y = SurfaceManager.GetSurfaceHeight(surface, position);
        float dir = (int)position.sqrMagnitude % 4 * 90;

        GameObject house = Instantiate(housesModels[Random.Range(0, housesModels.Length)],
                                       position, Quaternion.AngleAxis(dir, Vector3.up));

        house.transform.parent = transform;
        house.tag      = "House";
        house.isStatic = true;
    }
예제 #3
0
    // Use this for initialization
    void Start()
    {
        if (typeDatas == null)
        {
            InitTypeData();
        }

        text = transform.GetChild(0).GetComponent <TextMeshProUGUI>();

        text.text  = tagName;
        text.color = typeDatas[type].color;

        Vector3 position = transform.position;

        surfaceHeight      = SurfaceManager.GetSurfaceHeight(position);
        position.y         = surfaceHeight + height;
        transform.position = position;
    }
 public float GetSurfaceHeight(Vector3 position)
 {
     return(SurfaceManager.GetSurfaceHeight(position, height));
 }