Example #1
0
 // Awake
 void Awake()
 {
     //    messageText = GameObject.Find("MessageText");
     //    messageText.SetActive(false);
     inst = gameObject.GetComponent <GCScript>();
     anim = gameObject.GetComponent <Animator>();
 }
Example #2
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();
            }
        }
    }
Example #3
0
    void Start()
    {
        Cursor.visible   = false;
        Cursor.lockState = CursorLockMode.Locked;
        level1.gameObject.SetActive(false);
        level2.gameObject.SetActive(false);
        level3.gameObject.SetActive(false);

        game = this;

        weak = false;

        gameOver       = false;
        bricks         = 0;
        score          = 0;
        level          = 0;
        scoreText.text = "Score:" + score;
        livesText.text = "Balls:" + lives;

        NextLevel();
    }
Example #4
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;
        }
    }
Example #5
0
 void Awake()
 {
     Instance = this;
 }
 // Start is called before the first frame update
 void Start()
 {
     gcscript = GameObject.FindObjectOfType <GCScript>();
     Destroy(gameObject, 5);
 }
Example #7
0
 // Start is called before the first frame update
 void Start()
 {
     gcscript = GameObject.FindObjectOfType <GCScript>();
 }
Example #8
0
 void OnEnable()
 {
     scoreText.text = "Your final score is " + GCScript.getScore();
 }