public Cursor(EntityState es, Town town) : base(es) { Town = town; _aimleftkey = new DoubleInput(Keys.A, Buttons.DPadLeft, PlayerIndex.One); _aimrightkey = new DoubleInput(Keys.D, Buttons.DPadRight, PlayerIndex.One); _quickaimkey = new DoubleInput(Keys.LeftShift, Buttons.RightShoulder, PlayerIndex.One); Physics = new Physics(this); Components.Add(Physics); Render = new Render(this, StateRef.GameRef.Game.Content.Load<Texture2D>(@"game/cursor")) { Layer = 1f, Scale = 6f }; Components.Add(Render); Body = new Body(this, town.Body.Position + (town.Render.Origin - Vector2.UnitY * 40 - Render.Origin) * Render.Scale, Vector2.One * 5); Components.Add(Body); Town.Health.DiedEvent += Destroy; }
public new void Start() { if (_alreadystarted) return; _alreadystarted = true; GameRef.BGColor = Color.BlueViolet; _bgimage = new Image(this, GameRef.Game.Content.Load<Texture2D>(@"game/background"), Vector2.Zero) { Render = {Scale = 6f, Layer = 0f} }; AddEntity(_bgimage); _town = new Town(this); AddEntity(_town); _es = new EnemySpawner(this); EntityRemoved += _es.RemoveEnemy; _es.Targets.Add(_town); AddEntity(_es); _scoretext = new Text(this, Vector2.Zero, Score.ToString(), GameRef.Game.Content.Load<SpriteFont>(@"font")); _scoretext.Body.Position = new Vector2(GameRef.Viewport.Width/2 - _scoretext.Render.DrawRectangle.Width/2, 10); _scoretext.Render.Layer = 1f; AddEntity(_scoretext); _healthtext = new Text(this, Vector2.Zero, _town.Health.HitPoints.ToString(), GameRef.Game.Content.Load<SpriteFont>(@"font")); _healthtext.Body.Position = new Vector2(GameRef.Viewport.Width / 2 - _healthtext.Render.DrawRectangle.Width / 2, 50); _healthtext.Render.Layer = 1f; _healthtext.Render.Color = Color.Red; AddEntity(_healthtext); _gameovertext = new Text(this, Vector2.Zero, "", GameRef.Game.Content.Load<SpriteFont>(@"font")); _gameovertext.Render.Layer = 1f; _gameovertext.Render.Text = "Game Over!\nPress Start or Enter to retry!"; _gameovertext.Render.Color = Color.Black; _town.Collision.NewPartners = _es.Enemies; }