void Awake() { toyBody = GetComponent <ToyBody>(); toyBody.Joined += StartCount; toyBody.Splitted += FinishCount; }
public void OnCollisionEnter(Collision collision) { if (Protected) { return; } ToyBody other = collision.gameObject.GetComponent <ToyBody>(); if (other == null) { return; } if (other.InstanceId < InstanceId) { return; } if (other.Protected) { return; } if (this.BodyParts.Count == 1 && other.BodyParts.Count == 1) { other.Join(this); ProtectAgainstSpamming(); } else { Split(); other.Split(); } }
private void Awake() { toyBody = GetComponentInParent <ToyBody>(); toyBody.Joined += joinDispatcher.PlaySfxOnce; toyBody.Splitted += breakDispatcher.PlaySfxOnce; }
private void Awake() { toyJoinReaction = GetComponentInParent <ToyJoinReaction>(); toyBody = GetComponentInParent <ToyBody>(); toyBody.Splitted += EmitCollision; toyBody.Joined += EmitCollision; toyJoinReaction.CompletedJoinedReaction += EmitCompletedJoin; }
public void Join(ToyBody other) { if (BodyParts.Count > 1 || other.BodyParts.Count > 1) { return; } other.BodyParts.Add(BodyParts[0]); BodyParts.Remove(BodyParts[0]); other.UpdateBodyPartPositions(); DestroyThis(); }
public ToyBody InstantiateBody(BodyPart bodyPart1, BodyPart bodyPart2, Vector3 position, Quaternion rotation) { ToyBody toyBody = Instantiate <ToyBody>(Configuration.BodyPrefab, position, rotation); toyBody.BodyParts = new List <BodyPart>(); if (bodyPart1 != null) { toyBody.BodyParts.Add(bodyPart1); } if (bodyPart2 != null) { toyBody.BodyParts.Add(bodyPart2); } ToyBodies.Add(toyBody); return(toyBody); }