private void UpdateFieldState(GameTime gameTime) { if (FieldStateTime > 0) { if (fieldState == FieldState.Cloaked) { if (CloakAlpha < 1) { if (!CloakCommited) { CloakCommited = true; InstanceManager.AddDisplacementChild(this); } CloakAlpha += gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed; if (CloakAlpha > 1) { CloakAlpha = 1; MyColor = new Color(0.25f, 0.25f, 0.25f, 0) * 0; } else { MyColor = new Color(0.25f, 0.25f, 0.25f, 1) * (1 - CloakAlpha); } } } } else { if (CloakAlpha > 0) { CloakAlpha -= gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed; if (CloakAlpha < 0) { CloakAlpha = 0; MyColor = new Color(0.25f, 0.25f, 0.25f, 1); if (CloakCommited) { CloakCommited = false; InstanceManager.RemoveDisplacementChild(this); } } else { MyColor = new Color(0.25f, 0.25f, 0.25f, 1) * (1 - CloakAlpha); } } } }
private void UpdateFieldState(GameTime gameTime) { InvTime -= gameTime.ElapsedGameTime.Milliseconds; if (InvTime < 1) { if (FieldStateTime > 0) { FieldStateTime -= gameTime.ElapsedGameTime.Milliseconds; if (fieldState == FieldState.SpeedBoost) { if (MyColor.R > 64) { MyColor.R = (byte)Math.Max(MyColor.R - gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 64); } if (MyColor.G < 255) { MyColor.G = (byte)Math.Min(MyColor.G + gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 255); } if (MyColor.B > 64) { MyColor.B = (byte)Math.Max(MyColor.B - gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 64); } ParticleManager.CreateParticle(new Vector3(Position.X(), Y, Position.Y()), Vector3.Zero, new Color(0.25f, 1, 0.5f), Size.X() * 10, 1); } if (fieldState == FieldState.DamageBoost) { if (MyColor.R < 255) { MyColor.R = (byte)Math.Max(MyColor.R + gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 255); } if (MyColor.G > 64) { MyColor.G = (byte)Math.Min(MyColor.G - gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 64); } if (MyColor.B > 64) { MyColor.B = (byte)Math.Max(MyColor.B - gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 64); } ParticleManager.CreateParticle(new Vector3(Position.X(), Y, Position.Y()), Vector3.Zero, new Color(1, 0.5f, 0.25f), Size.X() * 10, 1); } if (fieldState == FieldState.Cloaked) { if (CloakAlpha < 1) { if (!CloakCommited && !Dead) { CloakCommited = true; InstanceManager.AddDisplacementChild(this); } CloakAlpha += gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed; if (CloakAlpha > 1) { CloakAlpha = 1; MyColor = new Color(0.25f, 0.25f, 0.25f, 0) * 0; } else { MyColor = new Color(0.25f, 0.25f, 0.25f, 1) * (1 - CloakAlpha); } } if (FieldStateTime < 0) { SoundManager.Play3DSound("UnitUnCloak", new Vector3(Position.X(), Y, Position.Y()), 0.2f, 700, 3); } } } else { if (CloakAlpha > 0) { CloakAlpha -= gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed; if (CloakAlpha < 0) { CloakAlpha = 0; MyColor = new Color(0.25f, 0.25f, 0.25f, 1); if (CloakCommited) { CloakCommited = false; InstanceManager.RemoveDisplacementChild(this); } } else { MyColor = new Color(0.25f, 0.25f, 0.25f, 1) * (1 - CloakAlpha); } } else { //if (IsGhostMode) // ParticleManager.CreateParticle(new Vector3(Position.X(), Y, Position.Y()), Vector3.Zero, new Color(0.5f, 0.25f, 0.5f), Size.X() * 10, 1); int TargetR = 64; int TargetB = 64; if (MyColor.R < TargetR) { MyColor.R = (byte)Math.Min(MyColor.R + gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, TargetR); } else if (MyColor.R > TargetR) { MyColor.R = (byte)Math.Max(MyColor.R - gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, TargetR); } if (MyColor.G < 64) { MyColor.G = (byte)Math.Min(MyColor.G + gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 64); } else if (MyColor.G > 64) { MyColor.G = (byte)Math.Max(MyColor.G - gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 64); } if (MyColor.B < TargetB) { MyColor.B = (byte)Math.Min(MyColor.B + gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, TargetB); } } } } else { if (MyColor.R < 255) { MyColor.R = (byte)Math.Min(MyColor.R + gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 255); } if (MyColor.G < 255) { MyColor.G = (byte)Math.Min(MyColor.G + gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 255); } if (MyColor.B < 255) { MyColor.B = (byte)Math.Min(MyColor.B + gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * CloakAlphaChangeSpeed * 255, 255); } } }