Ejemplo n.º 1
0
 protected virtual void OnPlayerHit(PlayerHit player, bool above)
 {
     if (!above)
     {
         player.OnDeath(gameObject);
     }
 }
Ejemplo n.º 2
0
 protected override void OnPlayerHit(PlayerHit player, bool above)
 {
     if (!above)
     {
         player.OnDeath(gameObject);
     }
 }
Ejemplo n.º 3
0
    void Explode()
    {
        if (!started)
        {
            return;
        }
        GameObject.Destroy(GetComponent <Rigidbody2D>());
        ExplosionSprite.SetActive(true);
        Collider2D[] colliders = Physics2D.OverlapCircleAll(transform.position, explosionRadius);
        for (int i = 0; i < colliders.GetLength(0); i++)
        {
            PlayerHit hit = colliders[i].gameObject.GetComponent <PlayerHit>();
            if (hit == null)
            {
                continue;
            }
            if (hit.gameObject == owner)
            {
                continue;
            }
            if (colliders[i] is BoxCollider2D == false)
            {
                continue;
            }
            hit.OnDeath(owner);
        }
        ExplosionSprite.transform.parent   = null;
        ExplosionSprite.transform.rotation = Quaternion.identity;
        DestroyAfterSeconds DAS = ExplosionSprite.AddComponent <DestroyAfterSeconds>();

        DAS.Seconds = 0.5f;
        GameObject.Destroy(gameObject);
    }
Ejemplo n.º 4
0
    void OnCollisionEnter2D(Collision2D c)
    {
        PlayerHit hit = c.collider.gameObject.GetComponent <PlayerHit>();

        if (!hit)
        {
            return;
        }

        hit.OnDeath(this.gameObject);
    }
Ejemplo n.º 5
0
    protected override void Activate()
    {
        GameObject ExplosionSprite = new GameObject("bombsuit explosion");

        ExplosionSprite.AddComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("PowerUps/Powers/BombSuit/Explosion");
        ExplosionSprite.transform.position = owner.transform.position;
        Collider2D[] colliders = Physics2D.OverlapCircleAll(owner.transform.position, explosionRadius);
        for (int i = 0; i < colliders.GetLength(0); i++)
        {
            PlayerHit hit = colliders[i].gameObject.GetComponent <PlayerHit>();
            if (hit == null)
            {
                continue;
            }
            if (hit.gameObject == owner)
            {
                continue;
            }
            if (colliders[i] is BoxCollider2D == false)
            {
                continue;
            }
            hit.OnDeath(owner);
        }
        ExplosionSprite.transform.parent   = null;
        ExplosionSprite.transform.rotation = Quaternion.identity;
        DestroyAfterSeconds DAS = ExplosionSprite.AddComponent <DestroyAfterSeconds>();

        DAS.Seconds = 0.5f;
        ScoreManager.gameData.BombSuitUsed++;

        PowerupUser PU = owner.GetComponent <PowerupUser>();

        PU.EndPowerup();
        PU.SetPowerup(new EmptyPowerup(owner));
    }
Ejemplo n.º 6
0
    void OnTriggerEnter2D(Collider2D c)
    {
        if (c.gameObject == owner)
        {
            return;
        }
        if (c.bounds.size.x > 1)
        {
            return;
        }
        if (c.isTrigger)
        {
            return;
        }
        //to make sure it doesn't hit multiple colliders on the players only 1 collisioncheck is allowed per frame
        bool toDestroy = false;

        if (Mathf.Abs(c.transform.position.x - gameObject.transform.position.x) > Mathf.Abs(c.transform.position.y - gameObject.transform.position.y) + 0.1f && Vector2.Dot(_rigid.velocity, (c.transform.position - transform.position)) > 0)
        {
            toDestroy = true;
        }



        if (_colCount <= 0 && !toDestroy)
        {
            //bounce from atop of blocks
            if (c.transform.position.y < transform.position.y)
            {
                _rigid.velocity = new Vector2(_rigid.velocity.x, 0);
                _rigid.AddForce(Vector2.up * BounceForce);
            }
            else
            //bounce from underneath blocks
            if (c.transform.position.y > transform.position.y)
            {
                _rigid.velocity = new Vector2(_rigid.velocity.x, 0);
                _rigid.AddForce(Vector2.up * -BounceForce);
            }
            else
            {
                toDestroy = true;
            }
        }

        _colCount++;

        //player hit
        PlayerHit hit = c.gameObject.GetComponent <PlayerHit>();

        if (hit != null && hit.gameObject != owner)
        {
            hit.OnDeath(gameObject);
            toDestroy = true;
        }



        if (toDestroy)
        {
            GameObject.Destroy(gameObject);
        }
    }