197 lines
5.9 KiB
JavaScript
197 lines
5.9 KiB
JavaScript
const ItemBase = require("nx.fx.sv.expand.item");
|
|
const AdventureEVT = require("adventure_event");
|
|
const ADVCT = require("adventure_controller");
|
|
const MapColl = require("cmp.adventure.map.coll");
|
|
|
|
cc.Class({
|
|
extends: ItemBase,
|
|
|
|
properties: {
|
|
land:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
shadow:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
builder:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
cloud:{//阴影
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
cloudColl:{
|
|
default:null,
|
|
type:MapColl
|
|
},
|
|
prePath:{//预设路径
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
landSp:{
|
|
default:[],
|
|
type:[cc.SpriteFrame]
|
|
},
|
|
shadowSp:{
|
|
default:[],
|
|
type:[cc.SpriteFrame]
|
|
}
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
onLoad(){
|
|
this.ctrl = ADVCT.getInstance();
|
|
},
|
|
|
|
//设置相对坐标
|
|
setPos(index){
|
|
this.index = index;
|
|
this.data = this.ctrl.getRoomDataByIndex(index);
|
|
if(nx.dt.objEmpty(this.data))return;
|
|
this.poses = this.data.room_id[0];
|
|
|
|
this.setUI();//更新ui
|
|
},
|
|
|
|
setUI(){
|
|
//设置图片
|
|
let idx = Math.floor(Math.random()*4);
|
|
let lsp = nx.gui.getComponent(this.land,"",cc.Sprite);
|
|
lsp.spriteFrame = this.landSp[idx];
|
|
let ssp = nx.gui.getComponent(this.shadow,"",cc.Sprite);
|
|
ssp.spriteFrame = this.shadowSp[idx];
|
|
|
|
let num_arr = [1,2,3];
|
|
let arr_id = Math.floor(Math.random()*3);
|
|
nx.gui.setSpriteFrame(this.cloud,"",cc.js.formatStr("prefab/pve/starlost/ui/check_%s",num_arr[arr_id]));
|
|
|
|
if(this.ctrl.getPlayModel() == 1){
|
|
this.evt_info = game.configs.adventure_endless_data.data_adventure_event[this.data.evt_id];
|
|
}else{
|
|
this.evt_info = game.configs.adventure_weekly_data.data_adventure_event[this.data.evt_id];
|
|
}
|
|
if(this.data.evt_id > 0){//有事件
|
|
this.builder.active = true;
|
|
//设置建筑图片
|
|
if(this.evt_info.evt_type != 8){
|
|
nx.gui.setSpriteFrame(this.builder,"",cc.js.formatStr("prefab/pve/starlost/icons/%s",this.data.res_id));
|
|
}else{//陷阱隱藏
|
|
this.builder.active = false;
|
|
}
|
|
}else{
|
|
this.builder.active = false;
|
|
}
|
|
|
|
//设置解锁状态
|
|
if(this.data.lock == 0){
|
|
this.delCloud();
|
|
}else{
|
|
this.cloud.active = true;
|
|
//刷新碰撞
|
|
this.cloudColl.upCollision(this.index);
|
|
}
|
|
|
|
if(this.data.status == 3){
|
|
this.shadow.active = false;
|
|
this.builder.active = false;
|
|
}else if(this.data.status == 2){
|
|
this.shadow.active = true;
|
|
}
|
|
},
|
|
|
|
updateInfo(index){
|
|
if(index != null){
|
|
this.index = index;
|
|
}
|
|
//需要刷新data
|
|
let new_data = this.ctrl.getRoomDataByIndex(this.index);
|
|
if(!new_data)return;
|
|
this.data = new_data;
|
|
this.poses = this.data.room_id[0];
|
|
if(this.ctrl.getPlayModel() == 1){
|
|
this.evt_info = game.configs.adventure_endless_data.data_adventure_event[this.data.evt_id];
|
|
}else{
|
|
this.evt_info = game.configs.adventure_weekly_data.data_adventure_event[this.data.evt_id];
|
|
}
|
|
if(this.data.evt_id > 0){//有事件
|
|
this.builder.active = true;
|
|
//设置建筑图片
|
|
if(this.evt_info.evt_type != 8){
|
|
nx.gui.setSpriteFrame(this.builder,"",cc.js.formatStr("prefab/pve/starlost/icons/%s",this.data.res_id));
|
|
}else{//陷阱隱藏
|
|
this.builder.active = false;
|
|
}
|
|
}else{
|
|
this.builder.active = false;
|
|
}
|
|
|
|
//刷新碰撞
|
|
if(this.data.lock == 0){
|
|
this.delCloud();
|
|
}else{
|
|
this.cloud.active = true;
|
|
//刷新碰撞
|
|
this.cloudColl.upCollision(this.index);
|
|
}
|
|
|
|
if(this.data.status == 3){
|
|
this.shadow.active = false;
|
|
this.builder.active = false;
|
|
}else if(this.data.status == 2){
|
|
this.shadow.active = true;
|
|
}
|
|
},
|
|
|
|
checkEvtInPath(){
|
|
if(this.ctrl.getDeadStatus()){
|
|
nx.bridge.createPanel("WndAdventureRelive",{});
|
|
return nx.tbox("AdvenDead");//已死亡
|
|
}
|
|
|
|
//0 迷霧 1 空地圖快 2 事件地圖塊 3 探索完成
|
|
if(this.data){
|
|
if(this.data.status == 2){//探索中
|
|
let room_ids = [];
|
|
room_ids.push(this.poses);
|
|
let model_type = this.ctrl.getPlayModel();
|
|
if(!this.evt_info)return;
|
|
//判斷障礙物
|
|
if(this.evt_info.evt_type == 11){
|
|
let item = this.ctrl.getItemBybid(99989);
|
|
if(!item || item.num <= 0){
|
|
return nx.tbox("AdvenCzNEnough");
|
|
}
|
|
}
|
|
let is_req_data = (this.evt_info.evt_type == 8 || this.evt_info.evt_type == 9 ||this.evt_info.evt_type == 11 || this.evt_info.evt_type == 12)?1:0;
|
|
this.ctrl.setCurEvtType(this.evt_info.evt_type);//操作事件前需要設置事件狀態
|
|
this.ctrl.send29520(room_ids,is_req_data,[],model_type);
|
|
}else if(this.data.status == 3){//探索完成
|
|
this.builder.active = false;
|
|
}else{
|
|
this.builder.active = false;
|
|
}
|
|
}
|
|
},
|
|
|
|
getPoses(){
|
|
return this.poses;
|
|
},
|
|
|
|
lightMap(){
|
|
this.prePath.active = true;
|
|
},
|
|
|
|
nightMap(){
|
|
this.prePath.active = false;
|
|
},
|
|
|
|
delCloud(){//去除阴影
|
|
this.cloud.active = false;
|
|
},
|
|
|
|
// update (dt) {},
|
|
});
|