public override void Update(GameTime gameTime) { if (velocity.Y == 0.0f && GameEnvironment.Random.NextDouble() < 0.01) { velocity = CalculateRandomVelocity(); Color = CalculateRandomColor(); } minVelocity += 0.001f; PainterGameWorld pwg = GameWorld as PainterGameWorld; if (pwg.IsOutsideWorld(GlobalPosition)) { if (this.targetcolor == this.color) { pwg.score += 10; PainterFramework.AssetManager.PlaySound("snd_collect_points"); } else { pwg.lives--; } Reset(); } Angle = (float)Math.Sin(position.Y / 50.0f) * 0.1f; base.Update(gameTime); }
//UPDATE public override void Update(GameTime gameTime) { if (velocity.Y == 0.0f && GameEnvironment.Random.NextDouble() < 0.01) { velocity = CalculatedRandomVelocity(); Color = CalculatedRandomColor(); } //Gameworld is as property of all GameObjects referencing the root parentobject PainterGameWorld pgw = GameWorld as PainterGameWorld; //when the cans drops down the screen and color matches get 10 points else lose 1 life if (pgw.IsOutsideGameWorld(GlobalPosition)) { if (color == targetColor) { pgw.Score += 10; //Painter.AssetManager.PlaySound("snd_collect_points"); } else { pgw.Lives--; } Reset(); } Angle = (float)Math.Sin(position.Y / 50.0f) * 0.1f; minVelocity += 0.001f; base.Update(gameTime); }
public override void Update(GameTime gameTime) { if (Shooting) { velocity.X *= 0.99f; velocity.Y += 6; } PainterGameWorld pgw = GameWorld as PainterGameWorld; if (pgw.IsOutsideWorld(GlobalPosition)) { Reset(); } base.Update(gameTime); }