"use strict"; cc._RF.push(module, '5689aAZEFxIGLkiRSFnlOVY', 'act.encounter.mod'); // Scripts/mod/acts/encounter/act.encounter.mod.js "use strict"; /******************************************************************************* * * 活动:銀河奇遇 * * ******************************************************************************/ var ActBase = require("act.base"); var Encounter = cc.Class({ "extends": ActBase, // 初始化配置数据 initConfig: function initConfig() { // 视图附着 nx.plugin.add(this, ["view"]); this.vattach("Acts"); }, // 注册协议接受事件 registerProtocals: function registerProtocals() { this.RegisterProtocal(31000, this.handle31000.bind(this)); this.RegisterProtocal(31001, this.handle31001.bind(this)); this.RegisterProtocal(31002, this.handle31002.bind(this)); }, // 从服务器初始化数据 reqBaseFromServer: function reqBaseFromServer(_cb) { var _this = this; var cfgs = ["fake_battle_data"]; this.loadConfigs(cfgs, function (_ret, _data) { _this.reqBaseData(_cb); }); }, // 请求剧情信息 reqBaseData: function reqBaseData(_cb) { this.send31000(_cb); }, // ============================================================ // 銀河奇遇 // ============================================================ //任務完成情況 send31000: function send31000(_cb) { this.SendProtocal(31000, {}, _cb); }, handle31000: function handle31000(_data) { if (!this.isGoodData(_data)) { this.vset("EncounterData", {}); return; } this.vset("EncounterData", _data); // 提示刷新 this.freshTips(_data); }, //挑戰 send31001: function send31001(params, _cb) { this.SendProtocal(31001, { id: params.id, formation_type: params.formation_type, pos_info: params.pos_info }, _cb); }, handle31001: function handle31001(_data) { if (!this.isGoodData(_data)) { return; } }, //领取 send31002: function send31002(id, _cb) { this.SendProtocal(31002, { id: id }, _cb); }, handle31002: function handle31002(_data) { nx.bridge.acts.reqActsRewards(); if (!this.isGoodData(_data)) { return; } }, // ============================================================ // 活动红点提示 // ============================================================ // 活动用到的提示KEY tipKeys: function tipKeys() { return ["award1", "award2", "award3", "award4", "award5", "award6"]; }, // 红点提示更新 freshTips: function freshTips(_data) { //是否有未挑戰的 var ids = _data.ids; var awards = _data.reward_ids; if (ids.length < 6 || awards.length < 6) { this.openTip("reward", true); } else { this.openTip("reward", false); } //是否有獎勵領取 for (var i = 0; i < 6; i++) { var passid = ids[i]; var awardid = awards[i]; if (passid && !awardid) { //已通過,未領取 this.openTip(this.tipKeys()[i], true); } else { this.openTip(this.tipKeys()[i], false); } } }, // ============================================================ // 引导 // ============================================================ // 触发引导 fireGuide: function fireGuide() { var self = this; var done = function done() { var campId = self.data.camp_id; nx.bridge.acts.reqDoneGuide(campId); }; nx.bridge.plot.fireForce(30001, function (_done) { if (_done) { done(); } }); }, // 首次触发 tryGuide: function tryGuide() { var _this2 = this; var campId = this.data.camp_id; if (!nx.dt.numPositive(campId, false)) { return; } nx.bridge.acts.needGuide(campId, function (_ret, _params) { if (_ret && _params && _params.code == 1) { _this2.fireGuide(); } }); } }); // 模块导出 module.exports = Encounter; cc._RF.pop();