NoviceWindow.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { _decorator, Component, Node } from 'cc';
  2. import { Http } from '../../core/net/Http';
  3. import { Window } from '../../core/ui/window/Window';
  4. import { WindowManager } from '../../core/ui/window/WindowManager';
  5. import { WindowOpenMode } from '../../core/ui/window/WindowOpenMode';
  6. import { g } from '../../Data/g';
  7. import { platform } from '../../Data/platform';
  8. import { FarmManager } from '../../Main/FarmManager';
  9. const { ccclass, property } = _decorator;
  10. @ccclass('NoviceWindow')
  11. export class NoviceWindow extends Component {
  12. @property({ type: [Node], tooltip: "新手引导节点集合" }) novices: Array<Node> = [];
  13. @property({ type: Window, tooltip: "获取窗口" }) getWindow: Window;
  14. @property({ type: Http, tooltip: "http组件" }) http: Http;
  15. public static isNovicing = false;
  16. start() {
  17. NoviceWindow.isNovicing = true;
  18. for (let i = 0; i < this.novices.length; i++) {
  19. this.novices[i].active = i == 0;
  20. }
  21. }
  22. public next(e: TouchType, id: string): void {
  23. let index = parseInt(id);
  24. this.novices[index].active = false;
  25. if (this.novices[index + 1]) {
  26. this.novices[index + 1].active = true;
  27. if (index + 1 == 2 || index + 1 == 4) {
  28. FarmManager.novice_selectFristFarm();
  29. }
  30. } else {
  31. FarmManager.plantWindowIsOpening = false;
  32. this.node.active = false;
  33. this.node.destroy();
  34. }
  35. }
  36. public plant(e: TouchType, id: string): void {
  37. platform.reportThinking("login", JSON.stringify({ guide: "first_plant" }));
  38. g.gameData.getProductingList(31000).push({ productID: 10001, ripeDate: Date.now() + 1000 });
  39. FarmManager.novice_plant();
  40. this.next(e, id);
  41. }
  42. public async closeWindow(e: TouchType, id: string) {
  43. platform.reportThinking("login", JSON.stringify({ guide: "first_harvest" }));
  44. let result = await this.http.send("/api/user/getNoviceBonus");
  45. g.gameData.getProductingList(31000).length = 0;
  46. FarmManager.novice_clean();
  47. this.getWindow.close();
  48. this.next(e, id);
  49. }
  50. public goTowithDraw(e: TouchType, id: string): void {
  51. platform.reportThinking("login", JSON.stringify({ guide: "first_withdraw" }));
  52. WindowManager.open("Prefabs/Withdraw/Withdraw", WindowOpenMode.CloseAndCover);
  53. this.next(e, id);
  54. }
  55. }