FarmManager.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { find } from "cc";
  2. import { FarmIcon } from "./FarmIcon";
  3. import { FarmSystem } from "./FarmSystem";
  4. /**
  5. * 窗口管理器
  6. * 实际管理在窗口系统,这里仅仅作为API调用
  7. * @author 袁浩
  8. */
  9. export class FarmManager {
  10. private static get farmSystem(): FarmSystem {
  11. var farmSystemNode = find("Canvas/FarmSystem");
  12. return farmSystemNode ? farmSystemNode.getComponent(FarmSystem) : null;
  13. }
  14. public static plantCountMap: Map<number, number> = new Map();
  15. public static plantWindowIsOpening = false;
  16. public static plantIsRequesting = false;
  17. public static onPlant(id: number): void {
  18. this.farmSystem.plant(id);
  19. }
  20. public static getCurrFarm(): FarmIcon {
  21. return this.farmSystem.currSelectFarm;
  22. }
  23. public static selectFristFarm(): void {
  24. let farm = this.farmSystem.selectNextFarm();
  25. if (!farm) {
  26. this.farmSystem.currSelectFarm = this.farmSystem.farms[0];
  27. }
  28. }
  29. public static novice_selectFristFarm(): void {
  30. this.farmSystem.currSelectFarm = this.farmSystem.farms[0];
  31. }
  32. public static novice_plant(): void {
  33. this.farmSystem.novice_plant();
  34. }
  35. public static novice_clean(): void {
  36. this.farmSystem.novice_clean();
  37. }
  38. }