226 lines
5.8 KiB
JavaScript
226 lines
5.8 KiB
JavaScript
import GameModel from "../../ts/core/GameModel";
|
|
import SKDataUtil from "../../ts/gear_2.3.4/util/SKDataUtil";
|
|
import GameUtil from "../../ts/core/GameUtil";
|
|
import VIPUtil from "../../ts/game/role/VIPUtil";
|
|
import MyModel from "../../ts/core/MyModel";
|
|
|
|
var SetRoleTitleUIMgr = require('../../game/SetRoleTitleUIMgr');
|
|
let CMainPlayerInfo = require('../../game/MainPlayerInfo');
|
|
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
content: cc.Node,
|
|
emojiAtlas: cc.SpriteAtlas,
|
|
|
|
propItem: cc.Prefab,
|
|
petItem: cc.Prefab,
|
|
roleTitleItem: cc.Prefab,
|
|
chatTaskItem: cc.Prefab,
|
|
chatEmotionItem: cc.Prefab,
|
|
|
|
emotionScrollView: cc.ScrollView,
|
|
propScrollView: cc.ScrollView,
|
|
petScrollView: cc.ScrollView,
|
|
taskScrollView: cc.ScrollView,
|
|
appelScrollView: cc.ScrollView,
|
|
},
|
|
|
|
onBottomToggle(event, type) {
|
|
// console.log("onBottomToggle")
|
|
let contents = this.content.children;
|
|
for (let i = 0; i < contents.length; i++) {
|
|
contents[i].active = false;
|
|
}
|
|
if (type == "emotion") {
|
|
this.emotionScrollView.node.active = true;
|
|
}
|
|
else if (type == "prop") {
|
|
this.propScrollView.node.active = true;
|
|
}
|
|
else if (type == "mount") {
|
|
this.petScrollView.node.active = true;
|
|
}
|
|
else if (type == "task") {
|
|
this.taskScrollView.node.active = true;
|
|
}
|
|
else if (type == "roletitle") {
|
|
this.appelScrollView.node.active = true;
|
|
}
|
|
},
|
|
|
|
initEmotion() {
|
|
// cc.log("初始化表情包");
|
|
this.isEmojiShow = false;
|
|
this.emotionScrollView.content.removeAllChildren();
|
|
for (let index = 0; index < 179; index++) {
|
|
|
|
let biaoqing = cc.instantiate(this.chatEmotionItem);
|
|
let data = { index: index };
|
|
biaoqing.getComponent("ChatEmotionItem").loadInfo(data);
|
|
if (biaoqing.getComponent("ChatEmotionItem").isEmpty) continue;
|
|
biaoqing.parent = this.emotionScrollView.content;
|
|
biaoqing.getComponent('ChatEmotionItem').setCallback(this.onPropCallback.bind(this));
|
|
}
|
|
},
|
|
|
|
initProp() {
|
|
this.propScrollView.content.removeAllChildren();
|
|
|
|
let list = [];
|
|
if (GameModel.equipData) {
|
|
let equipData = GameModel.equipData;
|
|
// cc.log(equipData);
|
|
for (const equip of equipData.list) {
|
|
if (equipData.info[equip]) {
|
|
let info = {
|
|
itemid: equip,
|
|
info: GameModel.equipData.info[equip],
|
|
type: 1
|
|
};
|
|
list.push(info);
|
|
}
|
|
}
|
|
for (let key in equipData.use) {
|
|
if (equipData.info[equipData.use[key]]) {
|
|
let info = {
|
|
itemid: equipData.use[key],
|
|
info: GameModel.equipData.info[equipData.use[key]],
|
|
type: 1
|
|
};
|
|
list.push(info);
|
|
}
|
|
}
|
|
}
|
|
let itemList = GameModel.player.itemList;
|
|
for (let itemId in itemList) {
|
|
let count = SKDataUtil.valueForKey(GameModel.player.itemList, itemId);
|
|
if (count != null && count > 0) {
|
|
let info = {
|
|
itemid: itemId,
|
|
count: count,
|
|
type: 0
|
|
};
|
|
list.push(info);
|
|
}
|
|
}
|
|
// cc.log(list);
|
|
let maxLength = list.length;
|
|
for (let index = 0; index < maxLength; index++) {
|
|
let item = null;
|
|
item = cc.instantiate(this.propItem);
|
|
item.parent = this.propScrollView.content;
|
|
item.getComponent('ChatPropItem').setData(list[index]);
|
|
item.getComponent('ChatPropItem').setCallback(this.onPropCallback.bind(this));
|
|
}
|
|
},
|
|
|
|
initPet() {
|
|
this.petScrollView.content.removeAllChildren();
|
|
// cc.log(this.mPetIndex);
|
|
|
|
if (this.mPetIndex == 0) {
|
|
let petInfo = GameModel.player.petInfo;
|
|
|
|
for (let index = 0; index < petInfo.list.length; index++) {
|
|
let pinfo = petInfo.list[index];
|
|
if (!pinfo || !pinfo.petid) {
|
|
cc.warn(`$警告:召喚獸面板加載列表數據錯誤${index}`);
|
|
continue;
|
|
}
|
|
pinfo.mType = 3;
|
|
let item = cc.instantiate(this.petItem);
|
|
item.parent = this.petScrollView.content;
|
|
item.getComponent('ChatPetItem').loadInfo(pinfo);
|
|
item.getComponent('ChatPetItem').setCallback(this.onPropCallback.bind(this));
|
|
}
|
|
} else {
|
|
let list = MyModel.shared.horseList.dict;
|
|
// cc.log(list);
|
|
for (let index in list) {
|
|
let pinfo = list[index];
|
|
if (!pinfo) {
|
|
cc.warn(`$警告:坐騎面板加載列表數據錯誤${index}`);
|
|
continue;
|
|
}
|
|
pinfo.mType = 4;
|
|
let item = cc.instantiate(this.petItem);
|
|
item.parent = this.petScrollView.content;
|
|
item.getComponent('ChatPetItem').loadInfo(pinfo);
|
|
item.getComponent('ChatPetItem').setCallback(this.onPropCallback.bind(this));
|
|
}
|
|
}
|
|
},
|
|
|
|
onTogglePetClick(event, petIndex) {
|
|
this.mPetIndex = petIndex;
|
|
this.initPet();
|
|
},
|
|
|
|
initRoleTitle() {
|
|
let roleTitles = SetRoleTitleUIMgr.roleTitles;
|
|
|
|
// cc.log(roleTitles);
|
|
this.appelScrollView.content.removeAllChildren();
|
|
for (let index = 0; index < roleTitles.length; index++) {
|
|
let pinfo = roleTitles[index];
|
|
if (!pinfo) {
|
|
cc.warn(`$警告:加載列表數據錯誤${index}`);
|
|
continue;
|
|
}
|
|
let item = cc.instantiate(this.roleTitleItem);
|
|
item.parent = this.appelScrollView.content;
|
|
item.getComponent('ChatRoleTitleItem').loadInfo(pinfo);
|
|
item.getComponent('ChatRoleTitleItem').setCallback(this.onPropCallback.bind(this));
|
|
}
|
|
},
|
|
|
|
initTask() {
|
|
let tasks = CMainPlayerInfo.vecTaskState;
|
|
// cc.log(tasks);
|
|
this.taskScrollView.content.removeAllChildren();
|
|
for (let index = 0; index < tasks.length; index++) {
|
|
let pinfo = tasks[index];
|
|
if (!pinfo) {
|
|
cc.warn(`$警告:加載列表數據錯誤${index}`);
|
|
continue;
|
|
}
|
|
let item = cc.instantiate(this.chatTaskItem);
|
|
item.parent = this.taskScrollView.content;
|
|
item.getComponent('ChatTaskItem').loadInfo(pinfo);
|
|
item.getComponent('ChatTaskItem').setCallback(this.onPropCallback.bind(this));
|
|
}
|
|
},
|
|
|
|
setCallback(callback) {
|
|
this.mCallback = callback;
|
|
},
|
|
|
|
onPropCallback(data) {
|
|
// cc.log(data);
|
|
if (this.mCallback) {
|
|
this.mCallback(data);
|
|
}
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
onLoad() {
|
|
this.mPropIndex = 0;
|
|
this.mPetIndex = 0;
|
|
|
|
this.initEmotion();
|
|
this.initProp();
|
|
this.initPet();
|
|
this.initRoleTitle();
|
|
this.initTask();
|
|
},
|
|
|
|
|
|
start() {
|
|
|
|
},
|
|
|
|
// update (dt) {},
|
|
});
|