public override void Draw(World world, XnaGraphics graphics) { this.m_World = world as RedMeansGoWorld; base.Draw(world, graphics); graphics.DrawSprite((int)this.X, (int)this.Y, this.Width - 8, this.Height - 8, "player.powerup", this.PowerupColor, false, this.Rotation, new Vector2(54 / 2, 54 / 2)); string msg; if (this.Health <= 0) msg = "You win. They died."; else msg = "Distance to Heart: " + (this.Health * 150).ToString("F2") + "cm"; graphics.DrawStringCentered((int)this.X, (int)this.Y + 40, msg); RedMeansGoGame.SetWindowTitle(msg); }
public static IEnumerable<double> YieldStopped(RedMeansGoWorld world) { yield return 0; }
public static IEnumerable<double> YieldHeartbeats(RedMeansGoWorld world) { while (true) { double health = (world.Player as RedMeansGo.Entities.Player).Health; if (health < 0.2) { yield return 0; yield return 0.5; yield return 1; yield return 1; yield return 0.8; yield return -0.1; yield return -0.7; yield return -0.7; yield return -0.3; } else if (health < 0.5) { yield return 0; yield return 0.01; yield return 0.06; yield return 0.5; yield return 0.8; yield return 1; yield return 1; yield return 1; yield return 0.8; yield return -0.1; yield return -0.7; yield return -0.7; yield return -0.7; yield return -0.3; yield return -0.1; yield return 0; yield return 0.15; yield return -0.05; } else { yield return 0; yield return 0; yield return 0.01; yield return 0.03; yield return 0.06; yield return 0.08; yield return 0.06; yield return 0.5; yield return 0.8; yield return 1; yield return 1; yield return 1; yield return 0.8; yield return -0.1; yield return -0.7; yield return -0.7; yield return -0.3; yield return -0.1; yield return 0; yield return 0.15; yield return 0.2; yield return 0.25; yield return 0.3; yield return 0.15; yield return -0.05; } for (var i = 0; i < (int)(health * 30); i++) yield return 0; } }
public override void Update(World world) { this.m_World = world as RedMeansGoWorld; base.Update(world); // Game pace is set by player health... reduce it very very slowly. this.Health -= 0.0001; //this.PowerupColor = new Color((float)m_Random.NextDouble(), (float)m_Random.NextDouble(), (float)m_Random.NextDouble()); if (this.Health <= 0) this.PowerupColor = new Color(127, 127, 127); else this.Rotation += 0.1 * ((1 - this.Health) * 0.3 + 1); double heartbeat = (world as RedMeansGoWorld).Heartbeats.Current; if (this.Health <= 0) heartbeat = -0.4; // You're dead :( this.Width = (int)(WIDTH * (heartbeat * 0.15 + 1)); this.Height = (int)(HEIGHT * (heartbeat * 0.15 + 1)); //this.Origin = new Vector2(this.Width / 2, this.Height / 2); if (this.X < RedMeansGoGame.GAME_WIDTH / 2) { foreach (var e in world.Entities) e.X += Tileset.TILESET_PIXEL_WIDTH - RedMeansGoGame.GAME_WIDTH; } if (this.X > Tileset.TILESET_PIXEL_WIDTH - RedMeansGoGame.GAME_WIDTH / 2) { foreach (var e in world.Entities) e.X -= Tileset.TILESET_PIXEL_WIDTH - RedMeansGoGame.GAME_WIDTH; } if (this.Y > Tileset.TILESET_PIXEL_HEIGHT - RedMeansGoGame.GAME_HEIGHT / 2) this.Y = Tileset.TILESET_PIXEL_HEIGHT - RedMeansGoGame.GAME_HEIGHT / 2; if (this.Y < RedMeansGoGame.GAME_HEIGHT / 2) { foreach (var e in world.Entities) e.Y += Tileset.TILESET_PIXEL_HEIGHT - RedMeansGoGame.GAME_HEIGHT; } }