ContaiierStateChange.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { Tween, tween } from "cc";
  2. import { ContainerState } from "../../util/Enum";
  3. import { ContainerView } from "./ContainerView";
  4. export const ContainerNone = (who: ContainerView) => {
  5. const w = who;
  6. return {
  7. check: () => {
  8. if (w.container?.state == ContainerState.NONE) {
  9. return true;
  10. }
  11. return false;
  12. },
  13. entry: () => {
  14. who.node.position = who.container.o_pos.clone()
  15. },
  16. do: (dt: number) => {
  17. },
  18. exit: () => {
  19. }
  20. }
  21. }
  22. export const ContainerSelect = (who: ContainerView) => {
  23. const w = who;
  24. return {
  25. check: () => {
  26. if (w.container?.state == ContainerState.SELECTED) {
  27. return true;
  28. }
  29. return false;
  30. },
  31. entry: () => {
  32. let opos = who.container.o_pos.clone()
  33. Tween.stopAllByTag(ContainerState.SELECTED,who.node)
  34. tween(who.node).tag(ContainerState.SELECTED).to(.2,{position:opos.add3f(0,30,0)}).start()
  35. },
  36. do: (dt: number) => {
  37. },
  38. exit: () => {
  39. let opos = who.container.o_pos.clone()
  40. Tween.stopAllByTag(ContainerState.SELECTED,who.node)
  41. tween(who.node).tag(ContainerState.SELECTED).to(.2,{position:opos}).start()
  42. }
  43. }
  44. }