示例#1
0
 void Win()
 {
     if (!shouldUpdate)
     {
         return;
     }
     winPanel.gameObject.SetActive(true);
     winPanel.SetText(FindObjectOfType <BlockGrid>().count * 127);
     leaning      = 0.0f;
     shouldUpdate = false;
 }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }
        leaningBar_Commie.sliderVal = 1 - (leaning + 1) / 2;
        leaningBar_Cappie.sliderVal = (leaning + 1) / 2;
        if (!shouldUpdate)
        {
            return;
        }


        float incr = Mathf.Log10(Mathf.Abs(leaningAggregate) + 1) * Time.deltaTime * 0.3f;

        if (leaningAggregate < 0.0f)
        {
            incr *= -1.0f;
        }
        leaning += incr;
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            leaning       -= 0.1f;
            lastArrowUsage = Time.time;
        }
        else if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            leaning       += 0.1f;
            lastArrowUsage = Time.time;
        }
        else if (Input.GetKeyDown(KeyCode.A) && lastArrowUsage + 0.3 < Time.time)
        {
            leaning -= 0.1f;
        }
        else if (Input.GetKeyDown(KeyCode.D) && lastArrowUsage + 0.3 < Time.time)
        {
            leaning += 0.1f;
        }
        leaning = Mathf.Clamp(leaning, -1.0f, 1.0f);

        leaningAggregate = 0.0f;

        happiness          = Mathf.Min(happiness + happinessAggregate, 100.0f);
        cashFlow           = Mathf.Min(cashFlow + cashFlowAggregate, 100.0f);
        happinessAggregate = 0.0f;
        cashFlowAggregate  = 0.0f;

        leaningText.text = leaning.ToString() + "\n" + happiness.ToString() + "\n" + cashFlow.ToString();

        happinessBar.sliderVal = happiness / 100.0f;
        cashFlowBar.sliderVal  = cashFlow / 100.0f;

        if (cashFlow <= 0.0f)
        {
            //BroadcastMessage("StopSimulation");
            commieLosePanel.gameObject.SetActive(true);

            commieLosePanel.SetText(FindObjectOfType <BlockGrid>().count * 127);
            leaning      = -1.0f;
            shouldUpdate = false;
        }
        else if (happiness <= 0.0f)
        {
            //BroadcastMessage("StopSimulation");
            cappieLosePanel.gameObject.SetActive(true);
            cappieLosePanel.SetText(FindObjectOfType <BlockGrid>().count * 127);
            leaning      = 1.0f;
            shouldUpdate = false;
        }
    }