private void OnTriggerStay2D(Collider2D other)
    {
        if (other.gameObject.layer == LayerMask.NameToLayer("BroomTrigger") && state == State.Broom)
        {
            other.SendMessage("OnBroomCollide");
        }

        if (other.CompareTag("Liftable") && AtlasInputManager.getKeyPressed("Up", true))
        {
            liftObject(other.gameObject);
        }

        if (other.CompareTag("ResetDamaging"))
        {
            if (graceFrames > 0)
            {
                graceFrames--;
            }
            else
            {
                resetPosition = true;
            }
        }
        ;

        if (other.CompareTag("ResetDrown"))
        {
            drown();
        }

        if (intangibleStates.Contains(state))
        {
            return;
        }
        if (other.gameObject.layer == LayerMask.NameToLayer("Danger") && (!invulnerable || other.CompareTag("ResetDamaging")))
        {
            if (other.CompareTag("ResetDamaging") && graceFrames > 0)
            {
                return;
            }

            if (other.CompareTag("Projectile"))
            {
                projectile p = other.GetComponent <projectile>();
                if (p.hurtPlayer)
                {
                    p.hit();
                }
            }

            startBonk(1, resetPosition);

            return;
        }
    }
示例#2
0
    void OnTriggerEnter2D(Collider2D col)
    {
        projectile missile = col.gameObject.GetComponent <projectile> ();

        if (missile)
        {
            health -= missile.getdamage();
            missile.hit();
            if (health <= 0)
            {
                Destroy(gameObject);
                LevelManager level = GameObject.Find("LevelManager").GetComponent <LevelManager>();
                level.LoadLevel("Lost");
            }
        }
    }
示例#3
0
    void OnTriggerEnter2D(Collider2D col)
    {
        projectile missile = col.gameObject.GetComponent <projectile> ();

        if (missile)
        {
            health -= missile.getdamage();
            missile.hit();
            if (health <= 0)
            {
                Destroy(gameObject);
                AudioSource.PlayClipAtPoint(death, transform.position);
                scorekeeper.scoreinc(scorevalue);
            }
        }
    }