void Update() { if (Input.GetMouseButtonDown(0)) { GameObject line = Instantiate(linePrefab); activeLine = line.GetComponent <LineBehaviour> (); coolOff = false; } if (activeLine != null && inkBottle.value > 1 && !coolOff) { Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); activeLine.updateLine(mousePosition); inkBottle.value -= decreasingSpeed * Time.deltaTime; } /*else * { * if (inkBottle.value < inkBottle.maxValue && coolOff) * inkBottle.value += increasingSpeed * Time.deltaTime; * }*/ if (Input.GetMouseButtonUp(0)) { activeLine = null; coolOff = false; StartCoroutine(coolOffStarter()); Camera.main.GetComponent <CameraBehaviour>().cameraFollow(); if (shipRb.isKinematic) { shipRb.bodyType = RigidbodyType2D.Dynamic; } } }
void Update() { audioSource.GetSpectrumData(samples, 0, FFTWindow.Blackman); if (activeLine != null) { float samplesSum = 0; for (int i = 0; i < 4; i++) { samplesSum += samples[i]; } graphPointY = (samplesSum) * graphMagnitude; graphPointX = Mathf.Max(shipRb.velocity.x, graphPointY); graphPosition = new Vector2(graphPosition.x + (graphPointX * Time.deltaTime), Mathf.Lerp(graphPosition.y, graphPointY, yLerpingSpeed * Time.deltaTime)); activeLine.updateLine(graphPosition); } }
void Update() { if (Input.GetMouseButtonDown(0)) { Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); line = Instantiate(linePrefab, mousePosition, Quaternion.identity); activeLine = line.GetComponent <LineBehaviour> (); } if (activeLine != null) { Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); activeLine.updateLine(mousePosition); } if (Input.GetMouseButtonUp(0)) { activeLine = null; Destroy(line); } }
void Update() { if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); Vector2 touchPosition = Camera.main.ScreenToWorldPoint(touch.position); if (touch.phase == TouchPhase.Began) { line = Instantiate(linePrefab, touchPosition, Quaternion.identity); activeLine = line.GetComponent <LineBehaviour> (); } else if (touch.phase == TouchPhase.Moved) { activeLine.updateLine(touchPosition); } else if (touch.phase == TouchPhase.Ended) { activeLine = null; Destroy(line); } } }
void Update() { if (Input.GetMouseButtonDown(0)) { GameObject line = Instantiate(linePrefab); activeLine = line.GetComponent <LineBehaviour> (); } if (activeLine != null) { Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); activeLine.updateLine(mousePosition); } if (Input.GetMouseButtonUp(0)) { activeLine = null; Camera.main.GetComponent <CameraBehaviour>().cameraFollow(); if (shipRb.isKinematic) { shipRb.bodyType = RigidbodyType2D.Dynamic; } } }