// Update is called once per frame void Update() { if (GameManager.isGamePlay) { l_score += Time.deltaTime; GameManager.GameScore = (int)(l_score * moveSpeed * 5); //Debug.Log ("GameScore " +GameScore); gm_object.ScoreText.text = "Score : " + GameManager.GameScore; Vector3 pos = new Vector3(transform.position.x, transform.position.y, transform.position.z + moveSpeed); transform.position = pos; if (Input.GetKeyDown(KeyCode.UpArrow) && isGrounded) { rbody.AddForce(new Vector3(0, jumpForce * jumpFactor, 0)); isGrounded = false; } if (Input.GetKeyDown(KeyCode.LeftArrow)) { switch (myAlignment) { case ballAllignment.Center: myAlignment = ballAllignment.Left; transform.position = new Vector3(-3, transform.position.y, transform.position.z); break; case ballAllignment.Right: myAlignment = ballAllignment.Center; transform.position = new Vector3(0, transform.position.y, transform.position.z); break; } } if (Input.GetKeyDown(KeyCode.RightArrow)) { switch (myAlignment) { case ballAllignment.Center: myAlignment = ballAllignment.Right; transform.position = new Vector3(3, transform.position.y, transform.position.z); break; case ballAllignment.Left: myAlignment = ballAllignment.Center; transform.position = new Vector3(0, transform.position.y, transform.position.z); break; } } } }
void Start() { gm_object = GameManager.gameMangerInstance; rbody = GetComponent <Rigidbody> (); myAlignment = ballAllignment.Center; }