const DWTool = require('../utils/DWTool')
const GameModule = require('../utils/GameModule')
const WeChat = require('../net/WeChat');
cc.Class({
extends: cc.Component,
properties: {
content: cc.Node,
coinRichText: cc.RichText,
watchVideoRichText: cc.RichText,
shareRichText: cc.RichText,
secretarySprite: cc.Node,
grossIncome: {
get: function() {
if (this._grossIncome) {
this._grossIncome = 0;
}
return this._grossIncome;
},
set: function (value) {
this._grossIncome = value;
this.setCoinRichText(value);
this.setWatchVideoRichText(value);
this.setShareVideoRichText(value);
}
}
},
// LIFE-CYCLE CALLBACKS:
init(grossIncome) {
this.grossIncome = grossIncome;
},
onLoad () {
},
start () {
this.content.scaleX = 0;
this.content.scaleY = 0;
this.content.runAction(cc.scaleTo(0.35, 1, 1).easing(cc.easeBackOut()));
this.secretarySprite.runAction(cc.moveBy(0.3, cc.v2(400, 0)));
},
dismiss() {
let finish = cc.callFunc(() => {
this.node.destroy();
}, this);
let sequence = cc.sequence(cc.scaleTo(0.2, 0, 0).easing(cc.easeBackIn()), finish)
this.content.runAction(sequence);
},
watchVideo() {
this.dismiss();
},
share() {
WeChat.inviteFriend(ShareAction.ADD_FRIEND, () => {
GameModule.userInfo.grossIncome += this.grossIncome * 3;
this.dismiss();
}, () => {
this.dismiss();
});
},
setCoinRichText(coin) {
this.coinRichText.string = ` ${DWTool.coinParse(coin)}`;
},
setWatchVideoRichText(coin) {
this.watchVideoRichText.string = ` ${DWTool.coinParse(coin * 2)}`;
},
setShareVideoRichText(coin) {
this.shareRichText.string = ` ${DWTool.coinParse(coin * 3)}`;
},
// update (dt) {},
});