123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- const HomeApi = require("../net/HomeApi");
- const GameNotificationKey = require("../utils/GameEnum").GameNotificationKey;
- const GameModule = require("../utils/GameModule");
- cc.Class({
- extends: cc.Component,
- properties: {
- roomLevel: 0
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {
- this.isGetting = false;
- this.isPlaying = false;
- let self = this;
- this.node.on(cc.Node.EventType.TOUCH_END, () => {
- self.getAward();
- });
- GameModule.homeGuide.on('Fire_state26', this.getAward, this);
- },
- start () {
- },
- init(roomId, roomLevel, pickupCallback) {
- this.roomId = roomId;
- this.roomLevel = roomLevel;
- this.pickupCallback = pickupCallback;
- },
- getAward() {
- if (this.isGetting || this.isPlaying) { return }
- this.isGetting = true;
- HomeApi.getRoomAward(this.roomId, this.roomLevel, (responseData) => {
- this.isGetting = false;
- GameModule.audioMng.playGetAward();
- this.pickupCallback(responseData.awardCount);
- GameEvent.fire(GameNotificationKey.GetRoomAward,responseData);
- let roomName = Global.BuildingManager.getRoomName(this.roomId);
- GameEvent.fire(GameNotificationKey.GameShowAdditionTips,roomName,1);
- let objct = {'cdTime': -6 * 1000, 'infoDesc': roomName + ' 提升2倍的金币产出', 'icon': 900001};
- Global._fixInformations.push(objct);
- GameEvent.fire(GameNotificationKey.GameUpdateMessageList, 1, false);
- },(errCode, errMsg) => {
- this.isGetting = false;
- Global.commonAlert.showCommonErrorAlert("领取奖励失败");
- });
- if (!GameModule.homeGuide.getComponent('HomeGuide').isPassGuideState('state27')) {
- GameModule.homeGuide.getComponent('HomeGuide').handleGuideStateNext('state26', 'state27');
- }
- },
- showAnimation() {
- if (this.isPlaying) { return; }
- this.node.stopAllActions();
- this.node.active = true;
- this.isPlaying = true;
- let jumpHeight = 100;
- let duration = 0.3;
- let animationArray = [];
- let moveAction1 = cc.moveBy(duration, 0, jumpHeight).easing(cc.easeCubicActionOut());
- let moveAction2 = cc.moveBy(duration, 0, -110).easing(cc.easeCubicActionIn());
- animationArray.push(moveAction1);
- animationArray.push(moveAction2);
- while(jumpHeight > 0.1) {
- jumpHeight = jumpHeight - (jumpHeight / 3);
- duration = duration - (duration / 3);
- let upAction = cc.moveBy(duration, 0, jumpHeight).easing(cc.easeCubicActionOut());
- let downAction = cc.moveBy(duration, 0, -jumpHeight).easing(cc.easeCubicActionIn());
- animationArray.push(upAction);
- animationArray.push(downAction);
- }
- let callback = cc.callFunc(() => {
- this.isPlaying = false;
- GameModule.homeGuide.getComponent('HomeGuide').handleGuideStateNext('state24', 'state26');
- });
- animationArray.push(callback);
- this.node.runAction(cc.sequence(animationArray));
- },
- updateAnimation() {
- if (this.isPlaying) { return; }
- this.node.active = true;
- this.node.stopAllActions();
- this.isPlaying = true;
- let jumpHeight = 100;
- let duration = 0.3;
- let animationArray = [];
- let moveAction1 = cc.moveBy(duration, 0, jumpHeight).easing(cc.easeCubicActionOut());
- let moveAction2 = cc.moveBy(duration, 0, -100).easing(cc.easeCubicActionIn());
- animationArray.push(moveAction1);
- animationArray.push(moveAction2);
- while(jumpHeight > 0.1) {
- jumpHeight = jumpHeight - (jumpHeight / 3);
- duration = duration - (duration / 3);
- let upAction = cc.moveBy(duration, 0, jumpHeight).easing(cc.easeCubicActionOut());
- let downAction = cc.moveBy(duration, 0, -jumpHeight).easing(cc.easeCubicActionIn());
- animationArray.push(upAction);
- animationArray.push(downAction);
- }
- let callback = cc.callFunc(() => {
- this.isPlaying = false;
- });
- animationArray.push(callback);
- this.node.runAction(cc.sequence(animationArray));
- },
- // update (dt) {},
- });
|