private void Update() { timer.GetComponent<TextMesh>().text = Math.Floor(fTimeDay) + ""; timerSmall.GetComponent<TextMesh>().text = "."+Mathf.Floor((fTimeDay- Mathf.Floor(fTimeDay))*10); slider.GetComponentInChildren<Image>().color = new Color(Mathf.Clamp((fImmunityfCurrent / fImmunityLimite), 1, 1), 1, 0.5f, Mathf.Clamp((1 - fImmunityfCurrent / fImmunityLimite), 1, 1)); slider.value = fImmunityfCurrent; //if not in pause if (!isGameInPause || !gameOver) { // if no cell to exam, test if there is a cell if (cellToExam == null) { if (Cells.cells[5] != null) { cellToExam = Cells.cells[5].GetComponentInChildren<CelluleBehaviour>(); } } if (fImmunityfCurrent > fImmunityLimite) { gameOver = true; } // if time is up if (fTimeInvestigation < 0) { // resetTime and add mistake to immunity fTimeInvestigation = fTimeInvestigationMax; fImmunityfCurrent += fMistakeTime; StartCoroutine(textAppear(tooSlow, tooSlowAudio)); } // soustract time else { fTimeInvestigation -= 0.01f; } // if time is up if (fTimeDay < 0) { /// /// this condition access another day to the difficulty settings /// days.NextLevel(); } // soustract time else { fTimeDay -= 0.01f; } } }
// test of the cell public void TestInterrogation(bool isDestroy) { audioSource.PlayOneShot(pressButton, 1); destroyBtn.GetComponent<Button>().interactable = false; okBtn.GetComponent<Button>().interactable = false; StartCoroutine(buttonReactivate()); tentacule.GetComponent<Animator>().ResetTrigger("pushButton"); tentacule.GetComponent<Animator>().SetTrigger("pushButton"); /// GOOD RESPONSE !---------- /// if you destroy a bad cell if (cellToExam.isBad && isDestroy) { score+=BonusBD; cellToExam.isRejected = true; } // if you let pass a good cell else if (!cellToExam.isBad && !isDestroy) { score+=BonusGL; cellToExam.isRejected = false; } /// BAD RESPONSE !---------- // if you destroy a good cell else if (!cellToExam.isBad && isDestroy) { score -= malusGD; cellToExam.isRejected = true; fImmunityfCurrent += fMistakeGoodCellDestroy; StartCoroutine(textAppear(goodCell, goodCellAudio)); } // if you pass a bad cell else if (cellToExam.isBad && !isDestroy) { score -= malusBL; fImmunityfCurrent += fMistakeBadCellPass; cellToExam.isRejected = false; StartCoroutine(textAppear(badCell, badCellAudio)); } // base action when test , do a cell cycle and reset the time Cells.doCellCycle(); cellToExam = Cells.cells[5].GetComponentInChildren<CelluleBehaviour>(); fTimeInvestigation = fTimeInvestigationMax; }