PlotStopViewImpl.ts
2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { SDK } from "simba-sdk";
import SVButton from "simba-sdk-ccsvbutton";
import { DummyNode } from "../../../../common/CCDummyObjects";
import { CCPureView } from "../../../../common/classbase/CCViewBase";
import { GameConstData } from "../../../../common/gameplay/gamedata/GameConstData";
import { GetRewardType } from "../../../../common/gameplay/gamedata/GameEnumData";
import { ShowType } from "../../../Enums";
import { RegView } from "../../PresenterCCViewFactory";
import { PlotStopView, PlotStopViewProps, PlotStopViewType } from "../type/PlotStopView";
const { ccclass, property } = cc._decorator;
@ccclass
@RegView(PlotStopViewType, "prefab/ui/PlotStopView")
export default class PlotStopViewImpl extends CCPureView<PlotStopViewProps> implements PlotStopView {
@property(cc.Node)
banner: cc.Node = DummyNode;
@property({ type: SVButton })
adButton: SVButton = undefined as unknown as SVButton;
svType: GetRewardType = GetRewardType.Ad;
onLoad() {
this.adButton.onResult = (type, ret) => {
if (ret) {
this._props.onAddRes(type);
} else {
this._props.onCancelAdCallback(this.svType);
}
}
}
closeView() {
this.isShowViewBanner(false);
this.close();
}
onEnable() {
this.isShowViewBanner(true);
this.adButton.loadSVConfig();
}
isShowViewBanner = (isShow: boolean) => {
if (isShow) {
let info = SDK.systemInfo.displayInfo;
let aspect = info.windowSize.height / cc.view.getVisibleSize().height;
this.node.getComponent(cc.Widget).updateAlignment();
let _width = this.banner.width * aspect;
let _height = this.banner.height * aspect;
let _left = (info.windowSize.width - _width) * 0.5;
let _top = info.windowSize.height - _height;
let style = {
left: _left,
top: _top,
width: _width,
height: _height,
anchorX: 0.5,
anchorY: 1,
}
SDK.showBannerAd(style, GameConstData.GAME_CONST_BANNER_REFRESH_TIME);
} else {
SDK.hideBannerAd();
}
}
unlockPlotCallback(event) {
this._props.unlockPlotCallbackFunc();
}
getSvBtnType = (): string => {
let ret = "share";
if (this.adButton.svPoint) {
ret = this.adButton.svPoint.type;
}
return ret;
}
}