void Start() { _controller = Pongstar.Get<GameController>(); var model = _controller.UI(); var sm = _controller.Score(); if (sm != null) _score = sm.As<Score>(); /* Fudge score for tests */ else { _score = new Score(); _score.Update(53223 + nRand.Int(100, 50), "Lucky"); _score.Winner = WinState.PLAYER; } /* Add to high scores? */ _controller.UpdateScore(_score.Points); _highscores = _controller.HighScores().Scores; /* Win noise~ */ model.Game.Audio = new nAudio(this.gameObject); Ps.Model.Actions.Game.SetupAudio(model.Game.Audio); if (_score.Winner == WinState.AI) model.Game.Audio.Play(Ps.Model.Actions.Game.WIN_LOSE_CHANNEL, Ps.Model.Actions.Game.LOSE_SOUND, 1f); else model.Game.Audio.Play(Ps.Model.Actions.Game.WIN_LOSE_CHANNEL, Ps.Model.Actions.Game.WIN_SOUND, 1f); /* Background~ */ _f = new Field(null, model.Camera); /* setup camera */ if (_pipe == null) { model.Camera.Active = true; _pipe = model.Camera.Pipe; _pipe.Drawables.Add(_f.Display); _c = new Collectables(model.Game); _pipe.Drawables.Add(_c.Display); } _ready = true; }
/** Reset the current state */ public void Reset() { Score = new Score(); NewGame(); }
/** AI points */ public static LData GameTopAi(Score s) { var e = 0.8f * (float) s.Ai / (float) (Config.WinScore - 1); var st = _fonts.Regular(5f, new Color(0.8f, 0.8f - e, 1f - e)); st.alignment = TextAnchor.MiddleRight; return new LData() { Msg = String.Format("Droid: {0}", s.Ai), Style = st }; }
/** Highscore win message */ public static LData ScoreWinMessage(Score s) { var st = _fonts.Regular(6f, new Color(0.8f, 1.0f, 0.8f)); st.alignment = TextAnchor.MiddleCenter; st.wordWrap = true; return new LData() { Msg = String.Format("You defeated Pong Droid and won with {0} points!", s.Points), Style = st }; }
/** Highscore lose message */ public static LData ScoreLoseMessage(Score s) { var st = _fonts.Regular(6f, new Color(1f, 0.8f, 0.8f)); st.alignment = TextAnchor.MiddleCenter; st.wordWrap = true; return new LData() { Msg = String.Format("You were defeated by Pong Droid and lost with {0} points", s.Points), Style = st }; }
/** Score for the top score section */ public static LData GameTopScore(Score s) { var st = _fonts.Regular(5f, new Color(0.8f, 0.8f, 1.0f)); st.alignment = TextAnchor.MiddleCenter; return new LData() { Msg = String.Format("Score: {0}", s.Points), Style = st }; }
/** Player points */ public static LData GameTopPlayer(Score s) { var e = 0.8f * (float) s.Player / (float) (Config.WinScore - 1); var st = _fonts.Regular(5f, new Color(0.8f - e, 0.8f, 1f - e)); st.alignment = TextAnchor.MiddleLeft; return new LData() { Msg = String.Format("Player: {0}", s.Player), Style = st }; }