void onScore(ScoreLevels scoreLevel)
    {
        if (scoreLevel == ScoreLevels.Perfect || scoreLevel == ScoreLevels.GoodShit || scoreLevel == ScoreLevels.Great)
        {
            combo += 1;
        }
        else
        {
            combo = 0;
        }
        if (combo == 0)
        {
            score += scoreMaping [scoreLevel];
        }
        else
        {
            score += scoreMaping [scoreLevel] * Mathf.Log(combo, comboLogBase);
        }

        if (score < 0)
        {
            score = 0;
        }

        DebugPanel.Instance.log("Score Numeric", score);
        scoreCount [scoreLevel] += 1;
        comboText.SetCombo(combo);
        maxCombo = Mathf.Max(combo, maxCombo);

        healthBar.setFraction(healthBarDisplayFraction());
    }
Ejemplo n.º 2
0
    void onScore(ScoreLevels score)
    {
        count = (count + 0);

//		Debug.LogFormat ("Score received {0}", score);

        GameObject scorePrefab = scoreToPrefab [score];

        if (scorePrefab != null)
        {
//			Debug.Log ("Found prefab");

            var scaleFactor = 1.5f;
            var time        = 0.2f;


            //cancel outstanding hides
            CancelInvoke("hideActivePrefab");
            if (activePrefab != null && activePrefab != scorePrefab)
            {
                activePrefab.SetActive(false);
            }

            activePrefab = scorePrefab;
            scorePrefab.SetActive(true);


//			if (scorePrefab != activePrefab) {
////				scorePrefab.transform.localScale = new Vector3 (0, 0, 1);
//
////				LeanTween.scaleX (scorePrefab, 1f, 0.05f);
////				LeanTween.scaleY (scorePrefab, 1f, 0.05f);
//			} else {
//
//			}


//			LeanTween.scaleX (scorePrefab, scaleFactor, time).setDelay (animationDelay)
//				.setOnComplete (() => LeanTween.scaleX (scorePrefab, 1.0f, time));
//			LeanTween.scaleY (scorePrefab, scaleFactor, time).setDelay (animationDelay)
//				.setOnComplete (() => LeanTween.scaleY (scorePrefab, 1.0f, time));
//
            Invoke("hideActivePrefab", liveTime);


//			LeanTween.scaleY (scorePrefab, scaleFactor, 0.1f);



//			LeanTween.move(scorePrefab,
//				new Vector2(1, 1),
//				1.0f
//				);
        }
    }
    public void processKey(StandardKeyCodes keycode, long time, bool keyDown = true)
    {
        if (patternMaster.isPlaying())
        {
            StandardControls control        = KeyMappings.keyToControl(keycode);
            MusicEventTypes  musicEventType = controlToEventType [control];

            //find first matching event
//			int index = events[eventType].FindIndex (e => actionMatches(eventType, e));
            //		Debug.Log (events[0]);

            var relevantEvents = events;
            if (!keyDown)              //keyup
            {
                relevantEvents = releaseEvents;
            }

            if (relevantEvents [musicEventType].Count > 0)
            {
                MusicEvent e = relevantEvents[musicEventType][0];


                if (keyDown)
                {
                    long expectedTime = patternMaster.absTime(e.startTime);
                    long delta        = expectedTime - time;

                    long adjustedError = delta + latencyAdjustment;
                    //only consider if within scoring range
                    if (delta < ScorableThreshold)
                    {
//						Debug.LogFormat ("Delta {0}", delta);
//						Debug.LogFormat ("Adjusted delta {0}", adjustedError);

                        ScoreLevels score = ReportQuality(adjustedError);

                        Messenger <ScoreLevels> .Invoke(MessengerKeys.EVENT_SCORE, score);

                        panel.log("Score", scoreToString [score]);

                        //					if (mode == ScoreCalculatorMode.Calibration) {
                        //						calibrator.addDelta ((int)delta);
                        //					}
                        relevantEvents [musicEventType].RemoveAt(0);

                        Messenger <MusicEvent> .Invoke(MessengerKeys.EVENT_HIT, e);


                        if (e.isHeldEvent())
                        {
                            releaseEventActive [e] = true;
                        }
                    }
                }
                else
                {
                    long expectedUpTime = patternMaster.absTime(e.endTime);
                    long delta          = expectedUpTime - time;
                    long adjusted       = delta + latencyAdjustment;
                    //only register relases if already down
                    if (releaseEventActive.ContainsKey(e))
                    {
                        ScoreLevels score = ReportQuality(adjusted);
//						Debug.LogFormat ("Release {0}", adjusted);

                        relevantEvents [musicEventType].RemoveAt(0);
                        Messenger <ScoreLevels> .Invoke(MessengerKeys.EVENT_SCORE, score);

                        Messenger <MusicEvent> .Invoke(MessengerKeys.EVENT_HELD_RELEASED, e);
                    }
                }
            }
        }
    }