void Start() { currencyText.text = "$" + PlayerPrefsController.GetTotalCurrency(); PlayerPrefsController.InitializeControlType(); if (PlayerPrefsController.GetControlType() == 0) { mouseControls.isOn = true; } else { mouseControls.isOn = false; } }
void Update() //Move and clamps paddle based on size { if (PlayerPrefsController.GetControlType() == 0) { if (paddleSize == 1f) { Vector2 paddlePos = new Vector2(transform.position.x, transform.position.y); paddlePos.x = Mathf.Clamp(GetXPos(), minX, maxX); //Move to the x coordinate with set boundaries transform.position = paddlePos; } if (paddleSize == 1.25f) { Vector2 paddlePos = new Vector2(transform.position.x, transform.position.y); paddlePos.x = Mathf.Clamp(GetXPos(), minX2, maxX2); //Move to the x coordinate with set boundaries transform.position = paddlePos; } if (paddleSize == 1.5f) { Vector2 paddlePos = new Vector2(transform.position.x, transform.position.y); paddlePos.x = Mathf.Clamp(GetXPos(), minX3, maxX3); //Move to the x coordinate with set boundaries transform.position = paddlePos; } } if (PlayerPrefsController.GetControlType() == 1) { if (paddleSize == 1f) { var deltaX = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed; var newXPos = Mathf.Clamp(transform.position.x + deltaX, minX, maxX); transform.position = new Vector2(newXPos, transform.position.y); } if (paddleSize == 1.25f) { var deltaX = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed; var newXPos = Mathf.Clamp(transform.position.x + deltaX, minX2, maxX2); transform.position = new Vector2(newXPos, transform.position.y); } if (paddleSize == 1.5f) { var deltaX = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed; var newXPos = Mathf.Clamp(transform.position.x + deltaX, minX3, maxX3); transform.position = new Vector2(newXPos, transform.position.y); } } }
private void LaunchOnMouseClick() //When left click happens, launch the ball and start the timer { if (PlayerPrefsController.GetControlType() == 0) { if (Input.GetMouseButtonDown(0)) { if (FindObjectOfType <ExplosiveBallSlider>() != null) { FindObjectOfType <ExplosiveBallSlider>().Reset(); hasStarted = true; myRigidBody2D.velocity = new Vector2(xPush, yPush); timer.StartTimer(); } else { hasStarted = true; myRigidBody2D.velocity = new Vector2(xPush, yPush); timer.StartTimer(); } } } if (PlayerPrefsController.GetControlType() == 1) { if (Input.GetKeyDown(KeyCode.Space)) { if (FindObjectOfType <ExplosiveBallSlider>() != null) { FindObjectOfType <ExplosiveBallSlider>().Reset(); hasStarted = true; myRigidBody2D.velocity = new Vector2(xPush, yPush); timer.StartTimer(); } else { hasStarted = true; myRigidBody2D.velocity = new Vector2(xPush, yPush); timer.StartTimer(); } } } }
private void ActivateExplosiveBall() //If explosive ball is off cooldown and you right click, set ball to explosive { if (explosiveBallAvailable) { if (PlayerPrefsController.GetControlType() == 0) { if (Input.GetMouseButtonDown(1)) { isExplosive = true; GetComponent <SpriteRenderer>().color = Color.red; } } if (PlayerPrefsController.GetControlType() == 1) { if (Input.GetKeyDown(KeyCode.Space)) { isExplosive = true; GetComponent <SpriteRenderer>().color = Color.red; } } } }