Inheritance: MonoBehaviour
Ejemplo n.º 1
0
    private void OnCollisionEnter(Collision collision)
    {
        if (ignoreNextCollision)
        {
            return;
        }

        if (isSuperSpeedActive && !collision.transform.GetComponent <Goal>())
        {
            Destroy(collision.transform.parent.gameObject, 0.2f);
        }
        else
        {
            //Death Parts
            DeathPart deathPart = collision.transform.GetComponent <DeathPart>();
            if (deathPart)
            {
                deathPart.HitDeathPart();
            }
        }



        rb.velocity = Vector3.zero;
        rb.AddForce(Vector3.up * impulseForce, ForceMode.Impulse);

        ignoreNextCollision = true;

        Invoke("AllowCollision", 0.2f);

        perfectPass        = 0;
        isSuperSpeedActive = false;
    }
Ejemplo n.º 2
0
    private void OnCollisionEnter(Collision other)
    {
        if (ignoreNextCollision)
        {
            return;
        }
        if (isSuperSpeedActive)
        {
            if (!other.transform.GetComponent <Goal>())
            {
                Destroy(other.transform.parent.gameObject);
            }
        }
        //перезапуск уровня при падении на deathPart без форсажа
        else
        {
            DeathPart deathPart = other.transform.GetComponent <DeathPart>();
            if (deathPart)
            {
                deathPart.HittedDeathPart();
            }
        }

        rb.velocity = Vector3.zero; //убрать скорость мяча
        rb.AddForce(Vector3.up * impulseForce, ForceMode.Impulse);

        ignoreNextCollision = true;
        Invoke("AllowCollision", .2f);

        perfectPass        = 0;
        isSuperSpeedActive = false;
        Debug.Log(GameManager.singleton.score);
    }
Ejemplo n.º 3
0
    private void OnCollisionEnter(Collision other)
    {
        boundAudio.Play();

        if (ignoreNextCollision)
        {
            return;
        }
        if (isSuperSpeedActive)
        {
            if (!other.transform.GetComponent <Goal>())
            {
                /*foreach (Transform t in other.transform.parent)
                 * {
                 *  gameObject.AddComponent<TriangleExplosion>();
                 *
                 *  StartCoroutine(gameObject.GetComponent<TriangleExplosion>().SplitMesh(true));
                 *  //Destroy(other.gameObject);
                 *  Debug.Log("exploding - exploding - exploding - exploding");
                 * }*/
                Destroy(other.transform.parent.gameObject);
            }
        }
        // If super speed is not active and a death part git hit -> restart game
        else
        {
            DeathPart deathPart = other.transform.GetComponent <DeathPart>();
            if (deathPart)
            {
                deathPart.HittedDeathPart();
            }
        }

        rb.velocity = Vector3.zero; // Remove velocity to not make the ball jump higher after falling done a greater distance
        rb.AddForce(Vector3.up * impulseForce, ForceMode.Impulse);



        // Safety check
        ignoreNextCollision = true;
        Invoke("AllowCollision", .2f);

        // Handlig super speed
        perfectPass        = 0;
        isSuperSpeedActive = false;
    }
Ejemplo n.º 4
0
    private void OnCollisionEnter(Collision other)
    {
        if (_ignoreNextCollision == true)
        {
            return;
        }

        DeathPart deathPart = other.transform.GetComponent <DeathPart>();

        if (deathPart)
        {
            deathPart.HittedDeathPart();
        }


        rb.velocity = Vector3.zero;
        rb.AddForce(Vector3.up * impulseForce, ForceMode.Impulse);
        _ignoreNextCollision = true;
        Invoke("AllowCollision", .2f);
    }
    private void OnCollisionEnter(Collision other)
    {
        if (ignoreNextCollision)
        {
            return;
        }
        if (isSuperSpeedActive)
        {
            if (!other.transform.GetComponent <Goal>())
            {
                Destroy(other.transform.gameObject, 0.3f);
            }
        }
        else
        {
            //instance of class death part
            //also adding resetting level functionality when deathpart is hit
            DeathPart deathPart = other.transform.GetComponent <DeathPart>();
            if (deathPart) // if death part exists
            {
                deathPart.HitDeathPart();
            }
        }


        FindObjectOfType <AudioManager>().Play("PlayerHit");



        rb.velocity = Vector3.zero; // Remove velocity to not make the ball jump higher after falling done a greater distance
        rb.AddForce(Vector3.up * impulseForce, ForceMode.Impulse);

        ignoreNextCollision = true;
        Invoke("AllowCollision", 0.2f);

        perfectPass        = 0;
        isSuperSpeedActive = false;
    }
Ejemplo n.º 6
0
    private void OnCollisionEnter(Collision collision)
    {
        if (ignoreNextCollision)
        {
            return;
        }
        DeathPart deathPart = collision.transform.GetComponent <DeathPart>();

        if (deathPart)
        {
            GameManager.singleton.RestartLevel();
        }

        //if (isSuperSpeedActive && !collision.transform.GetComponent<GameObject>())
        //{
        //    Destroy(collision.transform.parent.gameObject, 0.2f);
        //}
        //else
        //{
        //    DeathPart deathPart = collision.transform.GetComponent<DeathPart>();
        //    if (deathPart)
        //    {
        //        GameManager.singleton.RestartLevel();
        //    }
        //}



        rb.velocity = Vector3.zero;
        rb.AddForce(Vector3.up * impulseForce, ForceMode.Impulse);

        ignoreNextCollision = true;
        Invoke("AllowNextCollision", 0.2f);

        perfectPass        = 0;
        isSuperSpeedActive = false;
    }