195 lines
5.6 KiB
JavaScript
195 lines
5.6 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '5ed03XcVqROhLonnoUalsRJ', 'cmp.adventure.map');
|
|
// Scripts/mod/pve/adventure/cmp/cmp.adventure.map.js
|
|
|
|
"use strict";
|
|
|
|
var ItemBase = require("nx.fx.sv.expand.item");
|
|
var AdventureEVT = require("adventure_event");
|
|
var ADVCT = require("adventure_controller");
|
|
var 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: function onLoad() {
|
|
this.ctrl = ADVCT.getInstance();
|
|
},
|
|
//设置相对坐标
|
|
setPos: function 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: function setUI() {
|
|
//设置图片
|
|
var idx = Math.floor(Math.random() * 4);
|
|
var lsp = nx.gui.getComponent(this.land, "", cc.Sprite);
|
|
lsp.spriteFrame = this.landSp[idx];
|
|
var ssp = nx.gui.getComponent(this.shadow, "", cc.Sprite);
|
|
ssp.spriteFrame = this.shadowSp[idx];
|
|
var num_arr = [1, 2, 3];
|
|
var 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: function updateInfo(index) {
|
|
if (index != null) {
|
|
this.index = index;
|
|
}
|
|
//需要刷新data
|
|
var 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: function 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) {
|
|
//探索中
|
|
var room_ids = [];
|
|
room_ids.push(this.poses);
|
|
var model_type = this.ctrl.getPlayModel();
|
|
if (!this.evt_info) return;
|
|
//判斷障礙物
|
|
if (this.evt_info.evt_type == 11) {
|
|
var item = this.ctrl.getItemBybid(99989);
|
|
if (!item || item.num <= 0) {
|
|
return nx.tbox("AdvenCzNEnough");
|
|
}
|
|
}
|
|
var 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: function getPoses() {
|
|
return this.poses;
|
|
},
|
|
lightMap: function lightMap() {
|
|
this.prePath.active = true;
|
|
},
|
|
nightMap: function nightMap() {
|
|
this.prePath.active = false;
|
|
},
|
|
delCloud: function delCloud() {
|
|
//去除阴影
|
|
this.cloud.active = false;
|
|
} // update (dt) {},
|
|
});
|
|
|
|
cc._RF.pop(); |