public void Update(GameTime gt) { if (guy == null && rowan == null) { return; } if (_scene.GameObjects.Exists("BadGuy") && guy == null) { guy = (BadGuy)_scene.GameObjects.GetGameObject("BadGuy"); } if (_scene.GameObjects.Exists("Rowan") && rowan == null) { rowan = _scene.GameObjects.GetGameObject("Rowan"); } timetodisapear += (float)gt.ElapsedGameTime.TotalSeconds; float percent = timetodisapear / 1f; percent = 1f - percent; if (percent <= 0f) { Done = true; } if (guy != null) { Sprite sprite = (Sprite)guy.GetComponents("BadGuySprite").ElementAt(0); sprite.Color = Color.White * percent; } if (rowan != null) { Sprite sprite = (Sprite)rowan.GetComponents("Rowan").ElementAt(0); sprite.Color = Color.White * percent; } }
public void Update(GameTime gt) { if (_appearBadGuy && a == null) { a = new BadGuy(_position, _scene); _scene.GameObjects.AddGameObject("BadGuy", a); Particle p = new Particle(new Vector2(0, 0), new Vector2(10, 10), Color.Blue, 3f); p.AddComponent("Color", new SinglePixelParticleDrawer(p)); ColorLerper lerp = (ColorLerper)p.AddComponentAndReturnComponent("lerper", new ColorLerper(p)); lerp.AddColor(Color.Red, 1f); lerp.AddColor(Color.Blue, 1f); lerp.AddColor(Color.Yellow, 1f); p.AddComponent("Movement", new RandomMovementEffect(p, 15, 20)); gen = new ParticleGenerator(a.Position, new Vector2(-10, 10), new Vector2(-10, 10), 27, p, _scene); p.Generator = gen; gen.Enabled = true; gen.IgnoreSafeSpawning = false; } if (gen != null) { gen.Update(gt); _badguyopacityTime += (float)gt.ElapsedGameTime.TotalSeconds; Sprite sprite = (Sprite)a.GetComponents("BadGuySprite").ElementAt(0); sprite.Color = Color.White * (_badguyopacityTime / 2f); if (_badguyopacityTime > 1.84f) { gen.Enabled = false; } if (!gen.particles.Any() && gen.Enabled == false) { this.Done = true; } } this._scene.Camera.Target = _position; _time += (Single)gt.ElapsedGameTime.TotalSeconds; if (!(_time >= TimePerMessage)) { return; } if (Input.IsKeyDown(Keys.Space) || Input.IsKeyDown(Keys.Enter) || Input.IsKeyDown(Keys.Escape)) { if (Input.WasKeyUp(Keys.Space)) { Finish(); return; } if (Input.WasKeyUp(Keys.Enter)) { Finish(); return; } if (Input.WasKeyUp(Keys.Escape)) { Finish(); return; } } }