private int prevHighScore; //!< for high scores /** * Use this for initialization * Load level information and start calculating stats data */ void Start() { // pull up the level counter counter = GameObject.Find("StomachChooseBackground"); // find the reference to the MouthChooseBackground level = counter.GetComponent <StomachLoadLevelCounter> (); // get the MouthLoadLevelScript on the background chooser populateStats(); // look up the stats we are tracking from the data saved on disk calculateStars(); // calculate the # of stars earned based on the stats pulled up }
/** * Draws the background image for the mouth loading screen */ void OnGUI() { counter = GameObject.Find("StomachChooseBackground"); // find the reference to the mouth background choser level = counter.GetComponent <StomachLoadLevelCounter> (); // get the current level from the counter // draw the proper level load screen to take up the entiere screen GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), backgrounds [Mathf.Clamp(level.getLevel() - 1, 0, level.getMaxLevels())]); }
/** * Update is called once per frame */ void Update() { //Debug.Log("Time:"+elapsedTime[0]); /** * Always do this update */ for (int i = 0; i < cellManager.cellScripts.Length; i++) { if (getCurrentAcidLevel() == "acidic") { elapsedTime[i] += Time.deltaTime; } } /** * Adjust each cell based on cell state and acidic level */ for (int i = 0; i < cellManager.cellScripts.Length; i++) { /** * Update timer */ if (cellManager.cellScripts[i].getCellState() == "dead") { cellManager.cellScripts[i].setTimerImage(5); } else if (elapsedTime[i] < .1f * nextCellActionTime[i]) { cellManager.cellScripts[i].setTimerImage(0); } else if (elapsedTime[i] < .3f * nextCellActionTime[i]) { cellManager.cellScripts[i].setTimerImage(1); } else if (elapsedTime[i] < .5f * nextCellActionTime[i]) { cellManager.cellScripts[i].setTimerImage(2); } else if (elapsedTime[i] < .7f * nextCellActionTime[i]) { cellManager.cellScripts[i].setTimerImage(3); } else if (elapsedTime[i] < .9f * nextCellActionTime[i]) { cellManager.cellScripts[i].setTimerImage(4); } /** * Check for changes by other scripts */ if (cellManager.cellScripts[i].getCellState() == "slimed" && (lastCellState[i] == "burning" || lastCellState[i] == "normal")) { lastCellState[i] = "slimed"; nextCellActionTime[i] = TIME_FOR_SLIME_FADE; elapsedTime[i] = 0f; deathsForThisCellInARow[i] = 0; } if (cellManager.cellScripts[i].getCellState() == "dead" && lastCellState[i] != "dead") { lastCellState[i] = "dead"; nextCellActionTime[i] = TIME_TO_REVIVE; elapsedTime[i] = 0f; deathsForThisCellInARow[i]++; } if (cellManager.cellScripts[i].getCellRefresh() == true) { lastCellState[i] = "slimed"; nextCellActionTime[i] = TIME_FOR_SLIME_FADE; elapsedTime[i] = 0f; cellManager.cellScripts[i].setCellRefresh(false); deathsForThisCellInARow[i] = 0; } /** * Need to handle all possible cases if the acid level is neutral or basic */ if (getCurrentAcidLevel() == "neutral" || getCurrentAcidLevel() == "basic") { if (cellManager.cellScripts[i].getCellState() == "dead" && lastCellState[i] != "dead") { if (lastCellState[i] != "dead") { deathsForThisCellInARow[i]++; } lastCellState[i] = "dead"; /* * if (elapsedTime[i] >= nextCellActionTime[i]) * { * cellManager.cellScripts[i].setCellState("normal"); * nextCellActionTime[i] = TIME_TO_BURN; * elapsedTime[i] = 0f; * } */ continue; } if (cellManager.cellScripts[i].getCellState() == "slimed") { if (lastCellState[i] != "slimed") { deathsForThisCellInARow[i] = 0; } nextCellActionTime[i] = TIME_FOR_SLIME_FADE; elapsedTime[i] = 0f; continue; } /* * cellManager.cellScripts[i].setCellState("normal"); */ nextCellActionTime[i] = TIME_TO_BURN; //elapsedTime[i] = 0f; continue; } if (getCurrentAcidLevel() == "acidic") { if (cellManager.cellScripts[i].getCellState() == "dead") { if (lastCellState[i] != "dead") { deathsForThisCellInARow[i]++; } lastCellState[i] = "dead"; /*commend this so the cell will not refresh*/ /* * if (elapsedTime[i] >= nextCellActionTime[i]) * { * cellManager.cellScripts[i].setCellState("normal"); * nextCellActionTime[i] = TIME_TO_BURN; * elapsedTime[i] = 0f; * } */ continue; } // if the cell has been burning for too long it dies if (cellManager.cellScripts[i].getCellState() == "burning") { lastCellState[i] = "burning"; if (elapsedTime[i] >= nextCellActionTime[i]) { cellManager.cellScripts[i].setCellState("dead"); nextCellActionTime[i] = TIME_TO_REVIVE; elapsedTime[i] = 0f; deadcellcounter++; } continue; } if (cellManager.cellScripts[i].getCellState() == "slimed") { if (lastCellState[i] != "slimed") { deathsForThisCellInARow[i] = 0; } lastCellState[i] = "slimed"; if (elapsedTime[i] >= nextCellActionTime[i]) { cellManager.cellScripts[i].setCellState("burning"); nextCellActionTime[i] = TIME_TO_DIE; elapsedTime[i] = 0f; } continue; } if (cellManager.cellScripts[i].getCellState() == "normal") { lastCellState[i] = "normal"; if (elapsedTime[i] >= nextCellActionTime[i]) { cellManager.cellScripts[i].setCellState("burning"); nextCellActionTime[i] = TIME_TO_DIE; elapsedTime[i] = 0f; } continue; } } } if (totalfoodcounter >= MAX_FOOD_DROPED && sFM.noFoodBlobs()) { if (getCurrentAcidLevel() == "basic" | getCurrentAcidLevel() == "neutral") { endTimer = endTimer - Time.deltaTime; if (endTimer <= 0f) { GameObject chooseBackground = GameObject.Find("StomachChooseBackground"); StomachLoadLevelCounter level = chooseBackground.GetComponent <StomachLoadLevelCounter> (); level.nextLevel(); //Application.LoadLevel ("StomachStats"); endGameScript.end(); } } } PlayerPrefs.SetInt("StomachStats_totalfood", totalfoodcounter - 1); PlayerPrefs.SetInt("StomachStats_timesCellDied", deadcellcounter); PlayerPrefs.SetInt("StomachStats_foodDisolved", disolvedfoodcounter); }