Files
fc/dev/project/assets/Scripts/mod/pve/adventure/adventure_model.js
T
2026-05-23 22:10:14 +08:00

256 lines
7.5 KiB
JavaScript

// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
// 这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-05-09 14:14:52
// --------------------------------------------------------------------
const BridgeClass = require( "bridge.class" );
var AdventureEvent = require("adventure_event");
var RoleController = require("role_controller")
var AdventureModel = cc.Class({
extends: BridgeClass,
ctor: function () {
},
properties: {
},
initConfig: function () {
this.room_list = []; // 所有房间的
this.base_data = []; // 当前冒险的基础数据
this.buff_data = []; // buff数据
this.holiday_buff_data = []; // 活动buff数据
this.form_list = []; // 当前上阵伙伴信息
this.select_partner_id = 0; // 当前选中的伙伴id
this.red_status = false;
this.backpack_list = [];
this.plist = []; //伙伴死亡情况信息
this.before_room = 0;
this.plunder_record_list = []; //防御布阵掠夺记录
this.is_first_record_red = true;
},
// ==============================--
// desc:获取当前上阵伙伴信息
// @data:
// @return
// ==============================--
updateFormPartner:function(data, partner_id){
this.form_list = data;
this.select_partner_id = partner_id;
// 这里判断一下如果列表为空,则显示一个红点
// this.updateRedStatus(data.length == 0);
gcore.GlobalEvent.fire(AdventureEvent.UpdateAdventureForm);
},
// updateRedStatus:function(status){
// this.red_status = status;
// var is_open = AdventureActivityController.getInstance().isOpenActivity(AdventureActivityConst.Ground_Type.adventure);
// if(is_open == false){
// this.red_status = false;
// }
// },
// 宝箱领取红点
setAdventureBoxStatus:function(data){
this.box_status_list = {};
for(var i in data.list){
this.box_status_list[data.list[i].id] = data.list[i].status;
}
var red_point = false;
for(var i in data.list){
if(data.list[i].status == 1){
red_point = true;
break;
}
}
this.box_redpoint = red_point;
gcore.GlobalEvent.fire(AdventureEvent.UpdateAdventureForm);
var scene_adventure_redpiont = this.getAdventureRedPoint();
},
getAdventureBoxStatus:function(id){
if(this.box_status_list && this.box_status_list[id]){
return this.box_status_list[id];
}
return 0;
},
// 冒险红点
getAdventureRedPoint:function(){
var status = this.red_status || false;
var box_status = this.box_redpoint || false;
return (status || box_status);
},
getFormList:function(){
return this.form_list
},
// ==============================--
// desc:全部伙伴是否都已经死亡
// @return
// ==============================--
allHeroIsDie:function(){
var is_die = true;
for(var i in this.form_list){
if(this.form_list[i].now_hp != 0){
is_die = false;
break;
}
}
return is_die;
},
getSelectPartnerID:function(){
return this.select_partner_id;
},
updateSelectPartnerID:function(id){
this.select_partner_id = id;
gcore.GlobalEvent.fire(AdventureEvent.UpdateAdventureSelectHero);
},
// ==============================--
// desc:冒险的基础信息,对应协议的20600
// @data:
// @return
// ==============================--
setAdventureBaseData:function(data){
this.base_data = data;
gcore.GlobalEvent.fire(AdventureEvent.Update_Room_Base_Info);
},
getAdventureBaseData:function(){
return this.base_data;
},
setBuffData:function(data){
this.buff_data = data.buff_list;
this.holiday_buff_data = data.holiday_buff_list;
gcore.GlobalEvent.fire(AdventureEvent.Update_Buff_Info);
},
getBuffData:function(){
if(this.buff_data && Utils.next(this.buff_data || {}) != null){
return this.buff_data;
}
},
getHolidayBuffData:function( ){
if(this.holiday_buff_data && Utils.next(this.holiday_buff_data || {}) != null){
return this.holiday_buff_data;
}
},
setRoomList:function(data){
if(data == null || data.room_list == null)return;
for(var i in data.room_list){
this.room_list[data.room_list[i].id] = data.room_list[i];
}
gcore.GlobalEvent.fire(AdventureEvent.Update_Room_Info);
},
getRoomList:function(){
if(this.room_list && Utils.next(this.room_list || {}) != null){
return this.room_list;
}
},
updateRoomList:function(data){
for(var i in data.room_list){
var room = this.room_list[data.room_list[i].id];
if(room){
room.status = data.room_list[i].status;
room.lock = data.room_list[i].lock;
room.evt_id = data.room_list[i].evt_id;
}
}
gcore.GlobalEvent.fire(AdventureEvent.Update_Single_Room_Info,data);
},
getRoomInfoByRoomID:function(id){
if(this.room_list && Utils.next(this.room_list || {}) != null){
var data = null;
for(var i in this.room_list){
if(this.room_list[i].id == id){
data = this.room_list[i];
break;
}
}
return data;
}
},
getCurIndex:function(reset_num, config){
var idx = reset_num + 1;
var free_num = 0;
var cost_num = 0;
var vip_lev = RoleController.getInstance().getRoleVo().vip_lev;
while(config[idx]){
if(config[idx].cost == 0){
free_num = free_num + 1;
}else{
if(vip_lev >= config[idx].vip){
cost_num = cost_num + 1;
}
}
idx = idx + 1;
}
return [free_num, cost_num];
},
//返回解锁数量
getMineLockCount:function(){
let count = 0
let role_vo = RoleController.getInstance().getRoleVo()
let config_list = game.configs.AdventureMineData.data_mine_unlock_info
for (var k in config_list) {
let config =config_list[k]
if( Utils.next(config.open_cond) != null ){
let con = config.open_cond[0]
if( con[0] == "lev" ){
if( role_vo && role_vo.lev >= con[1] ){
count = count + 1
}
}
else if (con[0] == "vip" ){
if( role_vo && role_vo.vip_lev >= con[1] ){
count = count + 1
}
}
}
else
{
count = count +1
}
}
return count
},
setMineOccupyCount:function(count){
this.mine_occupy_count = count || 0
},
getMineOccupyCount:function(){
return this.mine_occupy_count
},
// 上一轮通关层数
setLastAdventureNum:function( num ){
this.last_adventure_num = num
},
getLastAdventureNum:function( ){
return this.last_adventure_num
},
});