示例#1
0
    //======================================================
    void OnTriggerEnter2D(Collider2D other)
    {
        PlayerHitboxReference playerReference = other.GetComponent <PlayerHitboxReference>();

        if (playerReference != null && playerReference.player != null)
        {
            if (onPlayerDetected != null)
            {
                onPlayerDetected(playerReference.player, this);
            }
        }
    }
示例#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();
            }
        }
    }
示例#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);
    }
示例#4
0
    //======================================================
    protected virtual void OnTriggerEnter2D(Collider2D other)
    {
        PlayerHitboxReference playerReference = other.GetComponent <PlayerHitboxReference>();

        if (playerReference != null && playerReference.player == owner)
        {
            Destroy(gameObject);
            return;
        }
        SwappableEntityHitboxReference swappableEntityReference = other.GetComponent <SwappableEntityHitboxReference>();

        if (swappableEntityReference != null && swappableEntityReference.swappableEntity != null)
        {
            owner.Swap(swappableEntityReference.swappableEntity);
        }
        else
        {
            SoundManager.instance.PlaySound(SoundManager.SoundType.NoSwap);
        }

        //Do something
        Destroy(gameObject);
    }
示例#5
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;
            }
        }
    }