CheckpointSideRewardViewComp.ts 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import { EventTouch, Node, Toggle, Tween, Vec3, _decorator, easing, tween } from "cc";
  2. import { oops } from "../../../../../extensions/oops-plugin-framework/assets/core/Oops";
  3. import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
  4. import { CCComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
  5. import { UIID } from "../../common/config/GameUIConfig";
  6. import { SingletonModuleComp, smc } from "../../common/SingletonModuleComp";
  7. import { AdManager } from "../../../platform/ad/AdManager";
  8. import { CheckpointCheckFailComp } from "../bll/CheckpointCheck";
  9. import { AddCellOperationComp } from "../bll/AddCellOperation";
  10. import { LaunchManager } from "../../../platform/launch/LaunchManager";
  11. const { ccclass, property } = _decorator;
  12. /** 角色信息界面 */
  13. @ccclass('CheckpointSideRewardViewComp')
  14. @ecs.register('CheckpointSideRewardView', false)
  15. export class CheckpointSideRewardViewComp extends CCComp {
  16. private btnClose
  17. private btnSide
  18. private btnReward
  19. onAdded(args: any) {
  20. console.log(args);
  21. }
  22. onLoad() {
  23. this.btnClose = this.node.getChildByPath("BG/btn_close")
  24. this.btnSide = this.node.getChildByPath("BG/btn_side")
  25. this.btnReward = this.node.getChildByPath("BG/btn_reward")
  26. this.btnClose.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
  27. this.btnSide.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
  28. this.btnReward.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
  29. if (LaunchManager.getInstance().fromSide) {
  30. this.btnReward.active = true
  31. this.btnSide.active = false
  32. } else {
  33. this.btnSide.active = true
  34. this.btnReward.active = false
  35. }
  36. const window = this.node.getChildByName("BG")
  37. window.setScale(new Vec3(0, 0, 1));
  38. // 使用Tween来实现动画效果
  39. Tween.stopAllByTarget(window); // 停止该节点上的所有其他Tween
  40. tween(window)
  41. // .delay(0.1)
  42. .to(0.3, { scale: new Vec3(0.8, 0.8, 1) }, { easing: easing.backOut }) // 缩放动画
  43. .start(); // 开始动画
  44. }
  45. private onTouchEnd(event: EventTouch) {
  46. switch (event.target.name) {
  47. case "btn_close":
  48. oops.gui.remove(UIID.SideReward);
  49. break;
  50. case "btn_side":
  51. tt.navigateToScene({
  52. scene: "sidebar",
  53. success: (res) => {
  54. console.log("navigate to scene success");
  55. },
  56. fail: (res) => {
  57. console.log("navigate to scene fail: ", res);
  58. oops.gui.toast("跳转失败")
  59. // 跳转失败回调逻辑
  60. },
  61. });
  62. break;
  63. case "btn_reward":
  64. if (smc.initialize.account.AccountModel.reward) {
  65. oops.gui.toast("已经领取过奖励了")
  66. } else {
  67. oops.gui.toast("提前解锁关卡3皮肤")
  68. smc.initialize.account.AccountModel.reward = true
  69. oops.gui.open(UIID.Skin)
  70. }
  71. break;
  72. }
  73. event.propagationStopped = true;
  74. }
  75. reset() {
  76. this.node.destroy();
  77. }
  78. }