public void beatCalled(float t) { if (readyToCount && MEASURECOUNT < MAX_MEASURES) { SpawnMeasure(); MEASURECOUNT++; } else { reset(); RecordShootingData.MakeCopy(); StartCoroutine(startagain()); } }
/// /// /// PHYSICS FUNCTIONS /// /// /// #region Input Functions // Get Input Data, use for any input checks void get_input(int instrumentIndex) { if (!GridController.inFightSceneMode || (GridController.inFightSceneMode && GridController.readyToCount)) // Horizontal Movement { float x = Input.GetAxis("Horizontal"); float y = Input.GetAxis("Vertical"); move_dir = new Vector2(x, y); // Vertical Movement if (Input.GetButtonDown("Jump")) { can_jump = true; } } else { move_dir = Vector2.zero; } //Shooting ---The fight scene needs to start with player on ground. if (GridController.inFightSceneMode) { if (GridController.readyToCount) { timecounter += Time.deltaTime; float fixedEightthOffset = 0.0f; if (Input.GetMouseButtonDown(0) && BeatTimer.MeasureTime >= 0) { /* Debug.Log("pressed down");*/ //1/8th of a measure hence 0.25f //divide by 2 because for 2 units -->x so for the visual width of the measure MeasureController.widthOfMeasure --> (x/2)*MeasureController.widthofMeasure // | is the measure and --- is the wall, so offset is calculated from the wall and back: <-.(15.7)-----|(14th one) fixedEightthOffset = (Mathf.Round((timecounter - BeatTimer.MeasureTime) / 0.25f) * 0.25f); float offset = MeasureController.widthOfMeasure * fixedEightthOffset / 2f; float temp = BeatTimer.MeasureTime + fixedEightthOffset; if (("" + temp) == ("" + timeindex)) { return; } float vertspacing = MeasureController.LatestMeasure.GetComponent <MeasureController>().vertspacing; index = (int)Mathf.Clamp(Mathf.Round((physicsTarget.position.y - startVerticalPosition) / vertspacing), 0, 12); Vector3 vectortogoto = new Vector3(MeasureController.LatestMeasure.transform.position.x - offset, MeasureController.LatestMeasure.transform.position.y + (index) * vertspacing, MeasureController.LatestMeasure.transform.position.z); GameObject gameobjecttemp = GameObject.Instantiate(Resources.Load <GameObject>("Note")); gameobjecttemp.transform.position = transform.position; StartCoroutine(FlyToYourPlace(gameobjecttemp, 0.05f, vectortogoto, () => { gameobjecttemp.transform.SetParent(MeasureController.LatestMeasure.transform, true); })); timeindex = BeatTimer.MeasureTime + fixedEightthOffset; playersampler.playSound(index); Debug.Log("sound started"); //AuidoScript.play //starttimer to determine how long note was played //As the note is held,scale the notemiddlesprite //AudioScript.stop //add the caps for the sprite //clean the duration to the nearest eighth //store cleaned duration in the recorded data //in playback mode, at the dictionary index value play the instrument assigned, the pitch clip for the amount of duration } if (Input.GetMouseButton(0) && BeatTimer.MeasureTime >= 0) { heldtimecounter += Time.deltaTime; //Jill's scaling part } if (Input.GetMouseButtonUp(0) && BeatTimer.MeasureTime >= 0) { Debug.Log("sound stopped"); playersampler.stopSound(index); Debug.Log(heldtimecounter); RecordShootingData.AddEntry(timeindex, new RecordedData(InstrumentPlayer.globalinstrumentindex, Mathf.Round(heldtimecounter / 0.25f) * 0.25f, index)); heldtimecounter = 0; timeindex = -1; spawn_projectile(); } } else { startVerticalPosition = physicsTarget.position.y; } } else { index = 0; } }