|
|
@@ -1,4 +1,6 @@
|
|
|
+import { PanelType } from "../../../../mk/system/UISystem";
|
|
|
import { AdFun } from "../../../data/AdData";
|
|
|
+import { GameProp } from "../../../data/GameData";
|
|
|
import TurnableItem from "./TurnableItem";
|
|
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
@@ -28,36 +30,47 @@ export default class Turnable extends cc.Component {
|
|
|
private initData() {
|
|
|
for (let i = 0; i < this.node_items.length; i++) {
|
|
|
let sc = this.node_items[i].getComponent(TurnableItem);
|
|
|
- sc.initData(i + "");
|
|
|
+ sc.initData((i % 3 + 1) + "");
|
|
|
}
|
|
|
this.updateLeftTimes();
|
|
|
}
|
|
|
|
|
|
/** 点击抽奖 */
|
|
|
clickDraw() {
|
|
|
- if (gData.turnable.leftTimes > 0 && !this.isPlaying) {
|
|
|
- this.isPlaying = true;
|
|
|
+ if (gData.turnable.leftTimes > 0) {
|
|
|
gData.adData.watchVideo(AdFun.turntable);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private draw() {
|
|
|
- gData.turnable.leftTimes--;
|
|
|
- this.node_turn.rotation = 1800;
|
|
|
+ private play() {
|
|
|
+ this.isPlaying = true;
|
|
|
+ this.node_turn.angle = 1800;
|
|
|
let index = 2;
|
|
|
let tar = index * 60;
|
|
|
cc.tween(this.node_turn)
|
|
|
- .to(3, { rotation: tar }, { easing: 'expoInOut' })
|
|
|
- .call(() => {
|
|
|
- this.updateLeftTimes();
|
|
|
- }, this).start();
|
|
|
+ .to(3, { angle: tar }, { easing: 'expoInOut' })
|
|
|
+ .call(this.playOver, this).start();
|
|
|
}
|
|
|
|
|
|
- updateLeftTimes(){
|
|
|
+ private playOver(){
|
|
|
+ this.isPlaying = false;
|
|
|
+ this.updateLeftTimes();
|
|
|
+ mk.ui.openPanel("reward",PanelType.module);
|
|
|
+ }
|
|
|
+
|
|
|
+ updateLeftTimes() {
|
|
|
this.lbl_left.string = `剩余:<color=#FFED99>${gData.turnable.leftTimes}</color>次`;
|
|
|
}
|
|
|
|
|
|
update() {
|
|
|
-
|
|
|
+ if (gData.turnable.adData) {
|
|
|
+ this.play();
|
|
|
+ gData.reward.data = gData.turnable.adData;
|
|
|
+ gData.turnable.adData = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ onDestroy() {
|
|
|
+
|
|
|
}
|
|
|
}
|