Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
Ce dépôt est archivé. Vous pouvez voir les fichiers et le cloner, mais vous ne pouvez pas pousser ni ouvrir de ticket/demande d'ajout.

45 lignes
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. }