示例#1
0
    public void Create()
    {
        Transform t = Instantiate(treePrefab) as Transform;

        thisTree = t.GetScript <GivingTree2> ();
        Iterate();
        TargetTree = trees[targetTreeIndex];
    }
示例#2
0
    void OnEndIterate()
    {
        GivingTree2 next = FirstTree;

        visitableTrees.Remove(next);
        FirstTree.transform.SetParent(transform);
        FirstTree.transform.SetLocalScale(0.1f);
        FirstTree.transform.SetLocalPosition(Vector3.zero);
        CreateTree(LastTree.TargetTree.position, LastTree.transform, true, next);
    }
示例#3
0
    void CreateTrees()
    {
        GivingTree2 targetTree = CreateTree(Vector3.zero, transform, true);

        PopulateTrees(targetTree);
        for (int i = 1; i < maxIterations; i++)
        {
            targetTree = CreateTree(targetTree.TargetTree.position, targetTree.transform, true);
            PopulateTrees(targetTree);
        }
    }
示例#4
0
 void PopulateTrees(GivingTree2 onTree)
 {
     for (int i = 0; i < onTree.TreeSpawns.Length; i++)
     {
         if (i == onTree.TargetTreeIndex)
         {
             continue;
         }
         Transform   t                = onTree.TreeSpawns[i];
         GivingTree2 newTree          = Instantiate(treePrefab) as GivingTree2;
         Transform   newTreeTransform = newTree.transform;
         newTreeTransform.SetPosition(t.position);
         newTreeTransform.SetParent(onTree.transform);
         newTreeTransform.SetLocalScale(0.1f);
     }
 }
示例#5
0
    GivingTree2 CreateTree(Vector3 position, Transform parent, bool visitable, GivingTree2 tree = null)
    {
        if (tree == null)
        {
            tree = Instantiate(treePrefab) as GivingTree2;
        }

        Transform treeTransform = tree.transform;

        treeTransform.SetPosition(position);
        treeTransform.SetParent(parent);
        treeTransform.SetLocalScale(0.1f);

        if (visitable)
        {
            tree.name = string.Format("Tree {0}", treeCount);
            treeCount++;
            visitableTrees.Add(tree);
        }

        return(tree);
    }