void OnGUI() { int stars; GUI.skin = GuiSkin; DrawHud(); switch (mGameState) { case GameState.GameOver: ShowCenteredMessage(mGameOverReason == GameOverReason.CiviliansDied ? Strings.GameOverCiviliansDied : Strings.GameOverPlayerDied, Strings.RetryingIn); GameManager.Instance.AutoSave(); break; case GameState.Won: // show the "Level Cleared" message ShowCenteredMessage(Strings.LevelCleared, Strings.NextLevelIn); // show # of stars earned stars = CalcStars(); Gu.Label(Gu.Center(0), Gu.Middle(GameConsts.StarsY), Gu.Dim(GameConsts.StarsFontSize), Util.MakeStars(stars)); // show message based on # of stars Gu.SetColor(GameConsts.StarsMessageColor); Gu.Label(Gu.Center(0), Gu.Middle(GameConsts.StarsMessageY), Gu.Dim(GameConsts.StarsMessageFontSize), Strings.StarsMessage[stars]); GameManager.Instance.AutoSave(); break; } }
bool DrawSignInButton() { DrawSignInBar(); // draw the sign in button GUI.skin = SignInButtonGuiSkin; bool result = Gu.Button(Gu.Center(GameConsts.Menu.SignInButtonX), Gu.Bottom(GameConsts.Menu.SignInButtonY), Gu.Dim(GameConsts.Menu.SignInButtonWidth), Gu.Dim(GameConsts.Menu.SignInButtonHeight), Gu.Dim(GameConsts.Menu.SignInButtonFontSize), " " + Strings.SignIn); GUI.skin = GuiSkin; // draw the Google+ logo GUI.DrawTexture(new Rect(Gu.Center(GameConsts.Menu.GooglePlusLogoX), Gu.Bottom(GameConsts.Menu.GooglePlusLogoY), Gu.Dim(GameConsts.Menu.GooglePlusLogoSize), Gu.Dim(GameConsts.Menu.GooglePlusLogoSize)), GooglePlusTex); // draw sign in encouragement text DrawSignInBlurb(Strings.SignInBlurb); return(result); }
void DrawTitle() { Gu.SetColor(Color.black); Gu.Label(Gu.Center(0), Gu.Middle(GameConsts.PauseScreen.TitleY), Gu.Dim(GameConsts.PauseScreen.TitleFontSize), Strings.GamePaused); }
void DrawTitle() { Gu.SetColor(GameConsts.ThemeColor); Gu.Label(Gu.Center(0), (int)Util.Interpolate(0.0f, 0.0f, 1.0f, Gu.Top(GameConsts.Menu.TitleY), mTransition.NormalizedElapsed), Gu.Dim(GameConsts.Menu.TitleFontSize), Strings.GameTitle); }
void ShowCenteredMessage(string centerMessage, string restartMessage) { int rem = (int)Mathf.Ceil(mAutoAdvanceCountdown.Remaining); Gu.SetColor(Color.black); Gu.Label(Gu.Center(0), Gu.Middle(0), Gu.Dim(GameConsts.GameOverFontSize), centerMessage); Gu.Label(Gu.Center(0), Gu.Middle(GameConsts.RetryTextOffset), Gu.Dim(GameConsts.RetryTextFontSize), restartMessage + " " + rem); }
bool DrawQuitButton() { Gu.SetColor(Color.white); return(Gu.Button(Gu.Center(GameConsts.PauseScreen.QuitX), Gu.Middle(GameConsts.PauseScreen.QuitY), Gu.Dim(GameConsts.PauseScreen.ButtonWidth), Gu.Dim(GameConsts.PauseScreen.ButtonHeight), Gu.Dim(GameConsts.PauseScreen.ButtonFontSize), Strings.QuitGame)); }
bool DrawQuitButton() { float w = GameConsts.Menu.AchButtonWidth; float h = GameConsts.Menu.AchButtonHeight; float x = -500; float y = 200; return(Gu.Button(Gu.Center(x), Gu.Middle(y), Gu.Dim(w), Gu.Dim(h), Gu.Dim(GameConsts.Menu.AchFontSize), Strings.QuitGame)); }
void DrawSignInBlurb(string text) { bool authenticated = GameManager.Instance.Authenticated; float x = authenticated ? 0.0f : GameConsts.Menu.SignInBlurbX; // draw sign in explanation text Gu.SetColor(authenticated ? GameConsts.Menu.SignedInBlurbColor : GameConsts.Menu.SignInBlurbColor); Gu.Label(Gu.Center(x), Gu.Bottom(GameConsts.Menu.SignInBlurbY), Gu.Dim(GameConsts.Menu.SignInBlurbFontSize), text); }
bool DrawLbButton() { float w = GameConsts.Menu.LbButtonWidth; float h = GameConsts.Menu.LbButtonHeight; float x = GameConsts.Menu.LbButtonX; float y = GameConsts.Menu.LbButtonY; return(Gu.Button(Gu.Center(x), (int)Util.Interpolate(0.0f, Screen.height, 1.0f, Gu.Middle(y), mTransition.NormalizedElapsed), Gu.Dim(w), Gu.Dim(h), Gu.Dim(GameConsts.Menu.LbFontSize), Strings.Leaderboards)); }
bool DrawPlayButton() { float w = GameConsts.Menu.PlayButtonWidth; float h = GameConsts.Menu.PlayButtonHeight; Gu.SetColor(Color.white); return(Gu.Button( Gu.Center(-w / 2), (int)Util.Interpolate(0.0f, Screen.height, 1.0f, Gu.Middle(-h / 2), mTransition.NormalizedElapsed), Gu.Dim(w), Gu.Dim(h), Gu.Dim(GameConsts.Menu.PlayButtonFontSize), Strings.Play)); }
void DrawHud() { Gu.SetColor(Color.black); // draw score Gu.Label(Gu.Right(GameConsts.Hud.ScoreX), Gu.Top(GameConsts.Hud.ScoreY), Gu.Dim(GameConsts.Hud.ScoreFontSize), ((int)mDisplayedScore.Value).ToString("D5")); // draw % level complete int pc = Util.Clamp((int)(mLevelTime.NormalizedElapsed * 100), 0, 100); if (mGameState == GameState.Playing && pc == 100) { // while playing, we never get to 100% :-D pc = 99; } // draw level # and % complete Gu.Label(Gu.Left(GameConsts.Hud.StageX), Gu.Bottom(GameConsts.Hud.StageY), Gu.Dim(GameConsts.Hud.StageFontSize), string.Format(Strings.StageFmt, Util.GetLevelLetter(GameManager.Instance.Level), pc)); // draw accuracy Gu.Label(Gu.Right(GameConsts.Hud.AccuracyX), Gu.Top(GameConsts.Hud.AccuracyY), Gu.Dim(GameConsts.Hud.AccuracyFontSize), string.Format(Strings.AccuracyFmt, GetAccuracyPercent())); // draw combo counter if (mCombo > 1 && Util.BlinkFunc(GameConsts.BlinkPeriod, 0.0f)) { Gu.SetColor(GameConsts.Hud.ComboColor); Gu.Label(Gu.Center(GameConsts.Hud.ComboX), Gu.Top(GameConsts.Hud.ComboY), Gu.Dim(GameConsts.Hud.ComboFontSize), string.Format(Strings.ComboFmt, GetComboMult())); } // if there's a message being displayed, draw it now if (mMessageCd.Active && mMessage != null) { Gu.SetColor(0.0f, 0.0f, 0.0f, Util.Trapezoid(GameConsts.Hud.MessageDuration, GameConsts.Hud.MessageTransitionDuration, mMessageCd.Elapsed)); Gu.Label(Gu.Center(0), Gu.Middle(0), Gu.Dim(GameConsts.Hud.MessageFontSize), mMessage); } }
void OnGUI() { if (Time.timeScale == 0) { return; } if (DelayBeforeStart > 0) { return; } GUI.skin = GuiSkin; switch (phase) { case 0: float aspect = ArrowTex.width / (float)ArrowTex.height; GUI.DrawTexture(new Rect(Gu.Left(GameConsts.Tutorial.SteerArrowX), Gu.Top(0), aspect * Screen.height, (int)(mTransitionCd.NormalizedElapsed * Screen.height)), ArrowTex); Gu.Label( Gu.Left(GameConsts.Tutorial.SteerTextX), (int)Util.Interpolate(0.0f, 0.0f, 1.0f, Gu.Middle(0), mTransitionCd.NormalizedElapsed), Gu.Dim(GameConsts.Tutorial.FontSize), Strings.Tutorial1); break; case 1: Gu.Label(Gu.Right(GameConsts.Tutorial.FireTextX), (int)Util.Interpolate(0.0f, Screen.height, 1.0f, Gu.Middle(0), mTransitionCd.NormalizedElapsed), Gu.Dim(GameConsts.Tutorial.FontSize), Strings.Tutorial2); break; default: Gu.Label(Gu.Center(0), (int)(Util.Interpolate(0.0f, 0.0f, 1.0f, Gu.Middle(0), mTransitionCd.NormalizedElapsed)), Gu.Dim(GameConsts.Tutorial.FontSize), Strings.Tutorial3); break; } }
void OnGUI() { GUI.skin = GuiSkin; Gu.SetColor(Color.black); Gu.Label(Gu.Center(GameConsts.EndScreen.EndTextX), (int)Util.Interpolate(0.0f, Screen.height, 1.0f, Gu.Middle(GameConsts.EndScreen.EndTextY), mTransitionCd.NormalizedElapsed), Gu.Dim(GameConsts.EndScreen.EndTextFontSize), Strings.EndText, false); bool wantOut = DrawUpButton(); if (mTransitionCd.Expired && wantOut) { GameManager.Instance.QuitToMenu(); } }
bool DrawLevelButton(int levelNo, int col, int row) { LevelProgress lp = GameManager.Instance.Progress.GetLevelProgress(levelNo); if (lp == null) { return(false); } float centerX = StartX + Stride * col; float centerY = StartY + Stride * row; centerX = Util.Interpolate(0.0f, 0.0f, 1.0f, centerX, mTransition.NormalizedElapsed); float left = centerX - LevelSize * 0.5f; float top = centerY - LevelSize * 0.5f; if (GameManager.Instance.Progress.IsLevelUnlocked(levelNo)) { Gu.SetColor(Color.white); bool r = Gu.Button(Gu.Center(left), Gu.Middle(top), Gu.Dim(LevelSize), Gu.Dim(LevelSize), Gu.Dim(LevelFontSize), Util.GetLevelLetter(levelNo)); Gu.SetColor(Color.white); if (lp.Cleared) { Gu.Label(Gu.Center(centerX + ScoreOffsetX), Gu.Middle(centerY + ScoreOffsetY), Gu.Dim(ScoreFontSize), lp.Score.ToString("D5")); Gu.Label(Gu.Center(centerX + ScoreOffsetX), Gu.Middle(centerY - ScoreOffsetY), Gu.Dim(ScoreFontSize), Util.MakeStars(lp.Stars)); } return(r); } else { GUI.DrawTexture(new Rect(Gu.Center(left), Gu.Middle(top), Gu.Dim(LevelSize), Gu.Dim(LevelSize)), DisabledTex); return(false); } }
void DrawPleaseWait() { Gu.SetColor(Color.black); Gu.Label(Gu.Center(0), Gu.Middle(0), Gu.Dim(GameConsts.Menu.PleaseWaitFontSize), GameManager.Instance.AuthProgressMessage); }