CritLayer.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import { _decorator, Component, Node } from "cc";
  2. import Utils from "../../scripts/utils/Utils";
  3. import { Hall } from "../hall/Hall";
  4. import BaseUI from "../../scripts/base/BaseUI";
  5. import { RewardLayer } from "./RewardLayer";
  6. import { GoodsId } from "../../scripts/api/GoodsId";
  7. import { Tips } from "../../scripts/mgr/Tips";
  8. import GameM from "../../scripts/api/GameM";
  9. import ItemsM from "../../scripts/mgr/ItemsM";
  10. import UserM from "../../scripts/api/UserM";
  11. import UIUtils from "../../scripts/base/UIUtils";
  12. import { Vec3 } from "cc";
  13. import { isValid } from "cc";
  14. const { ccclass, property } = _decorator;
  15. export interface POGClaimLayerCallback {
  16. onClaim(isCritical: boolean): void;
  17. }
  18. @ccclass("CritLayer")
  19. export class CritLayer extends BaseUI {
  20. static async show(gameId: number, spinId: string, pogValue: number) {
  21. if (pogValue <= 0) {
  22. Tips.show("Invalid pog value");
  23. return;
  24. }
  25. let layer = await Hall.ins.showLayer("prefab/layer/CritLayer");
  26. layer.getComponent(CritLayer).init(gameId, spinId, pogValue);
  27. }
  28. private pogValue: number;
  29. private critRewardPog: number = 0;
  30. private spinId: string = "";
  31. private gameId: number = 0;
  32. async init(gameId: number, spinId: string, pogValue: number) {
  33. this.pogValue = pogValue;
  34. this.gameId = gameId;
  35. this.spinId = spinId;
  36. let result = await GameM.ins.getCritReward(gameId, spinId);
  37. if (!result) {
  38. this.playAnim();
  39. return;
  40. }
  41. UserM.ins.refreshGoods(result.goodList);
  42. this.critRewardPog = result.critPog;
  43. this.setText("lbl_crit_pog1", "" + Utils.formatNumber(pogValue, 2));
  44. this.setText(
  45. "lbl_crit_pog2",
  46. "" + Utils.formatNumber(pogValue + result.critPog, 2)
  47. );
  48. this.playAnim();
  49. }
  50. playAnim() {
  51. let self=this;
  52. this.a1.active = true;
  53. this.a1.setPosition(0, -500, 0);
  54. this.a2.setPosition(0, -500, 0);
  55. this.a3.setPosition(0, -500, 0);
  56. this.a3.setScale(0.5, 0.5, 0.5);
  57. UIUtils.AnimBezierMoveAndScale(
  58. this.a1,
  59. new Vec3(0, 0, 0),
  60. 0.7,
  61. 0.5,
  62. () => {}
  63. );
  64. setTimeout(() => {
  65. this.a2.active = true;
  66. UIUtils.AnimBezierMoveAndScale(this.a2, new Vec3(0, 0, 0), 1, 1, () => {});
  67. }, 1000);
  68. setTimeout(() => {
  69. if (!isValid(self.node)) {
  70. return;
  71. }
  72. this.a3.active = true;
  73. UIUtils.AnimBezierMoveAndScale(
  74. self.a3,
  75. new Vec3(0, 0, 0),
  76. 1.4,
  77. 1,
  78. () => {}
  79. );
  80. }, 1500);
  81. }
  82. private a1: Node;
  83. private a2: Node;
  84. private a3: Node;
  85. protected onLoad(): void {
  86. super.onLoad();
  87. this.a1 = this.FindNode("anim1").children[0];
  88. this.a2 = this.FindNode("anim2").children[0];
  89. this.a3 = this.FindNode("anim3").children[0];
  90. this.a1.active = false;
  91. this.a2.active = false;
  92. this.a3.active = false;
  93. }
  94. protected simpleOnBtnClick(name: string): void {
  95. switch (name) {
  96. case "btn_claim":
  97. break;
  98. case "btn_claim_critical":
  99. break;
  100. }
  101. this.closePage();
  102. }
  103. }