LightFlash.as 948 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include "Scripts/GameObject.as"
  2. class LightFlash : GameObject
  3. {
  4. LightFlash()
  5. {
  6. }
  7. void Create(const Vector3&in position, const Quaternion&in rotation)
  8. {
  9. node.position = position;
  10. node.rotation = rotation;
  11. Light@ light = node.CreateComponent("Light");
  12. light.lightType = LIGHT_POINT;
  13. light.range = 500.0;
  14. light.color = Color(2.0, 2.0, 2.0);
  15. light.castShadows = true;
  16. light.shadowResolution = 0.25;
  17. light.rampTexture = cache.GetResource("Texture2D", "Textures/RampWide.png");
  18. duration = 0.1;
  19. }
  20. void FixedUpdate(float timeStep)
  21. {
  22. Light@ light = node.GetComponent("Light");
  23. light.color = light.color * Max(1.0 - timeStep * 10.0, 0.0);
  24. if (duration >= 0)
  25. {
  26. duration -= timeStep;
  27. if (duration <= 0)
  28. node.Remove();
  29. }
  30. }
  31. }