346 lines
10 KiB
JavaScript
346 lines
10 KiB
JavaScript
|
|
// --------------------------------------------------------------------
|
||
|
|
// 这里填写简要说明(必填),
|
||
|
|
// @author: lwc@syg.com(必填, 创建模块的人员)
|
||
|
|
// @editor: xxx@syg.com(必填, 后续维护以及修改的人员)
|
||
|
|
// @description:
|
||
|
|
// 位面改版 参考afk的 后端 国辉 策划 中建
|
||
|
|
// <br/>Create: 2020-02-05
|
||
|
|
// --------------------------------------------------------------------
|
||
|
|
|
||
|
|
const BridgeClass = require( "bridge.class" );
|
||
|
|
var PlanesafkEvent = require("planesafk_event")
|
||
|
|
var PlanesafkModel = cc.Class({
|
||
|
|
extends: BridgeClass,
|
||
|
|
ctor: function () {
|
||
|
|
this.ctrl = arguments[0];
|
||
|
|
this.initConfig()
|
||
|
|
},
|
||
|
|
|
||
|
|
initConfig:function(){
|
||
|
|
//当前地图id
|
||
|
|
this.map_id = null
|
||
|
|
//地图数据
|
||
|
|
this.map_config = null
|
||
|
|
|
||
|
|
//角色当前位置
|
||
|
|
this.cur_line = null
|
||
|
|
this.cur_index = null
|
||
|
|
|
||
|
|
//是否显示探索完毕
|
||
|
|
this.is_show_search_finish = null
|
||
|
|
|
||
|
|
//登陆红点(一定要赋值 null)
|
||
|
|
this.planesafk_login_redpoint = null
|
||
|
|
},
|
||
|
|
|
||
|
|
setCdTime(time){
|
||
|
|
this.cd_time = time;
|
||
|
|
},
|
||
|
|
|
||
|
|
getCdTime(){
|
||
|
|
return this.cd_time || 0;
|
||
|
|
},
|
||
|
|
|
||
|
|
setIsShowSearchFinish:function(is_show){
|
||
|
|
this.is_show_search_finish = is_show
|
||
|
|
},
|
||
|
|
|
||
|
|
getIsShowSearchFinish:function(){
|
||
|
|
return this.is_show_search_finish
|
||
|
|
},
|
||
|
|
|
||
|
|
// 设置形象id
|
||
|
|
setPlanesRoleLookId:function( look_id ){
|
||
|
|
this.planes_look_id = look_id
|
||
|
|
},
|
||
|
|
|
||
|
|
getPlanesRoleLookId:function( ){
|
||
|
|
return this.planes_look_id
|
||
|
|
},
|
||
|
|
// 设置地图id
|
||
|
|
setMapData:function( data ){
|
||
|
|
if (! data) { return }
|
||
|
|
if (data.map_id) {
|
||
|
|
this.map_id = data.map_id
|
||
|
|
this.map_config = gdata("planes_data","data_customs",this.map_id)//game.configs.PlanesData.data_customs[this.map_id]
|
||
|
|
}
|
||
|
|
},
|
||
|
|
//更新角色位置
|
||
|
|
updateRolePos:function(data){
|
||
|
|
this.cur_line = data.line || 1
|
||
|
|
this.cur_index = data.index || 3
|
||
|
|
},
|
||
|
|
|
||
|
|
getMapID:function( ){
|
||
|
|
return this.map_id || 1
|
||
|
|
},
|
||
|
|
|
||
|
|
//获取地图资源id
|
||
|
|
getMapResID:function( ){
|
||
|
|
if (this.map_config) {
|
||
|
|
return "11"
|
||
|
|
}
|
||
|
|
return "11"
|
||
|
|
},
|
||
|
|
|
||
|
|
//获取角色位置
|
||
|
|
//@ return 当前行 ,当前索引
|
||
|
|
getRolePos:function(){ //GY需修改变量获取方式
|
||
|
|
var cur_line = this.cur_line || 1
|
||
|
|
var cur_index = this.cur_index || 3
|
||
|
|
return [cur_line, cur_index]
|
||
|
|
},
|
||
|
|
|
||
|
|
//是否活动开启中
|
||
|
|
isHolidayOpen:function(){
|
||
|
|
return this.is_holiday_open
|
||
|
|
},
|
||
|
|
|
||
|
|
//设置活动开启中
|
||
|
|
setHolidayOpen:function(is_holiday){
|
||
|
|
if (is_holiday) {
|
||
|
|
this.is_holiday_open = (is_holiday == 1)
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// 设置所有英雄数据
|
||
|
|
setAllPlanesHeroData:function( data ){
|
||
|
|
this.planes_hero_data = data
|
||
|
|
},
|
||
|
|
|
||
|
|
getAllPlanesHeroData:function( ){
|
||
|
|
return this.planes_hero_data
|
||
|
|
},
|
||
|
|
|
||
|
|
getPlanesHireHeroData:function( id ){
|
||
|
|
if (!this.planes_hero_data) { return }
|
||
|
|
for (var k in this.planes_hero_data) {
|
||
|
|
var v = this.planes_hero_data[k]
|
||
|
|
if (v.flag == 1 && v.partner_id == id) {
|
||
|
|
return v
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// 更新我方英雄血量数据
|
||
|
|
updateMyHeroData:function( data_list ){
|
||
|
|
if (! this.planes_hero_data) { return }
|
||
|
|
for (var k in data_list) {
|
||
|
|
for (var m in this.planes_hero_data) {
|
||
|
|
if (this.planes_hero_data[m].flag == data_list[k].flag && this.planes_hero_data[m].partner_id == data_list[k].partner_id) {
|
||
|
|
this.planes_hero_data[m].hp_per = data_list[k].hp_per
|
||
|
|
break
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
gcore.GlobalEvent.fire(PlanesafkEvent.Get_Hero_Live_Event)
|
||
|
|
},
|
||
|
|
|
||
|
|
// 获取英雄的剩余血量
|
||
|
|
getMyPlanesHeroHpPer:function( partner_id, flag ){
|
||
|
|
if (! this.planes_hero_data) { return }
|
||
|
|
var hp_per = 100
|
||
|
|
flag = flag || 0
|
||
|
|
for (var k in this.planes_hero_data) {
|
||
|
|
var v =this.planes_hero_data[k]
|
||
|
|
if (v.flag == flag && v.partner_id == partner_id) {
|
||
|
|
hp_per = v.hp_per || 100
|
||
|
|
break
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return hp_per
|
||
|
|
},
|
||
|
|
|
||
|
|
// 是否有不满血的英雄
|
||
|
|
checkIsHaveHpNotFullHero:function( ){
|
||
|
|
if (! this.planes_hero_data) { return }
|
||
|
|
var is_have = false
|
||
|
|
for (var k in this.planes_hero_data) {
|
||
|
|
var v = this.planes_hero_data[k]
|
||
|
|
if (v.hp_per < 100) {
|
||
|
|
is_have = true
|
||
|
|
break
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return is_have
|
||
|
|
},
|
||
|
|
|
||
|
|
// 是否有死亡的英雄
|
||
|
|
checkIsHaveDieHero:function( ){
|
||
|
|
if (! this.planes_hero_data) { return }
|
||
|
|
var is_have = false
|
||
|
|
for (var k in this.planes_hero_data) {
|
||
|
|
var v = this.planes_hero_data[k]
|
||
|
|
if (v.hp_per <= 0) {
|
||
|
|
is_have = true
|
||
|
|
break
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return is_have
|
||
|
|
},
|
||
|
|
|
||
|
|
// 获取背景图标资源
|
||
|
|
getBgPathByResId:function( res_id ){
|
||
|
|
if (res_id && res_id != "" ) {
|
||
|
|
return cc.js.formatStr("resource/planes/grid_icon/%s.png", res_id)
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
getPlanesAfkRedStatus:function( ){
|
||
|
|
var red_status = this.getOrderactionRedpoint() || this.planesafk_login_redpoint
|
||
|
|
return red_status
|
||
|
|
},
|
||
|
|
|
||
|
|
checkPlanesafkRedPoint:function(){
|
||
|
|
gcore.GlobalEvent.fire(PlanesafkEvent.Update_Planes_Red_Event)
|
||
|
|
},
|
||
|
|
|
||
|
|
setPlanesafkLoginRedpointFalse:function(){
|
||
|
|
this.planesafk_login_redpoint = false
|
||
|
|
this.checkPlanesafkRedPoint()
|
||
|
|
},
|
||
|
|
|
||
|
|
checkPlaneafkCanExploreRedPoint:function(data){
|
||
|
|
if (data && this.planesafk_login_redpoint == null) {
|
||
|
|
this.planesafk_login_redpoint = false
|
||
|
|
var planes_max_floor = 3
|
||
|
|
var config = gdata("planes_data","data_const","planes_max_floor")//game.configs.PlanesData.data_const.planes_max_floor
|
||
|
|
if (config) {
|
||
|
|
planes_max_floor = config.val
|
||
|
|
}
|
||
|
|
if (data.floor < planes_max_floor) {
|
||
|
|
this.planesafk_login_redpoint = true
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
if (data.is_can_reward == 1 && data.is_reward == 1) {
|
||
|
|
// this.planesafk_login_redpoint = false
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
this.planesafk_login_redpoint = true
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
this.checkPlanesafkRedPoint()
|
||
|
|
},
|
||
|
|
|
||
|
|
//--------------------------------战令-----------------------------------
|
||
|
|
setOrderactionData:function(data){
|
||
|
|
this.orderaction_data = data
|
||
|
|
if (data) {
|
||
|
|
this.setGiftStatus(data.rmb_status)
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
//获取当前周期
|
||
|
|
getCurPeriod:function(){
|
||
|
|
if (this.orderaction_data && this.orderaction_data.period) {
|
||
|
|
return this.orderaction_data.period
|
||
|
|
}
|
||
|
|
return 1
|
||
|
|
},
|
||
|
|
|
||
|
|
//获取特权状态
|
||
|
|
getGiftStatus:function(){
|
||
|
|
if (this.rmb_status) {
|
||
|
|
return this.rmb_status
|
||
|
|
}
|
||
|
|
return 0
|
||
|
|
},
|
||
|
|
|
||
|
|
getLevShowData:function(lev){
|
||
|
|
if (this.orderaction_data && this.orderaction_data.list && this.orderaction_data.list[lev]) {
|
||
|
|
return this.orderaction_data.list[lev]
|
||
|
|
}
|
||
|
|
return null
|
||
|
|
},
|
||
|
|
|
||
|
|
//获取胜场
|
||
|
|
getWinCounts:function(){
|
||
|
|
if (this.orderaction_data && this.orderaction_data.win_count) {
|
||
|
|
return this.orderaction_data.win_count
|
||
|
|
}
|
||
|
|
return 0
|
||
|
|
},
|
||
|
|
|
||
|
|
getCurDay:function(){
|
||
|
|
if (this.orderaction_data && this.orderaction_data.cur_day) {
|
||
|
|
return this.orderaction_data.cur_day
|
||
|
|
}
|
||
|
|
return 1
|
||
|
|
},
|
||
|
|
|
||
|
|
setOrderactionRedStatus:function(status){
|
||
|
|
this.orderaction_first_red_status = status
|
||
|
|
},
|
||
|
|
|
||
|
|
//设置特权状态
|
||
|
|
setGiftStatus:function(status){
|
||
|
|
this.rmb_status = status
|
||
|
|
},
|
||
|
|
|
||
|
|
//获取战令红点
|
||
|
|
getOrderactionRedpoint:function(){
|
||
|
|
if (this.orderaction_first_red_status == 1) {
|
||
|
|
return true
|
||
|
|
}
|
||
|
|
|
||
|
|
if (! this.orderaction_data) { return false }
|
||
|
|
|
||
|
|
var lev_reward_list = game.configs.arena_elite_war_order_data.data_lev_reward_list//gdata("arena_elite_war_order_data","data_lev_reward_list")//
|
||
|
|
if (lev_reward_list && lev_reward_list[this.orderaction_data.period]) {
|
||
|
|
for (var i in lev_reward_list[this.orderaction_data.period]) { //this.orderaction_data.list
|
||
|
|
var v = lev_reward_list[this.orderaction_data.period][i]
|
||
|
|
var status = 0
|
||
|
|
var rmb_status = 0
|
||
|
|
var lev_list = this.getLevShowData(v.lev)
|
||
|
|
if (lev_list ){
|
||
|
|
status = lev_list.award_status
|
||
|
|
rmb_status = lev_list.rmb_award_status
|
||
|
|
}
|
||
|
|
if (v.lev <= this.orderaction_data.lev) {
|
||
|
|
if (status == 0) { //可领
|
||
|
|
return true
|
||
|
|
}
|
||
|
|
else if ( rmb_status == 0 && this.orderaction_data.rmb_status == 1) { //可领
|
||
|
|
return true
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return false
|
||
|
|
},
|
||
|
|
|
||
|
|
//获取战令入口是否显示
|
||
|
|
getOrderIsShow:function(){
|
||
|
|
var configlv = gdata("PlanesWarOrderData","data_constant","limit_lev")//game.configs.PlanesWarOrderData.data_constant.limit_lev
|
||
|
|
var configday = gdata("PlanesWarOrderData","data_constant","open_srv_day")//game.configs.PlanesWarOrderData.data_constant.open_srv_day
|
||
|
|
var RoleController = require("role_controller")
|
||
|
|
var open_srv_day = RoleController.getInstance().getModel().getOpenSrvDay()
|
||
|
|
var rolevo = RoleController.getInstance().getModel().getRoleVo()
|
||
|
|
// 是否开启planes_war_order_data:
|
||
|
|
if (configday && configlv && rolevo && (open_srv_day < configday.val || rolevo.lev < configlv.val)) {
|
||
|
|
return false
|
||
|
|
}
|
||
|
|
return true
|
||
|
|
},
|
||
|
|
deleteMe:function(){
|
||
|
|
this.DeleteMe();
|
||
|
|
},
|
||
|
|
|
||
|
|
|
||
|
|
//---------------------------------}-------------------------------------
|
||
|
|
|
||
|
|
DeleteMe: function () {
|
||
|
|
if (this.model != null) {
|
||
|
|
this.model.deleteMe();
|
||
|
|
this.model = null;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
module.exports = PlanesafkModel;
|