|
@@ -7,6 +7,7 @@ import { GoodsData } from "../data/GoodsData";
|
|
|
import { MailData } from "../data/MailData";
|
|
|
import { RoleData } from "../data/RoleData";
|
|
|
import { UserData } from "../data/UserData";
|
|
|
+import { RoleConf } from "../ui/tower/conf/RoleConf";
|
|
|
import { EquipManager } from "./EquipManager";
|
|
|
import { GoodsManager } from "./GoodsManager";
|
|
|
import { RoleManager } from "./RoleManager";
|
|
@@ -15,23 +16,23 @@ import { RoleManager } from "./RoleManager";
|
|
|
//所有manager的连接器
|
|
|
export class UnionManager {
|
|
|
// 解析奖励数据
|
|
|
- static parseServerAwards(data:{[key:string]:AwardData}) {
|
|
|
- let awards:Array<BaseItem> = [];
|
|
|
+ static parseServerAwards(data: { [key: string]: AwardData }) {
|
|
|
+ let awards: Array<BaseItem> = [];
|
|
|
for (const key in Object.keys(data)) {
|
|
|
const element = data[key];
|
|
|
console.log(element[0]);
|
|
|
if (element[0] == ItemEnum.material) {
|
|
|
- let item = GoodsManager.addGoodsById(element[1].toString() , element[2]);
|
|
|
+ let item = GoodsManager.addGoodsById(element[1].toString(), element[2]);
|
|
|
awards.push(item);
|
|
|
} else if (element[0] == ItemEnum.equip) {
|
|
|
- }else if (element[0] == ItemEnum.user) {
|
|
|
+ } else if (element[0] == ItemEnum.user) {
|
|
|
let item: BaseItem = {
|
|
|
conf: {},
|
|
|
count: element[2],
|
|
|
id: element[1].toString(),
|
|
|
type: ItemEnum.user
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
let statu = UserData.status[element[1]]
|
|
|
if (statu) {
|
|
|
statu += element[2];
|
|
@@ -47,22 +48,22 @@ export class UnionManager {
|
|
|
}
|
|
|
|
|
|
// 触发物品刷新事件
|
|
|
- static fireEventWithItem(itemList:[BaseItem]){
|
|
|
+ static fireEventWithItem(itemList: [BaseItem]) {
|
|
|
let updateEvent = [];
|
|
|
- for(let i in itemList){
|
|
|
+ for (let i in itemList) {
|
|
|
let item = itemList[i];
|
|
|
- if(item.type == ItemEnum.user){
|
|
|
- if(!updateEvent[GameEvent.StatusUpdate]){
|
|
|
+ if (item.type == ItemEnum.user) {
|
|
|
+ if (!updateEvent[GameEvent.StatusUpdate]) {
|
|
|
Framework.event.fireEvent(GameEvent.StatusUpdate);
|
|
|
}
|
|
|
updateEvent[GameEvent.StatusUpdate] = true
|
|
|
- }else if(item.type == ItemEnum.equip){
|
|
|
- if(!updateEvent[GameEvent.EquipChange]){
|
|
|
+ } else if (item.type == ItemEnum.equip) {
|
|
|
+ if (!updateEvent[GameEvent.EquipChange]) {
|
|
|
Framework.event.fireEvent(GameEvent.EquipChange);
|
|
|
}
|
|
|
updateEvent[GameEvent.EquipChange] = true
|
|
|
- }else if(item.type == ItemEnum.material){
|
|
|
- if(!updateEvent[GameEvent.MaterialChange]){
|
|
|
+ } else if (item.type == ItemEnum.material) {
|
|
|
+ if (!updateEvent[GameEvent.MaterialChange]) {
|
|
|
Framework.event.fireEvent(GameEvent.MaterialChange);
|
|
|
}
|
|
|
updateEvent[GameEvent.MaterialChange] = true
|
|
@@ -70,8 +71,8 @@ export class UnionManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- static showItemTips(awards:Array<BaseItem>) {
|
|
|
- let tipsStr:string = "";
|
|
|
+ static showItemTips(awards: Array<BaseItem>) {
|
|
|
+ let tipsStr: string = "";
|
|
|
for (const key in awards) {
|
|
|
const element = awards[key];
|
|
|
tipsStr += element.count + "*" + element.id + " ";
|
|
@@ -102,7 +103,7 @@ export class UnionManager {
|
|
|
if (data.role_bag && data.role_bag.roles) {
|
|
|
RoleManager.setData(data.role_bag.roles)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
BattleData.setLoginData(data)
|
|
|
|
|
|
if (data.inventory) {
|
|
@@ -112,5 +113,28 @@ export class UnionManager {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ // 更新角色属性
|
|
|
+ static UpdateRoleAttr(data: []) {
|
|
|
+ for (const rId of data) {
|
|
|
+ let role = RoleData.getRoleDataByID(rId);
|
|
|
+ let newAttr = RoleManager.CalcRoleAttr(role);
|
|
|
+ role.attr = newAttr;
|
|
|
+ Framework.event.fireEvent(GameEvent.RoleAttrChange, rId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据种族获取所属英雄id
|
|
|
+ static getRoleGroupByRace(race) {
|
|
|
+ let rGroup = [];
|
|
|
+ for (const key in RoleConf.data) {
|
|
|
+ if (Object.prototype.hasOwnProperty.call(RoleConf.data, key)) {
|
|
|
+ const element = RoleConf.data[key];
|
|
|
+ if (element.Race == race) {
|
|
|
+ rGroup.push(element.Id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rGroup;
|
|
|
+ }
|
|
|
}
|