Init() 공개 메소드

public Init ( int _depthLevel, float _rotateAmount, float _sizeScalar ) : void
_depthLevel int
_rotateAmount float
_sizeScalar float
리턴 void
예제 #1
0
    private bool isRoot = true; //used to enforce calling Init() on children

    #endregion Fields

    #region Methods

    public bool Branch()
    {
        if (branched || !readyToBranch) {
        return false;
        }

        if (depthLevel != 0 && isRoot) {
        throw new System.Exception("Cannot branch before calling Init() on TreeSegment");
        }

        if (depthLevel >= maxDepth) {
        //	    renderer.material.color = new Color(0, 1f, 0, renderer.material.color.a); //DEVEL
        return false;
        }
        int childDepth = depthLevel + 1;
        if (branch1 == null) { // if no first branch
        branch1 = Instantiate(this, branchLoc, transform.rotation)
        as TreeSegment;
        branch1.Init(childDepth,
             Random.Range(minBranchAngle, maxBranchAngle),
             sizeScalar);
        }
        if (branch2 == null) {
        branch2 = Instantiate(this, branchLoc, transform.rotation)
        as TreeSegment;
        branch2.Init(childDepth,
             Random.Range(minBranchAngle, maxBranchAngle) * -1f,
             sizeScalar);
        }

        branched = true;
        //	renderer.material.color = new Color(139 / 255f, 100 / 255f, 19 / 255f, renderer.material.color.a); //DEVEL

        return true;
    }
예제 #2
0
    public bool Branch()
    {
        if (branched || !readyToBranch)
        {
            return(false);
        }

        if (depthLevel != 0 && isRoot)
        {
            throw new System.Exception("Cannot branch before calling Init() on TreeSegment");
        }

        if (depthLevel >= maxDepth)
        {
            //	    renderer.material.color = new Color(0, 1f, 0, renderer.material.color.a); //DEVEL
            return(false);
        }
        int childDepth = depthLevel + 1;

        if (branch1 == null)   // if no first branch
        {
            branch1 = Instantiate(this, branchLoc, transform.rotation)
                      as TreeSegment;
            branch1.Init(childDepth,
                         Random.Range(minBranchAngle, maxBranchAngle),
                         sizeScalar);
        }
        if (branch2 == null)
        {
            branch2 = Instantiate(this, branchLoc, transform.rotation)
                      as TreeSegment;
            branch2.Init(childDepth,
                         Random.Range(minBranchAngle, maxBranchAngle) * -1f,
                         sizeScalar);
        }

        branched = true;
        //	renderer.material.color = new Color(139 / 255f, 100 / 255f, 19 / 255f, renderer.material.color.a); //DEVEL

        return(true);
    }