Exemplo n.º 1
0
    void Awake()
    {
        toyBody = GetComponent <ToyBody>();

        toyBody.Joined   += StartCount;
        toyBody.Splitted += FinishCount;
    }
Exemplo n.º 2
0
    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();
        }
    }
Exemplo n.º 3
0
    private void Awake()
    {
        toyBody = GetComponentInParent <ToyBody>();

        toyBody.Joined   += joinDispatcher.PlaySfxOnce;
        toyBody.Splitted += breakDispatcher.PlaySfxOnce;
    }
Exemplo n.º 4
0
    private void Awake()
    {
        toyJoinReaction = GetComponentInParent <ToyJoinReaction>();
        toyBody         = GetComponentInParent <ToyBody>();

        toyBody.Splitted += EmitCollision;
        toyBody.Joined   += EmitCollision;
        toyJoinReaction.CompletedJoinedReaction += EmitCompletedJoin;
    }
Exemplo n.º 5
0
    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();
    }
Exemplo n.º 6
0
    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);
    }