Example #1
0
    private void Update()
    {
        if (isDead)
        {
            return;
        }

        if (shipHull <= 0)
        {
            isDead = true;
            CameraControll.ChangeView(ViewKind.Space);
            return;
        }

        dangerObject.SetActive(shipHull < 0.3f);        //30%

        hullText.text = string.Format("{0:0}%", shipHull * 100f);
        foreach (TMP_Text t in moneyText)
        {
            t.text = money.ToString();
        }

        energyText.text = string.Format("{0:0}/{1:0}", energy, maxEnergy);

        if (currentTask == "")
        {
            return;
        }

        TaskContainer task = GetById(currentTask);

        if (!task.working)
        {
            return;
        }

        if (currentTime > 0)
        {
            currentTime  -= Time.deltaTime;
            task.progress = 1 - currentTime / task.task.time;
            return;
        }

        task.completed = true;
        task.working   = false;
        task.progress  = 1;

        OnScienceComplete?.Invoke(currentTask);

        currentTime = 0;
        currentTask = "";
    }