Exemplo n.º 1
0
    public void SpawnResource(Vector3 spawnPosition, float spawnRadius, float angleInDegrees)
    {
        float pointX = (spawnRadius * Mathf.Cos(angleInDegrees * Mathf.PI / 180.0f)) + spawnPosition.x;
        float pointZ = (spawnRadius * Mathf.Sin(angleInDegrees * Mathf.PI / 180.0f)) + spawnPosition.z;

        Vector3 spawnPoint = new Vector3(pointX, 0.0f, pointZ);

        GameObject newResource = Instantiate(Resources.Load(generator.ToString()), spawnPoint, transform.rotation) as GameObject;

        newResource.transform.parent = this.transform;

        Spawn ns = newResource.GetComponent <Spawn>();

        ns.inPosition = true;
        ns.resourceID = spawnedResources;
        ns.DetectNewNodes();
    }