// Use this for initialization void Start() { myBody = GetComponentInParent <Rigidbody2D>(); leftIdle = transform.Find("LeftIdle"); rightIdle = transform.Find("RightIdle"); for (int i = 0; i < tentaclesPerSide; i++) { Tentacle tentacle = TentacleMaker.Basic(pack, 9); tentacle.transform.parent = transform; tentacle.transform.localPosition = Vector2.zero; tentacle.AttachBase(myBody, myBody.transform.position); tentacle.AttachEnd(myBody, RightIdlePosition()); rightSideTentacles.Add(tentacle); } for (int i = 0; i < tentaclesPerSide; i++) { Tentacle tentacle = TentacleMaker.Basic(pack, 9); tentacle.transform.parent = transform; tentacle.transform.localPosition = Vector2.zero; tentacle.AttachBase(myBody, myBody.transform.position); tentacle.AttachEnd(myBody, LeftIdlePosition()); leftSideTentacles.Add(tentacle); } }
public void SeverTentacle() { if (leftSideTentacles.Count == 0 && rightSideTentacles.Count == 0) { return; } if (leftSideTentacles.Count == rightSideTentacles.Count) { if (Random.value > 0.5) { TentacleMaker.SeverTentacle(leftSideTentacles[0]); leftSideTentacles.RemoveAt(0); } else { TentacleMaker.SeverTentacle(rightSideTentacles[0]); rightSideTentacles.RemoveAt(0); } } else if (leftSideTentacles.Count > rightSideTentacles.Count) { TentacleMaker.SeverTentacle(leftSideTentacles[0]); leftSideTentacles.RemoveAt(0); } else { TentacleMaker.SeverTentacle(rightSideTentacles[0]); rightSideTentacles.RemoveAt(0); } stretchSpeed += stretchSpeedIncrease; }