GameConfing.ts 976 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { _decorator, Component, Node, v2, Vec2 } from 'cc';
  2. import { aa } from '../../scripts/aa';
  3. import { UI_Notify } from '../ui/ui_notify/UI_Notify';
  4. // import { UI_Notify } from '../ui_notify/UI_Notify';
  5. export const GameConfing = {
  6. // 容器大小
  7. capacity: 4,
  8. Hcapacity: 12,
  9. waterHight: 180,
  10. // 格子长宽
  11. containerWith: 82 + 10,
  12. containerHightMin: 220,
  13. containerHightMax: 280
  14. }
  15. export const SaveComponent = {
  16. getGameData: () => chsdk.get_gid() + "gameData",
  17. }
  18. export const Direction = Object.freeze({
  19. UP: v2(0, 1),
  20. DOWN: v2(0, -1),
  21. LEFT: v2(-1, 0),
  22. RIGHT: v2(1, 0)
  23. })
  24. export function Notify(msg: string): void {
  25. let ui = aa.uIMgr.getUI(UI_Notify) as UI_Notify;
  26. ui?.newNotify(msg);
  27. }
  28. /**
  29. *
  30. * @param time 单位秒
  31. */
  32. export function sleep(time: number): Promise<void> {
  33. return new Promise<void>((resolve)=>{
  34. setTimeout(()=>{
  35. resolve()
  36. },time*1000)
  37. })
  38. }