ItemName.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { ProductType } from "../../data/GameData";
  2. const { ccclass, property } = cc._decorator;
  3. @ccclass
  4. export default class ItemName extends cc.Component{
  5. @property({displayName: '复选组件', type: cc.Toggle})
  6. public toggle: cc.Toggle = null;
  7. @property({displayName: '名字', type: cc.Label})
  8. public lbl_name: cc.Label = null;
  9. @property({displayName: '是否解锁标识', type: cc.Node})
  10. public sp_luck: cc.Node = null;
  11. @property({displayName: '红点', type: cc.Node})
  12. public node_redPoint: cc.Node = null;
  13. @property({displayName: '按钮', type: cc.Button})
  14. public btn_luck: cc.Button = null;
  15. pt:ProductType = ProductType.nzw;
  16. start(){
  17. }
  18. InitUI(name: string, luck: boolean, showRedPoint: boolean)
  19. {
  20. }
  21. setShowUIState(luck: boolean, showRedPoint: boolean, id: ProductType)
  22. {
  23. this.sp_luck.active = luck;
  24. this.btn_luck.node.active = luck;
  25. this.node_redPoint.active = showRedPoint;
  26. this.pt = id;
  27. }
  28. clickLuckBtn()
  29. {
  30. let data = gData.gameData.getProductArrByType(this.pt);
  31. if(data && data.length> 0 && data[0].unlock == 2)
  32. {
  33. let times = data[0].value - gData.gameData.playerProp.completeFarmTaskTimes;
  34. mk.tip.pop(`完成${times}次任务红包后解锁`);
  35. }
  36. }
  37. }