示例#1
0
    void NextDayMenu()
    {
        pausedTime        = true;
        resumeTxt.enabled = true;
        Time.timeScale    = 0f;

        float killingRate = (Entity.Destroyed / (float)Entity.Spawned);

        float destructionRate = 0f;

        foreach (var e in Entity.entities)
        {
            destructionRate += e.GetDestructionLevel();
        }
        destructionRate /= Entity.entities.Count;

        Entity.Spawned   = 0;
        Entity.Destroyed = 0;

        float destructionPercent = killingRate * 0.3f + destructionRate * 0.7f;
        float taxesIncrease      = (todayEarnings * destructionPercent) * 0.01f;

        taxes += taxesIncrease;

        if (taxes < 0.2f)
        {
            taxes = 0.2f;
        }
        if (taxes > 0.9f)
        {
            taxes = 0.9f;
        }

        salary = 2333f * (1f - taxes);

        string incdec = (taxes - lastTaxes) > 0 ? "increased" : "decreased";
        string resume = string.Format(
            "<b>Day {0}</b>\n\n" +
            "You earned {1}$ and " + incdec + " the taxes amount by {2}% today.\n" +
            "Destruction level: {3} / 100%\n\n" +
            "Press Space to continue ...",
            dayIndex.ToString(),
            todayEarnings.ToString("0.00"),
            ((taxes - lastTaxes) * 100f).ToString("0.00"),
            (destructionPercent * 100f).ToString("0.00"));

        totalEarnigs += todayEarnings;
        todayEarnings = 0f;

        if (dayIndex == dayCount || !entity.Alive())
        {
            SetFinishScreen();
        }
        else
        {
            resumeTxt.SetText(resume);
        }

        ResetScene();

        var destructibles = GameObject.FindGameObjectsWithTag("destructible");
        var police        = GameObject.FindGameObjectsWithTag("police");

        spawner.Respawn();

        foreach (var p in police)
        {
            Destroy(p);
        }

        foreach (var d in destructibles)
        {
            Destructible2D.D2dDestructible des = d.GetComponent <Destructible2D.D2dDestructible>();
            des.ResetAlpha();
        }
    }