Sign.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { GameProp } from "../../../data/GameData";
  2. /**
  3. * 签到界面
  4. * - 每天第一次上线默认弹出一次【除首日】
  5. * - 全部签完后,不可再签到。此处需要判断上次签到天数。
  6. * - 签到数据几点刷新?什么方式刷新? 与后端沟通
  7. * @author 薛鸿潇
  8. */
  9. const { ccclass, property } = cc._decorator;
  10. @ccclass
  11. export default class Sign extends cc.Component {
  12. @property({ type: cc.ScrollView, displayName: '滚动视图' })
  13. private scroll_view: cc.ScrollView = null!;
  14. @property({ type: cc.Animation, displayName: '按钮_动画' })
  15. private anim_btn: cc.Animation = null!;
  16. onLoad() {
  17. }
  18. start() {
  19. g.sign.sign_can = g.gameData.getProp(GEnum.GameProp.sign_can)
  20. g.sign.initListData();
  21. g.sign.init_data = true;
  22. }
  23. /**
  24. * 初始化滚动视图
  25. */
  26. private initScollView() {
  27. let list_data = g.sign.list_data;
  28. this.scroll_view.node.emit('srollview-init', list_data)
  29. }
  30. /**
  31. * 点击领取按钮
  32. */
  33. private clickReceiveReward() {
  34. g.sign.sign_can = 0;
  35. }
  36. update(dt) {
  37. if (g.sign.init_data) {
  38. g.sign.init_data = false;
  39. this.initScollView();
  40. this.initBtnStyle();
  41. }
  42. }
  43. /**
  44. * 初始化按钮样式
  45. */
  46. private initBtnStyle() {
  47. if (g.sign.sign_can) {
  48. this.anim_btn.play();
  49. this.anim_btn.getComponent('SetGray').setGray(false);
  50. } else {
  51. this.anim_btn.stop();
  52. this.anim_btn.node.scale = 1;
  53. this.anim_btn.getComponent('SetGray').setGray(true);
  54. }
  55. }
  56. }