public void CutNode(BonsaiNode node) { Sett(node.my_cell_pos, 0); nodeDict.Remove(node.my_cell_pos); RetireNode(node); }
public void Setup(BonsaiNode originalNode, HashSet <BonsaiNode> subBonsais, Vector3 pushDir) { body.mass = 1 + .1f * originalNode.thickness; float divide = 2f; foreach (var bon in subBonsais) { body.mass += .1f * bon.thickness; bon.liner.sortingOrder = 2; circle.offset = circle.offset + (Vector2)(bon.transform.position - transform.position) / divide; divide++; } body.velocity = pushDir * Random.Range(5, 10); body.angularVelocity = Random.Range(-30f, 30f); transform.position = originalNode.transform.position; liner.SetPosition(0, originalNode.liner.GetPosition(0) * .5f + .5f * originalNode.liner.GetPosition(1)); liner.SetPosition(1, originalNode.liner.GetPosition(1)); liner.startColor = Color.Lerp(originalNode.liner.endColor, originalNode.liner.startColor, .5f); liner.endColor = originalNode.liner.endColor; liner.startWidth = originalNode.liner.startWidth * .5f + .5f * originalNode.liner.endWidth; liner.endWidth = originalNode.liner.endWidth; if (subBonsais.Count > 0) { liner.numCapVertices = 0; } foreach (var subBonsai in subBonsais) { // all cut bonsais are locked to me! subBonsai.transform.SetParent(this.transform, true); } }
public void SetParent(BonsaiNode parent) { this.parent = parent; this.transform.position = parent.transform.position; liner.startWidth = thickness; this.offset = Quaternion.Euler(0, 0, Random.value * 360) * Vector2.right * Random.Range(1, maxOffsetLength); }
/// <summary> /// Get the parent to begin the connection. /// </summary> /// <param name="child">The child to orphan.</param> /// <returns></returns> public static BonsaiNode StartConnection(BonsaiNode child) { // Starting a connection from a child means that its parent will make a new connection. // So the child becomes orphaned. BonsaiNode parent = child.Parent; child.SetParent(null); return(parent); }
public void AddNode(BonsaiNode node) { activeNodes.Add(node); activeNodeCount++; energyPerNode = energyBase + energyMultiplier / activeNodeCount; nodeDict.Add(node.my_cell_pos, node); Sett(node.my_cell_pos, 1); // set it solid. }
public BonsaiNode SpawnChildNode(BonsaiNode parent, twin verifiedDir) { var childNode = banks["node"].Spawn <BonsaiNode>(GetEntLot("nodes")); childNode.Setup(mazeMaster, parent.my_cell_pos + verifiedDir); childNode.SetParent(parent); AddNode(childNode); return(childNode); }
public void RetireNode(BonsaiNode node) { if (activeNodes.Remove(node)) { activeNodeCount--; if (activeNodeCount <= 1) { energyPerNode = energyMultiplier; } else { energyPerNode = energyBase + energyMultiplier / activeNodeCount; } } }
/// <summary> /// Creates a connection between the output and the input or node under the mouse. /// </summary> /// <param name="coord"></param> /// <param name="output"></param> public static void FinishConnection(BonsaiCanvas canvas, BonsaiNode parent, BonsaiNode child) { canvas.AddChild(parent, child); }