public bool Collide(GameJamComponent that) { Rectangle r1 = new Rectangle((int)this.Position.X, (int)this.Position.Y, (int)(this.width * this.scale), (int)(this.height * this.scale)); Rectangle r2 = new Rectangle((int)that.Position.X, (int)that.Position.Y, (int)(that.width * that.scale), (int)(that.height * that.scale)); return(r1.Intersects(r2)); }
public override void Update(GameTime gameTime) { base.Update(gameTime); bulletAnimation.Update(gameTime); foreach (GameComponent component in this.Screen.Components) { GameJamComponent drawable = component as GameJamComponent; if (drawable != null && this.Collide(drawable)) { if (drawable is Asteroid) { this.Destroy(); } if (team == Team.PLAYER) { ZombieShip zombie = drawable as ZombieShip; if (zombie != null) { this.Destroy(); zombie.Explode(); long points = zombie.PointValue * ((2 * this.Screen.GameSpeed) - 10); this.Screen.Player.ScorePoints(points); this.Screen.AddComponent(new ScoreDisplay(this.Game, this.Screen, zombie.Position, points)); } Boss boss = drawable as Boss; if (boss != null && boss.Alive) { this.Destroy(); boss.Damage(); } } } } }
public bool Collide(GameJamComponent that) { Rectangle r1 = new Rectangle((int)this.Position.X, (int)this.Position.Y, (int)(this.width*this.scale), (int)(this.height*this.scale)); Rectangle r2 = new Rectangle((int)that.Position.X, (int)that.Position.Y, (int)(that.width*that.scale), (int)(that.height*that.scale)); return r1.Intersects(r2); }