public virtual void RetryLevel() { LevelFail.SetActive(false); LevelComplete.SetActive(false); //PointManager.ResetPoints(); gameRunning = true; }
public virtual void FailLevel() { LevelFail.SetActive(true); gameRunning = false; }
private void UpdateGame() { //Pre game timer if (mPreGameTime > 0) { mPreGameTime--; if (mPreGameTime == 0) { mPlaying = true; ClearASCII(); WriteASCIICentred("PAUSED", mASCIISize.Width / 2, mASCIISize.Height / 2); } else { ClearASCII(); string[] lns = mLevel.Name.Split('|'); for (int i = 0; i < lns.Length; i++) { WriteASCIICentred(lns[i], mASCIISize.Width / 2, (mASCIISize.Height * (i + 1)) / (lns.Length + 1)); } } } if (mPlaying && !mPaused) { //Update all the snakes UpdateSnakes(); //Check block at bottom //if (GetTileAt(BottomDoorLocation) == TileType.Null) { // if (!IsThereSnakeAt(BottomDoorLocation)) { // SetTileAt(BottomDoorLocation, TileType.Wall); // } //} if (mMode == Mode.Normal) { //mLevelTime--; if (mLevelTime == 0) { AddRandomFood(mInitialFood - GetRemainingFoodCount()); mLevelTime = InitialLevelTime; } } } if (LevelUpdate != null) { LevelUpdate.Invoke(this, EventArgs.Empty); } //Repaint Invalidate(); //Callback functions switch (mCallbackState) { case CallbackState.WinGame: mPlaying = false; if (LevelComplete != null) { LevelComplete.Invoke(this, EventArgs.Empty); } break; case CallbackState.LoseGame: mPlaying = false; if (LevelFail != null) { LevelFail.Invoke(this, EventArgs.Empty); } break; } //Reset callback mCallbackState = CallbackState.Null; //Update the update counter mUpdateCnt = (mUpdateCnt + 1) % UpdatesPerSecond; }