Beispiel #1
0
        public void FinishCure()
        {
            if (OnCureFinished != null)
            {
                OnCureFinished(currentCure);
            }

            // Reset cure but leave scenario active for a few seconds
            currentCure = null;
            StartCoroutine(DelayedNewScenario(6f));
        }
Beispiel #2
0
 private void HandleCureFinished(Cure cure)
 {
     PlayClip(cure.CalculateEffectiveness() > 0 ? goodCure : badCure);
 }
Beispiel #3
0
        private void Update()
        {
            if (currentLevel != null)
            {
                timeLeft -= Time.deltaTime;
                float percentageLeft = (timeLeft / (currentLevel.time * 60f));
                if (OnTimeLeftUpdated != null)
                {
                    OnTimeLeftUpdated(timeLeft, percentageLeft);
                }

                if (timeLeft <= 0)
                {
                    gameOver = true;
                    float totalScore = 0f;
                    int   deaths     = 0;

                    // Do some scoring
                    foreach (var cure in cures)
                    {
                        if (cure == currentCure)
                        {
                            continue;
                        }

                        float score = cure.CalculateEffectiveness();
                        if (score == float.NegativeInfinity)
                        {
                            deaths++;
                            totalScore -= 500f; // Lets just say you lose 500 points for killing someone, seems fair
                        }
                        else
                        {
                            totalScore += score;
                        }
                    }

                    int highScore = PlayerPrefs.GetInt("highScore", 0);
                    if (Mathf.RoundToInt(totalScore) > highScore)
                    {
                        PlayerPrefs.SetInt("highScore", Mathf.RoundToInt(totalScore));
                    }

                    currentLevel = null;
                    if (OnGameOver != null)
                    {
                        OnGameOver(totalScore, deaths);
                    }
                    return;
                }

                if (currentScenario == null)
                {
                    List <Scenario> possibleScenarios = Scenarios.instance.GetAllConfigs();

                    // First time round gets an easy one
                    if (lastScenario == null)
                    {
                        currentScenario = possibleScenarios[0];
                    }
                    else
                    {
                        possibleScenarios.Remove(lastScenario);
                        currentScenario = possibleScenarios[Random.Range(0, possibleScenarios.Count)];
                    }

                    currentCure = new Cure(currentScenario);
                    cures.Add(currentCure);
                    if (OnScenarioUpdated != null)
                    {
                        OnScenarioUpdated(currentScenario);
                    }
                }
            }
        }