/** Reset the ball position and start again */ public void NewGame() { PlayerPaddle = new Paddle(this); AiPaddle = new Paddle(this); Ball = new Ball(this); Field = new Field(this, Camera()); Sparkle = new Sparkle(this); RainbowTrail = new RainbowTrail(this); Flare = new Ps.Model.Object.Flare(this); Collectables = new Collectables(this); /* actions */ SetupActions(); _input = new GameInput(this); Game.SoundReset(); // reload /* Set initial paddle positions */ PlayerPaddle.Position[0] = 0f; PlayerPaddle.Position[1] = Field.Bounds[1] + nLayout.DistanceInWorld(14f, nAxis.Y, _camera);; AiPaddle.Position[0] = 0f; AiPaddle.Position[1] = Field.Bounds[3] - AiPaddle.Size[1] - nLayout.DistanceInWorld(7f, nAxis.Y, _camera); var direction = new nGLine() { P1 = new float[2] { 0, 0 }, P2 = new float[2] { nRand.Float(0f, 1f), nRand.Float(1f, 0.3f) } }; var unit = direction.Unit; Ball.Position[0] = 0; Ball.Position[1] = 0; Ball.Velocity[0] = unit[0] * 35f; Ball.Velocity[1] = unit[1] * 35f; /* reset paddles */ AiPaddle.Ai = new EasyAiProfile(); AiPaddle.Speed = AiPaddle.Ai.Speed; PlayerPaddle.Speed = Config.PlayerSpeed; AiPaddle.Position[0] = 0; PlayerPaddle.Position[0] = 0; /* ai */ Activated = false; Camera().Pipe.Drawables.Clear(); Camera().Pipe.Render(); }
private Twinkle MakeTwinkle(Collectables parent) { var bounds = _state.GameBounds(); var t = new Twinkle() { Size = nRand.Float(5f, 1f), Points = 500, Position = new float[2] { nRand.Float(0, bounds.xMax * 3f / 4f), nRand.Float(0, bounds.yMax * 3f / 4f) }, Color = new float[4] { nRand.Float(0.9f, 0f, 0.2f), nRand.Float(0.9f, 0f, 0.2f), nRand.Float(0.9f, 0f, 0.2f), 0f }, SpinRate = nRand.Float(0, Config.CollectableSpinRate) }; return t; }
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; }
public void Manufacture(Collectables parent) { var m = new nMotion(MakeTwinkle(parent), MakeTwinkleAnim()); _twinks.Add(m); parent.Twinkles.Add((Twinkle) m.Parent); }