Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        offset        = transform.position - indicadorDirecao.transform.position;
        rb            = GetComponent <Rigidbody>();
        controleForca = indicadorForca.GetComponent <ControleIndicadorForca>();

        placar = GameObject.Find("Placar").GetComponent <Text>();

        sair.gameObject.SetActive(false);

        ControleGame.InicializaGame();
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey("w") && !ControleGame.play && ControleIndicadorForca.IsForcaSet())
        {
            float efeito = new System.Random().Next(-300, 300);
            rb.AddForce(new Vector3(efeito, 0.0f, -Mathf.Abs(power)));
            rb.velocity         = new Vector3(0.0f, 0.0f, -controleForca.forca);
            ControleGame.inicio = DateTime.Now;
            ControleGame.play   = true;
        }

        // Se começar a compensar para um lado, não é possível compensar para o outro.
        if (Input.GetKey("d") && compensaDir)
        {
            compensaEsq = false;
            rb.AddForce(new Vector3(-3.0f, 0.0f, -2.0f));
        }

        if (Input.GetKey("a") && compensaEsq)
        {
            compensaDir = false;
            rb.AddForce(new Vector3(3.0f, 0.0f, -2.0f));
        }

        if (Input.GetKey(KeyCode.Space) && ControleGame.play && ControleGame.gameover)
        {
            ControleGame.InicializaGame();
            SceneManager.LoadScene(0);
        }

        if (Input.GetKeyDown("escape"))
        {
            if (sair.gameObject.activeSelf)
            {
                sair.gameObject.SetActive(false);
            }
            else
            {
                sair.gameObject.SetActive(true);
            }
        }
    }