Sign.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { GameProp, RewardState } 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. // gData.sign.sign_can = gData.gameData.getProp(GameProp.sign_can);
  20. gData.sign.initListData();
  21. gData.sign.init_data = true;
  22. }
  23. /**
  24. * 初始化滚动视图
  25. */
  26. private initScollView() {
  27. let list_data = gData.sign.list_data;
  28. this.scroll_view.node.emit('srollview-init', list_data)
  29. }
  30. /**
  31. * 点击领取按钮
  32. */
  33. private clickReceiveReward() {
  34. if (!gData.sign.sign_can) return;
  35. gData.sign.sign_can = 0;
  36. gData.sign.sign_last_bar++;
  37. let new_data = [
  38. {
  39. key: GameProp.sign_can,
  40. value: gData.sign.sign_can
  41. },
  42. {
  43. key: GameProp.sign_last_bar,
  44. value: gData.sign.sign_last_bar
  45. }
  46. ]
  47. gData.gameData.setProps(new_data);
  48. }
  49. update(dt) {
  50. if (gData.sign.init_data) {
  51. gData.sign.init_data = false;
  52. this.initScollView();
  53. this.initBtnStyle();
  54. }
  55. }
  56. /**
  57. * 初始化按钮样式
  58. */
  59. private initBtnStyle() {
  60. if (gData.sign.sign_can) {
  61. this.anim_btn.play();
  62. this.anim_btn.getComponent('SetGray').setGray(false);
  63. } else {
  64. this.anim_btn.stop();
  65. this.anim_btn.node.scale = 1;
  66. this.anim_btn.getComponent('SetGray').setGray(true);
  67. }
  68. }
  69. }