Beispiel #1
0
    // ====================================================
    void Squash(PhysicsController other)
    {
        PlayerController player = other.GetComponent <PlayerController>();

        if (player != null)
        {
            player.InstaDeath();
            return;
        }
        PatrollingEnemy patroller = other.GetComponent <PatrollingEnemy>();

        if (patroller != null)
        {
            patroller.InstaDeath();
            return;
        }
        Destroy(other.gameObject);
    }
Beispiel #2
0
    //======================================================
    void OnTriggerEnter2D(Collider2D other)
    {
        PlayerHitboxReference playerReference = other.GetComponent <PlayerHitboxReference>();

        if (playerReference != null && playerReference.player != null)
        {
            playerReference.player.InstaDeath();
        }

        SwappableEntityHitboxReference swappableEntityReference = other.GetComponent <SwappableEntityHitboxReference>();

        if (swappableEntityReference != null && swappableEntityReference.swappableEntity != null)
        {
            PatrollingEnemy patrollingEnemy = swappableEntityReference.swappableEntity as PatrollingEnemy;
            if (patrollingEnemy != null)
            {
                patrollingEnemy.InstaDeath();
            }
        }
    }
Beispiel #3
0
    //======================================================
    protected override void OnTriggerEnter2D(Collider2D other)
    {
        PlayerHitboxReference playerReference = other.GetComponent <PlayerHitboxReference>();

        if (playerReference != null && playerReference.player != null)
        {
            playerReference.player.InstaDeath();
        }

        SwappableEntityHitboxReference swappableEntityReference = other.GetComponent <SwappableEntityHitboxReference>();

        if (swappableEntityReference != null && swappableEntityReference.swappableEntity != null)
        {
            PatrollingEnemy patrollingEnemy = swappableEntityReference.swappableEntity as PatrollingEnemy;
            if (patrollingEnemy != null)
            {
                patrollingEnemy.InstaDeath();
            }
        }

        //Do something
        Destroy(gameObject);
    }
Beispiel #4
0
    // =====================================
    private void OnTriggerStay2D(Collider2D other)
    {
        PlayerHitboxReference playerReference = other.GetComponent <PlayerHitboxReference>();

        if (playerReference != null && playerReference.player != null && !playerReference.player.isDead)
        {
            PlayerController player    = playerReference.player;
            Vector2          direction = transform.TransformDirection(localSpikeDirection).normalized;
            if (Vector2.Dot(direction, player.currentSpeed - currentSpeed) >= -0.1f)
            {
                return;
            }

            SoundManager.instance.PlaySound(SoundManager.SoundType.Spikes);
            player.InstaDeath();
            return;
        }

        SwappableEntityHitboxReference swappableEntityReference = other.GetComponent <SwappableEntityHitboxReference>();

        if (swappableEntityReference != null && swappableEntityReference.swappableEntity != null)
        {
            PatrollingEnemy enemy = swappableEntityReference.swappableEntity as PatrollingEnemy;
            if (enemy != null)
            {
                Vector2 direction = transform.TransformDirection(localSpikeDirection).normalized;
                if (Vector2.Dot(direction, enemy.currentSpeed - currentSpeed) >= -0.1f)
                {
                    return;
                }

                SoundManager.instance.PlaySound(SoundManager.SoundType.Spikes);
                enemy.InstaDeath();
                return;
            }
        }
    }