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; }
// Use this for initialization void Start() { ts = gameObject.GetComponent<TreeSegment>(); if (ts == null) { throw new System.Exception("This GameObject needs a TreeSegment"); } if (gameObject.GetComponent<Rigidbody>() == null) { throw new System.Exception("This GameObject needs a rigid body to trigger branching on collision"); } }
public void TestSimpleRemove () { var collection = new SegmentTree<TreeSegment> (); var seg1 = new TreeSegment (10, 10); collection.Add (seg1); var seg2 = new TreeSegment (12, 2); collection.Add (seg2); var seg3 = new TreeSegment (14, 2); collection.Add (seg3); var seg4 = new TreeSegment (11, 5); collection.Add (seg4); collection.Remove (seg2); Assert.AreEqual (3, collection.Segments.Count ()); collection.Remove (seg4); Assert.AreEqual (2, collection.Segments.Count ()); }
// Use this for initialization void Start() { origScale = transform.localScale; transform.localScale = Vector3.zero; ts = gameObject.GetComponent<TreeSegment>(); }
void Start() { ts = gameObject.GetComponent<TreeSegment>(); }
public Tax() { _treeMax = new TreeSegment<City>(CityBase.GetAll().SortByIndex()); }
// Use this for initialization void Start() { origScale = transform.localScale; transform.localScale = Vector3.zero; ts = gameObject.GetComponent <TreeSegment>(); }
void Start() { ts = gameObject.GetComponent <TreeSegment>(); }