25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

45 lines
1.2KB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace coa4u
  5. {
  6. class ActionTintBy : ActionInterval
  7. {
  8. protected Vector4 color;
  9. protected const float coeff = 1F / 255F;
  10. public ActionTintBy(Vector4 tgtColor, float tgtDuration)
  11. : base(tgtDuration)
  12. {
  13. color = tgtColor * coeff;
  14. }
  15. public ActionTintBy(Vector3 tgtColor, float tgtDuration)
  16. : this(new Vector4(tgtColor.x, tgtColor.y, tgtColor.z), tgtDuration)
  17. {
  18. }
  19. public override ActionInstant clone()
  20. {
  21. return new ActionTintBy(color / coeff, duration);
  22. }
  23. public override ActionInstant reverse()
  24. {
  25. return new ActionTintBy(-color / coeff, duration);
  26. }
  27. public override void stepInterval(float dt)
  28. {
  29. float d = dt / duration;
  30. Vector4 tgt = color * d;
  31. Color tgtColor = renderer.material.color;
  32. tgtColor[0] += tgt[0];
  33. tgtColor[1] += tgt[1];
  34. tgtColor[2] += tgt[2];
  35. tgtColor[3] += tgt[3];
  36. renderer.material.color = tgtColor;
  37. }
  38. }
  39. }