Esempio n. 1
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.transform.tag == "Environment")
        {
            Destroy(gameObject);
            Instantiate(fragments, transform.position, transform.rotation);

            if (!GCScript.isTheGameOver())
            {
                GCScript.updateScore();
            }
        }
        else if (collision.transform.tag == "Player")
        {
            Destroy(gameObject);
            if (!PlayerScript.isPlayerInvincible())
            {
                GCScript.gameOver();
            }
        }
    }
Esempio n. 2
0
    void FixedUpdate()
    {
        float currentSlowFactor = slowFactor;

        if (!GCScript.isTheGameOver() && hasTouchedGround)
        {
            rb.drag = 4.0f;

            if (!isSlow)
            {
                currentSlowFactor = 1.0f;
            }

            // Keyboard
            if (Input.GetAxis("Horizontal") != 0.0f)
            {
                rb.AddForce(new Vector3(-Input.GetAxis("Horizontal") * speed / currentSlowFactor, 0.0f, 0.0f));
            }

            //Touch Screen
            foreach (Touch touch in Input.touches)
            {
                if (touch.position.x < Screen.width / 2)
                {
                    rb.AddForce(new Vector3(speed / currentSlowFactor, 0.0f, 0.0f));
                }
                else if (touch.position.x > Screen.width / 2)
                {
                    rb.AddForce(new Vector3(-speed / currentSlowFactor, 0.0f, 0.0f));
                }
            }
        }
        else
        {
            rb.drag = 0.0f;
        }
    }