|
|
@@ -6,13 +6,17 @@
|
|
|
* @LastEditors: dgflash
|
|
|
* @LastEditTime: 2022-09-20 17:18:29
|
|
|
*/
|
|
|
-import { EventTouch, Node, _decorator, sys } from "cc";
|
|
|
+import { EventTouch, Node, Widget, _decorator, sys, view } 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 } from "../../common/SingletonModuleComp";
|
|
|
import { CheckpointLevelItemViewComp } from "./CheckpointLevelItem";
|
|
|
+import { AdManager } from "../../../platform/ad/AdManager";
|
|
|
+import { ClearCellOperationComp } from "../bll/ClearCellOperation";
|
|
|
+import { AddCellOperationComp } from "../bll/AddCellOperation";
|
|
|
+import { FullVehicleOperationComp } from "../bll/FullVehicleOperation";
|
|
|
|
|
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
@@ -37,6 +41,22 @@ export class CheckpointMainViewComp extends CCComp {
|
|
|
const btnLeave = this.node.getChildByPath("bottom/btn_leave")
|
|
|
const btnReward = this.node.getChildByPath("btn_reward")
|
|
|
const btnSetting = this.node.getChildByPath("btn_setting")
|
|
|
+ const levelGroup = this.node.getChildByPath("level")
|
|
|
+ // console.log('当前平台',sys.os)
|
|
|
+ // if (sys.os === sys.OS.IOS || sys.os === sys.OS.ANDROID) {
|
|
|
+
|
|
|
+
|
|
|
+ // }
|
|
|
+ const safeArea = sys.getSafeAreaRect();
|
|
|
+ const winSize = view.getVisibleSize();
|
|
|
+
|
|
|
+ // 调整其 Widget 组件来适配刘海
|
|
|
+ const widget = levelGroup.getComponent(Widget);
|
|
|
+ if (widget) {
|
|
|
+ widget.top = winSize.height - safeArea.height - safeArea.y;
|
|
|
+ // console.log('偏移高度',widget.top)
|
|
|
+ widget.updateAlignment(); // 立即更新 widget 对齐
|
|
|
+ }
|
|
|
btnSkin.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
|
|
|
btnAddCell.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
|
|
|
btnClear.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
|
|
|
@@ -110,21 +130,47 @@ export class CheckpointMainViewComp extends CCComp {
|
|
|
oops.gui.toast('该关卡使用次数已满')
|
|
|
return
|
|
|
}
|
|
|
- oops.gui.open(UIID.ClearCell);
|
|
|
+ if (sys.platform === sys.Platform.WECHAT_GAME) {
|
|
|
+ oops.gui.open(UIID.ClearCell);
|
|
|
+ } else {
|
|
|
+ AdManager.getInstance().showRewardVideoAd(() => {
|
|
|
+ console.log('成功看完广告')
|
|
|
+ ecs.getSingleton(SingletonModuleComp).account.checkpoint.add(ClearCellOperationComp)
|
|
|
+ ecs.getSingleton(SingletonModuleComp).account.checkpoint.CheckpointModelBase.vm.clearCount += 1
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
break;
|
|
|
case "btn_add_cell":
|
|
|
if (checkpoint.CheckpointModelBase.vm.addCellCount >= 3) {
|
|
|
oops.gui.toast('该关卡使用次数已满')
|
|
|
return
|
|
|
}
|
|
|
- oops.gui.open(UIID.AddCell);
|
|
|
+ if (sys.platform === sys.Platform.WECHAT_GAME) {
|
|
|
+ oops.gui.open(UIID.AddCell);
|
|
|
+ } else {
|
|
|
+ AdManager.getInstance().showRewardVideoAd(() => {
|
|
|
+ console.log('成功看完广告')
|
|
|
+ ecs.getSingleton(SingletonModuleComp).account.checkpoint.add(AddCellOperationComp)
|
|
|
+ ecs.getSingleton(SingletonModuleComp).account.checkpoint.CheckpointModelBase.vm.addCellCount += 1
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
break;
|
|
|
case "btn_leave":
|
|
|
if (checkpoint.CheckpointModelBase.vm.leaveCount >= 3) {
|
|
|
oops.gui.toast('该关卡使用次数已满')
|
|
|
return
|
|
|
}
|
|
|
- oops.gui.open(UIID.VehicleLeave);
|
|
|
+ if (sys.platform === sys.Platform.WECHAT_GAME) {
|
|
|
+ oops.gui.open(UIID.VehicleLeave);
|
|
|
+ } else {
|
|
|
+ AdManager.getInstance().showRewardVideoAd(() => {
|
|
|
+ console.log('成功看完广告')
|
|
|
+ ecs.getSingleton(SingletonModuleComp).account.checkpoint.add(FullVehicleOperationComp)
|
|
|
+ ecs.getSingleton(SingletonModuleComp).account.checkpoint.CheckpointModelBase.vm.leaveCount += 1
|
|
|
+ })
|
|
|
+ }
|
|
|
break;
|
|
|
case "btn_reward":
|
|
|
oops.gui.open(UIID.SideReward);
|