Exemplo n.º 1
0
    /// <summary>
    /// Tries to attach and obj to the platform if it's not already attached
    /// </summary>
    /// <param name="other">The other Collider2D involved in this collision</param>
    private void AttachObject(Collider2D other)
    {
        if (crumbled)
        {
            return;
        }
        ObjectController2D obj = other.GetComponent <ObjectController2D>();

        if (obj && !objs.Contains(obj))
        {
            // doesn't attach to the obj if it's a 1 way platform and the obj is below it
            if (pConfig.owPlatformMask == (pConfig.owPlatformMask | (1 << gameObject.layer)) &&
                (obj.transform.position.y < transform.position.y || obj.TotalSpeed.y > 0))
            {
                return;
            }
            else
            {
                objs.Add(obj);
                if (crumbleTime > 0 && currentCrumbleTime <= 0)
                {
                    if (!onlyPlayerCrumble || obj.GetComponent <PlayerController>())
                    {
                        currentCrumbleTime = crumbleTime;
                        animator.SetTrigger(ANIMATION_CRUMBLING);
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Sent when another object enters a trigger collider attached to this
    /// object (2D physics only).
    /// </summary>
    /// <param name="other">The other Collider2D involved in this collision.</param>
    void OnTriggerEnter2D(Collider2D other)
    {
        ObjectController2D obj = other.GetComponent <ObjectController2D>();

        if (obj)
        {
            obj.SetForce(force);
            obj.IgnoreFriction = true;
            CharacterController2D character = obj.GetComponent <CharacterController2D>();
            if (character)
            {
                character.ResetJumpsAndDashes();
            }
            animator.SetTrigger(jumpAnimation);
            if (audioSource)
            {
                audioSource.Play();
            }
        }
    }