ADClearSickData.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /** 清除害虫数据类 */
  2. import { FactroyState, FarmState, PastureState, ProductType } from "../../../game/data/GameData";
  3. const { ccclass } = cc._decorator;
  4. @ccclass
  5. export default class ADClearSickData {
  6. curConfigID = -1;
  7. tab = null;
  8. openPanel(tab, id) {
  9. this.tab = tab;
  10. this.curConfigID = id;
  11. mk.ui.openPanel('game/prefab/uiPanel/ADClearSickPanel');
  12. }
  13. clearSick() {
  14. if (this.tab == ProductType.nzw) {
  15. let farm = gData.gameData.getFarmDataMap(this.curConfigID);
  16. farm.state = FarmState.Ripe;
  17. if (gData.gameData.RawInsectCurArr[0] > 0) {
  18. gData.gameData.RawInsectCurArr[0]--;
  19. }
  20. }
  21. else if (this.tab == ProductType.dw) {
  22. let pasture = gData.gameData.getPastureDataMap(this.curConfigID);
  23. pasture.state = PastureState.Ripe;
  24. if (gData.gameData.RawInsectCurArr[1] > 0) {
  25. gData.gameData.RawInsectCurArr[1]--;
  26. }
  27. }
  28. else {
  29. let factory = gData.gameData.getFactoryDataMap(this.curConfigID);
  30. factory.state = FactroyState.Ripe;
  31. if (gData.gameData.RawInsectCurArr[2] > 0) {
  32. gData.gameData.RawInsectCurArr[2]--;
  33. }
  34. }
  35. gData.gameData.needFreshArr.push(this.curConfigID);
  36. }
  37. }