Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        //transform.localScale = new Vector3(5, 3, 1);
        //Retrieve values from the root controller to calculate range
        johnRootController sc = GameObject.FindGameObjectWithTag("Root").GetComponent <johnRootController>();

        depthDistance = sc.depthDistance;

        //Generate a multiplier for the starting scale based on tree's x and y distances
        //xDim is the x distance from the root node to either child
        float xDim     = sc.getBaseXDistance() / 2;
        float multSize = Mathf.Sqrt(xDim * xDim + depthDistance * depthDistance);

        multSize /= GetComponent <Renderer>().bounds.size.x;
        multSize *= 2.5f;// - maxDepth / (maxDepth + 1);

        //Create the initial scale used in letThereBeLight() and set it to the starting light
        startScale           = new Vector3(multSize, multSize, 1);
        transform.localScale = startScale;

        //Finally, get the player's location and move there while setting the start point
        player             = GameObject.FindGameObjectWithTag("Player");
        transform.position = player.transform.position;
        origPosition       = transform.position;
    }
Пример #2
0
    public void setDepth()
    {
        //this function finds and sets the depth of the node
        //based on its current y position
        int currentDepth = 1;
        //find the controller for root node
        GameObject         root = GameObject.Find("Root Node");
        johnRootController rc   = root.GetComponent <johnRootController>();
        //set yPosition to Depth Distance (from johnRootController) minus Root Node's y position
        float yPosition = (root.transform.position.y - rc.depthDistance);

        //while nodes left set depth
        while (currentDepth <= rc.maxDepth)
        {
            if (transform.position.y == yPosition)
            {
                depth = currentDepth;
            }
            currentDepth += 1;
            yPosition    -= rc.depthDistance;
        }
    }