void onKeyClicked(object o, string s) { float timePast = evolveInTime(); // the effect of this method depends only on time // not on how many times you call it if (s.Equals("down")) { float delta = Mathf.Abs(timePast - t1); debugger.addOnce(delta.ToString()); if (delta < 0.4) { pressedGoodEnough = true; if (delta < 0.2) { pressedBest = true; } } } if (s.Equals("up")) { float delta = Mathf.Abs(timePast - t2); if (delta > 0.2) { releasedBest = false; if (delta > 0.4) { releasedGoodEnough = false; } } } }
void Update() { if (Input.GetMouseButtonDown(0) && onKey()) { Event(this, "down"); } if (Input.GetMouseButtonUp(0) && onKey()) { Event(this, "up"); } // clear debug text with left key if (Input.GetMouseButtonDown(1)) { debugger.addOnce(""); } }