private void _addBranchLocal(Vector3 localPoint, float rotation) { GameObject newChild = new GameObject(); newChild.transform.parent = transform; // If we are in a child level, we need to add the parent branch // rotation object to make sure we are calculated in nested // rotations due to calculating from world units. float branchRotation = rotation + transform.rotation.eulerAngles.z; newChild.transform.rotation = Quaternion.Euler(0f, 0f, branchRotation); newChild.transform.localPosition = localPoint; float remainingBranchDistanceRatio = (maxHeight - newChild.transform.localPosition.y) / maxHeight; BranchComponent newBranch = newChild.AddComponent <BranchComponent>(); if (isAutomated) { newBranch.isAutomated = isAutomated; newBranch.secondsBetweenSegments = secondsBetweenSegments; } newBranch.branchMaterial = new Material(branchMaterial); newBranch.branchLevel = branchLevel + 1; newBranch.maxBaseWidth = maxBaseWidth * CHILD_BRANCH_SCALE_FACTOR * remainingBranchDistanceRatio; newBranch.maxHeight = maxHeight * CHILD_BRANCH_SCALE_FACTOR; newBranch.maxLeftRightDistance = maxLeftRightDistance * CHILD_BRANCH_SCALE_FACTOR; newBranch.tipWidth = tipWidth * CHILD_BRANCH_SCALE_FACTOR; newBranch.selectionPointPrefab = selectionPointPrefab; newBranch.parentBranch = this; newBranch.animatedFlowerPrefab = animatedFlowerPrefab; newBranch.animatedLeafPrefab = animatedLeafPrefab; }
public BranchManager(BranchComponent branchComponent) { // assign references to all the relevant branch elements m_branchPrefab = branchComponent.GetBranchPrefab(); m_branchPanel = branchComponent.GetBranches(); m_branchContent = branchComponent.GetBranchContent(); }
public BranchManager(BranchComponent branchComponent) { m_branchPrefab = branchComponent.GetBranchPrefab(); m_branchPanel = branchComponent.GetBranches(); m_sliderTimer = branchComponent.GetTimerSlider(); m_branchContent = branchComponent.GetBranchContent(); m_branchComponent = branchComponent; }
public void AddBranch(BranchComponent branch) { _branches.Add(branch); }