| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import { EventTouch, Node, Toggle, Tween, Vec3, _decorator, easing, tween } from "cc";
- import { oops } from "../../../../../extensions/oops-plugin-framework/assets/core/Oops";
- import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
- import { CCComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
- import { UIID } from "../../common/config/GameUIConfig";
- import { SingletonModuleComp, smc } from "../../common/SingletonModuleComp";
- import { AdManager } from "../../../platform/ad/AdManager";
- import { CheckpointCheckFailComp } from "../bll/CheckpointCheck";
- import { AddCellOperationComp } from "../bll/AddCellOperation";
- import { LaunchManager } from "../../../platform/launch/LaunchManager";
- const { ccclass, property } = _decorator;
- /** 角色信息界面 */
- @ccclass('CheckpointSideRewardViewComp')
- @ecs.register('CheckpointSideRewardView', false)
- export class CheckpointSideRewardViewComp extends CCComp {
- private btnClose
- private btnSide
- private btnReward
- onAdded(args: any) {
- console.log(args);
- }
- onLoad() {
- this.btnClose = this.node.getChildByPath("BG/btn_close")
- this.btnSide = this.node.getChildByPath("BG/btn_side")
- this.btnReward = this.node.getChildByPath("BG/btn_reward")
- this.btnClose.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
- this.btnSide.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
- this.btnReward.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
- if (LaunchManager.getInstance().fromSide) {
- this.btnReward.active = true
- this.btnSide.active = false
- } else {
- this.btnSide.active = true
- this.btnReward.active = false
- }
- const window = this.node.getChildByName("BG")
- window.setScale(new Vec3(0, 0, 1));
- // 使用Tween来实现动画效果
- Tween.stopAllByTarget(window); // 停止该节点上的所有其他Tween
- tween(window)
- // .delay(0.1)
- .to(0.3, { scale: new Vec3(0.8, 0.8, 1) }, { easing: easing.backOut }) // 缩放动画
- .start(); // 开始动画
- }
- private onTouchEnd(event: EventTouch) {
- switch (event.target.name) {
- case "btn_close":
- oops.gui.remove(UIID.SideReward);
- break;
- case "btn_side":
- tt.navigateToScene({
- scene: "sidebar",
- success: (res) => {
- console.log("navigate to scene success");
- },
- fail: (res) => {
- console.log("navigate to scene fail: ", res);
- oops.gui.toast("跳转失败")
- // 跳转失败回调逻辑
- },
- });
- break;
- case "btn_reward":
- if (smc.initialize.account.AccountModel.reward) {
- oops.gui.toast("已经领取过奖励了")
- } else {
- oops.gui.toast("提前解锁关卡3皮肤")
- smc.initialize.account.AccountModel.reward = true
- oops.gui.open(UIID.Skin)
- }
- break;
- }
- event.propagationStopped = true;
- }
- reset() {
- this.node.destroy();
- }
- }
|