|
@@ -4,17 +4,6 @@ import NotifierCenter from "../../../src/webtcp/NotifierCenter";
|
|
import common from "../../../src/common/common";
|
|
import common from "../../../src/common/common";
|
|
import AudioManager from "../../../src/audioUitls/AudioManager";
|
|
import AudioManager from "../../../src/audioUitls/AudioManager";
|
|
|
|
|
|
-const EStarSkineMap = new Map([
|
|
|
|
- [1, '1-Star'],
|
|
|
|
- [2, '2-star'],
|
|
|
|
- [3, '3-star']
|
|
|
|
-])
|
|
|
|
-
|
|
|
|
-enum ESuccessAni {
|
|
|
|
- 'success1' = 'success1',
|
|
|
|
- 'success2' = 'success2'
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
export interface PropsFinish {
|
|
export interface PropsFinish {
|
|
star: number, // 获得的星星数目
|
|
star: number, // 获得的星星数目
|
|
audios?: cc.AudioClip[], // 音频路径
|
|
audios?: cc.AudioClip[], // 音频路径
|
|
@@ -24,30 +13,196 @@ const { ccclass, property } = cc._decorator;
|
|
@ccclass
|
|
@ccclass
|
|
export default class LuojigouFinish extends cc.Component {
|
|
export default class LuojigouFinish extends cc.Component {
|
|
|
|
|
|
- @property({ tooltip: '弹窗中的spine', type: sp.Skeleton })
|
|
|
|
- SuccessSpine: sp.Skeleton = null;
|
|
|
|
|
|
+ @property({ tooltip: '节点', type: cc.Node })
|
|
|
|
+ nodeSuc: cc.Node = null;
|
|
|
|
+
|
|
|
|
+ @property({ tooltip: '节点', type: cc.Node })
|
|
|
|
+ nodeCoin: cc.Node = null;
|
|
|
|
+
|
|
|
|
+ @property({ tooltip: '节点', type: cc.Node })
|
|
|
|
+ nodeLimit: cc.Node = null;
|
|
|
|
+
|
|
|
|
+ dataQues = {
|
|
|
|
+ nodeSuc: {
|
|
|
|
+ spine: {
|
|
|
|
+ scale: 0,
|
|
|
|
+ },
|
|
|
|
+ score: {
|
|
|
|
+ opacity: 0,
|
|
|
|
+ },
|
|
|
|
+ coin: {
|
|
|
|
+ scale: 0,
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ nodeCoin: {
|
|
|
|
+ sign: {
|
|
|
|
+ scale: 0,
|
|
|
|
+ },
|
|
|
|
+ coin: {
|
|
|
|
+ position: cc.v3(0, 0, 0),
|
|
|
|
+ childScale: 0,
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ spineData: { idle: 'j', play_1: 'one', idle_1: 'one-j', play_2: 'two', idle_2: 'two-j', play_3: 'three', idle_3: 'three-j', },
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ protected start(): void {
|
|
|
|
+ this.initData();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ initData() {
|
|
|
|
+ this.dataQues.nodeSuc.spine.scale = this.nodeSuc.getChildByName('spine').scale;
|
|
|
|
+ this.dataQues.nodeSuc.score.opacity = this.nodeSuc.getChildByName('score').opacity;
|
|
|
|
+ this.dataQues.nodeSuc.coin.scale = this.nodeSuc.getChildByName('coin').scale;
|
|
|
|
+ this.dataQues.nodeCoin.coin.position = this.nodeCoin.getChildByName('coin').position;
|
|
|
|
+ this.dataQues.nodeCoin.coin.childScale = this.nodeCoin.getChildByName('coin').getChildByName('icon0').scale;
|
|
|
|
+ this.dataQues.nodeCoin.sign.scale = this.nodeCoin.getChildByName('sign').scale;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ updateUI() {
|
|
|
|
+ this.node.active = true;
|
|
|
|
+ this.nodeSuc.active = true;
|
|
|
|
+ this.nodeSuc.getChildByName('spine').active = true;
|
|
|
|
+ this.nodeSuc.getChildByName('spine').scale = this.dataQues.nodeSuc.spine.scale;
|
|
|
|
+ this.nodeSuc.getChildByName('score').active = false;
|
|
|
|
+ this.nodeSuc.getChildByName('score').opacity = this.dataQues.nodeSuc.score.opacity;
|
|
|
|
+
|
|
|
|
+ this.nodeCoin.active = true;
|
|
|
|
+ this.nodeCoin.getChildByName('coin').active = false;
|
|
|
|
+ this.nodeCoin.getChildByName('coin').position = this.dataQues.nodeCoin.coin.position;
|
|
|
|
+ this.nodeCoin.getChildByName('sign').scale = this.dataQues.nodeCoin.sign.scale;
|
|
|
|
+ let arrCoinCoin = Tools.getArrByNode(this.nodeCoin.getChildByName('coin'), 'icon');
|
|
|
|
+ arrCoinCoin.forEach((item) => {
|
|
|
|
+ item.scale = this.dataQues.nodeSuc.coin.scale;
|
|
|
|
+ item.position = cc.v3(0, 0, 0);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ initGameFinish() {
|
|
|
|
+ this.node.active = true;
|
|
|
|
+ this.nodeSuc.active = false;
|
|
|
|
+ this.nodeLimit.active = false;
|
|
|
|
+ this.nodeCoin.active = true;
|
|
|
|
+ let itemScore = this.nodeCoin.getChildByName('score');
|
|
|
|
+ itemScore.getComponent(cc.Label).string = String(common.coinBase.data.userWisdomCoin);
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* @description 设置成功弹窗的动画
|
|
* @description 设置成功弹窗的动画
|
|
* @description 星星数
|
|
* @description 星星数
|
|
*/
|
|
*/
|
|
setAnimation(props: PropsFinish): void {
|
|
setAnimation(props: PropsFinish): void {
|
|
- common.httpReportdata();
|
|
|
|
- common.setGameToLocal();
|
|
|
|
- this.node.active = true;
|
|
|
|
- const spine = this.SuccessSpine;
|
|
|
|
- spine.setSkin(EStarSkineMap.get(props.star));
|
|
|
|
- spine.timeScale = 0.8;
|
|
|
|
- spine.setAnimation(0, ESuccessAni.success1, false);
|
|
|
|
- spine.addAnimation(0, ESuccessAni.success2, true);
|
|
|
|
- AudioManager.getInstance().playEffect('audio/star_' + props.star);
|
|
|
|
|
|
+ let coinData = common.coinBase.data;
|
|
|
|
+ let coinCur = coinData.userWisdomCoin;
|
|
|
|
+ let coinElse = coinData.remainderWisdomCoin;
|
|
|
|
+ let coinAdd = coinElse > props.star ? props.star : coinElse;
|
|
|
|
+ coinData.userWisdomCoin += coinAdd;
|
|
|
|
+ coinData.remainderWisdomCoin -= coinAdd;
|
|
|
|
+ common.httpReportCoin(coinAdd);// 数据上报-智慧币
|
|
|
|
+ common.httpReportdata();// 数据上报
|
|
|
|
+ common.setGameToLocal();// 修改本地数据
|
|
|
|
+
|
|
|
|
+ this.updateUI();
|
|
|
|
+ let sucSpine = this.nodeSuc.getChildByName('spine');
|
|
|
|
+ let sucCoin = this.nodeSuc.getChildByName('coin');
|
|
|
|
+ let coinCoin = this.nodeCoin.getChildByName('coin');
|
|
|
|
+ let coinSign = this.nodeCoin.getChildByName('sign');
|
|
|
|
+ let arrCoinCoin = Tools.getArrByNode(coinCoin, 'icon');
|
|
|
|
+ arrCoinCoin.forEach((item, index)=>{
|
|
|
|
+ item.active = index < props.star;
|
|
|
|
+ });
|
|
|
|
|
|
- if (props.audios && props.audios.length > 0) {
|
|
|
|
- Tools.playEffectArr(props.audios, this.closeLJGCard.bind(this));
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- this.scheduleOnce(this.closeLJGCard.bind(this), 4);
|
|
|
|
- }
|
|
|
|
|
|
+ let timeScale = 1.2;
|
|
|
|
+ let sucSke = sucSpine.getComponent(sp.Skeleton);
|
|
|
|
+ Tools.playAnimation(sucSke, this.dataQues.spineData['play_' + props.star], false, ()=>{
|
|
|
|
+ Tools.playAnimation(sucSke, this.dataQues.spineData['idle_' + props.star], true, null, timeScale);
|
|
|
|
+ // 分数变化
|
|
|
|
+ let funScore = () => {
|
|
|
|
+ if (coinAdd <= 0) {
|
|
|
|
+ if (!this.nodeLimit.active) {
|
|
|
|
+ this.nodeLimit.active = true;
|
|
|
|
+ this.nodeLimit.opacity = 0;
|
|
|
|
+ cc.Tween.stopAllByTarget(this.nodeLimit);
|
|
|
|
+ cc.tween(this.nodeLimit).to(0.25, { opacity: 255 }).delay(1.0).to(0.25, { opacity: 0 }).call(() => {
|
|
|
|
+ this.nodeLimit.active = false;
|
|
|
|
+ }).start();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ coinCur++;
|
|
|
|
+ coinAdd--;
|
|
|
|
+ let itemScore = this.nodeCoin.getChildByName('score');
|
|
|
|
+ itemScore.getComponent(cc.Label).string = String(coinCur);
|
|
|
|
+ AudioManager.getInstance().playEffect('audio/good_touch');
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ // 金币移动
|
|
|
|
+ let funcMove = (star) => {
|
|
|
|
+ let curId = star - 1;
|
|
|
|
+ if (curId >= 0) {
|
|
|
|
+ let item = arrCoinCoin[curId];
|
|
|
|
+ let posGoal = Tools.getLocalPos(this.nodeCoin.getChildByName('sign'), item.parent);
|
|
|
|
+ let opt = {
|
|
|
|
+ p1: cc.v2(item.x, item.y),
|
|
|
|
+ p2: cc.v2(posGoal.x, posGoal.y - 40),
|
|
|
|
+ pTo: cc.v2(posGoal.x, item.y),
|
|
|
|
+ };
|
|
|
|
+ let time = Tools.getMoveTime(opt.p1, opt.p2, 1, 1250);
|
|
|
|
+ cc.Tween.stopAllByTarget(item);
|
|
|
|
+ let tw = cc.tween;
|
|
|
|
+ tw(item)
|
|
|
|
+ .parallel(
|
|
|
|
+ tw().to(time, { scale: this.dataQues.nodeCoin.coin.childScale }),
|
|
|
|
+ tw().bezierTo(time, opt.p1, opt.pTo, opt.p2).call(()=>{
|
|
|
|
+ funScore();
|
|
|
|
+ cc.Tween.stopAllByTarget(coinSign);
|
|
|
|
+ coinSign.scale = 1.0;
|
|
|
|
+ cc.tween(coinSign).to(0.15, {scale: 1.2}).to(0.075, {scale: 1.0}).start();
|
|
|
|
+ }),
|
|
|
|
+ tw().delay(time * 0.2).call(funcMove.bind(this, curId)),
|
|
|
|
+ )
|
|
|
|
+ .call(()=>{
|
|
|
|
+ item.active = false;
|
|
|
|
+ })
|
|
|
|
+ .start();
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ if (props.audios && props.audios.length > 0) {
|
|
|
|
+ Tools.playEffectArr(props.audios, this.closeLJGCard.bind(this));
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ this.scheduleOnce(this.closeLJGCard.bind(this), 4);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ cc.Tween.stopAllByTarget(sucSpine);
|
|
|
|
+ cc.tween(sucSpine).to(0.2, { scale: 0 }).call(() => {
|
|
|
|
+ sucSpine.active = false;
|
|
|
|
+ // 出现加分
|
|
|
|
+ let score = this.nodeSuc.getChildByName('score');
|
|
|
|
+ score.getChildByName('label').getComponent(cc.Label).string = '+' + props.star;
|
|
|
|
+ score.active = true;
|
|
|
|
+ score.opacity = 0;
|
|
|
|
+ cc.Tween.stopAllByTarget(score);
|
|
|
|
+ cc.tween(score).to(0.3, { opacity: 255 }).delay(0.6).to(0.3, { opacity: 255 }).call(() => {
|
|
|
|
+ score.active = false;
|
|
|
|
+ }).start();
|
|
|
|
+ // 出现金币
|
|
|
|
+ coinCoin.active = true;
|
|
|
|
+ coinCoin.opacity = 0;
|
|
|
|
+ coinCoin.scale = 0;
|
|
|
|
+ coinCoin.position = Tools.getLocalPos(sucCoin, coinCoin.parent);
|
|
|
|
+ cc.Tween.stopAllByTarget(coinCoin);
|
|
|
|
+ cc.tween(coinCoin).delay(0.2).parallel(
|
|
|
|
+ cc.tween().to(0.15, { scale: 1.3 }).to(0.075, { scale: 1.0 }),
|
|
|
|
+ cc.tween().to(0.3, { opacity: 255 }),
|
|
|
|
+ ).delay(0.7).call(() => {
|
|
|
|
+ funcMove(props.star);
|
|
|
|
+ }).start();
|
|
|
|
+ }).start();
|
|
|
|
+ }, timeScale);
|
|
|
|
+ AudioManager.getInstance().playEffect('audio/star_' + props.star);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|