IEnumerator Loop() { while (gameObject.activeInHierarchy) { isTouch = toggle.isOn; if (PaddleChanger.Instance.paddleMode != lastedPaddle) { PaddleChanger.OnChangePaddle(PaddleChanger.Instance.paddleMode); lastedPaddle = PaddleChanger.Instance.paddleMode; } switch (PaddleChanger.Instance.paddleMode) { case PaddleMode.Limited: if (isTouch) { Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); transform.position = new Vector2(mousePos.x, -3.3f); } else { dirVelocity = Vector3.right * Input.GetAxisRaw("Horizontal") * m_fSpeed; rigidbody2D.velocity = dirVelocity; } break; case PaddleMode.Freedom: if (isTouch) { Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); transform.position = new Vector2(mousePos.x, mousePos.y); } else { dirVelocity = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")) * m_fSpeed; rigidbody2D.velocity = dirVelocity; transform.position = new Vector2( Mathf.Clamp(transform.position.x, -2.5f, 2.5f) , Mathf.Clamp(transform.position.y, -5f, 5f)); } break; default: break; } yield return(null); } yield return(null); }
public void ChangePaddle(PaddleMode paddleMode) { switch (paddleMode) { case PaddleMode.Limited: m_limitedPaddle?.gameObject?.SetActive(true); m_freedomPaddle?.gameObject?.SetActive(false); break; case PaddleMode.Freedom: m_freedomPaddle?.gameObject?.SetActive(true); m_limitedPaddle?.gameObject?.SetActive(false); break; default: break; } }
public void TEST_CHANGED_FREEDOM_PADDLE() { //ChangePaddle(PaddleMode.Freedom); paddleMode = PaddleMode.Freedom; }
public void TEST_CHANGED_LIMITED_PADDLE() { //ChangePaddle(PaddleMode.Limited); paddleMode = PaddleMode.Limited; }
public void SetPaddle(PaddleMode _paddleMode) => paddleMode = _paddleMode;
private void OnEnable() { paddleMode = PaddleMode.Limited; ChangePaddle(paddleMode); }