public void beatBoxArrived(BeatBox beatBox) { beatBoxArrivalTime = currentTime();// Time.time; beatBoxArrival = beatBox; trailArrivalTime = beatBox.getTrailTime(); checkingTrail = false; if (Settings.instance.difficultyTouchToHit) { if (isAlreadyInside) { beatBoxArrival.hit(1); beatBoxArrival = null;//TODO currently not checking trail in touchToHit mode //if (trailArrivalTime <= 0)//no trail, we can discard the box // beatBoxArrival = null; //else // checkingTrail = true; startParticles(); } else { beatBoxArrival.miss(); beatBoxArrival = null; beatBoxArrivalTime = -10; } } }
void playBeatBox(float clipTime) { if (beatBoxArrival != null) { if (lastLaneHit > 0)//if there was a hit triggered in the lane (by key or beater) { float timeDelta = Mathf.Abs(lastLaneHit - beatBoxArrivalTime); //Debug.Log("Checking hit beatboxarrivaltime " + beatBoxArrivalTime + " vs lastLaneHit " + lastLaneHit + " delta " + timeDelta); if (timeDelta <= maxTimeDelta) { if (beatBoxArrival.direction >= 0) { //Debug.Log(":::::::::lastLaneDirection " + lastLaneDirection + " beatBoxArrival.direction " + beatBoxArrival.direction); if (lastLaneDirection != beatBoxArrival.direction) { beatBoxArrival.miss(); beatBoxArrival = null; beatBoxArrivalTime = -10; } else { beatBoxArrival.hit(timeDelta / maxTimeDelta); startParticles(); } } else { beatBoxArrival.hit(timeDelta / maxTimeDelta); startParticles(); } if (trailArrivalTime <= 0)//no trail, we can discard the box { beatBoxArrival = null; } else { checkingTrail = true; } } lastLaneHit = -10; } if (!checkingTrail && beatBoxArrival != null && beatBoxArrivalTime < clipTime - maxTimeDelta) //past due time and has no trail, it's a miss { //Debug.Log("MISS! " + beatBoxArrivalTime + " " + (clipTime - maxTimeDelta)); beatBoxArrival.miss(); beatBoxArrival = null; beatBoxArrivalTime = -10; } } if (lastLaneHit > 0 && lastLaneHit < clipTime - maxTimeDelta) { lastLaneHit = -10; } if (checkingTrail)//this needs to be checked after main checks above { //at this point, controller should stay inside checker, otherwise ontriggerexit would cause a miss() trailArrivalTime -= Time.deltaTime; if (trailArrivalTime <= 0) { beatBoxArrival.trailHit(); beatBoxArrival = null; checkingTrail = false; } } }