Ejemplo n.º 1
0
 private void OnDestroy()
 {
     if (GetComponent <EnemyController>().health > 0)
     {
         return;
     }
     TrunkGenerator.Generate(Trunk.Type.Root, transform.position);
 }
Ejemplo n.º 2
0
    private void Awake()
    {
        meshFilter             = GetComponent <MeshFilter>();
        meshRenderer           = GetComponent <MeshRenderer>();
        meshRenderer.materials = TrunkMaterials;

        generator = new TrunkGenerator(this, meshFilter.mesh);
    }
Ejemplo n.º 3
0
    public BranchGenerator(ProceduralTree tree, Mesh mesh, TrunkGenerator parent,
                           Vector3 position, Vector3 direction, float radius, float segmentLength, int numSegments) : base(tree, mesh, parent)
    {
        this.position = position;
        initialRadius = radius;

        initialRotation = Quaternion.FromToRotation(Vector3.up, direction);

        float t = Mathf.InverseLerp(
            ProceduralTree.MIN_THICKNESS, ProceduralTree.MAX_THICKNESS, initialRadius
            );

        numSides = (int)Mathf.Floor(
            Mathf.Lerp(ProceduralTree.MIN_ROUNDNESS, ProceduralTree.MAX_ROUNDNESS, t)
            );

        this.segmentLength = segmentLength;
        this.numSegments   = numSegments;

        this.foliageScale = initialRadius / tree.Thickness;
    }