|
@@ -2,11 +2,13 @@ import Gamecfg from "../../../../common/gameCfg";
|
|
import { gameMethod } from "../../../../common/gameMethod";
|
|
import { gameMethod } from "../../../../common/gameMethod";
|
|
import GameDataCenter from "../../../../data/GameDataCenter";
|
|
import GameDataCenter from "../../../../data/GameDataCenter";
|
|
import { ItemEvent, UserEvent, ZhanLiEvent } from "../../../../data/const/EventConst";
|
|
import { ItemEvent, UserEvent, ZhanLiEvent } from "../../../../data/const/EventConst";
|
|
-import { ConstItem, HeadBgType } from "../../../../data/const/TypeConst";
|
|
|
|
|
|
+import { ConstItem, HeadBgType, ItemKind } from "../../../../data/const/TypeConst";
|
|
import FguiLoadMgr from "../../../../frameWork/fgui/FguiLoadMgr";
|
|
import FguiLoadMgr from "../../../../frameWork/fgui/FguiLoadMgr";
|
|
import EventMng from "../../../../manager/EventMng";
|
|
import EventMng from "../../../../manager/EventMng";
|
|
import ClickAuEffect from "../../../../utils/ClickAuEffect";
|
|
import ClickAuEffect from "../../../../utils/ClickAuEffect";
|
|
import GameMath from "../../../../utils/GameMath";
|
|
import GameMath from "../../../../utils/GameMath";
|
|
|
|
+import { GridEvent } from "../../../gridMap/GridEvent";
|
|
|
|
+import ItemCount, { ItemCountExtraParam } from "../../Common/ItemCount";
|
|
import UserHead from "../../Common/UserHead";
|
|
import UserHead from "../../Common/UserHead";
|
|
|
|
|
|
export default class UIHeadTopView {
|
|
export default class UIHeadTopView {
|
|
@@ -16,6 +18,9 @@ export default class UIHeadTopView {
|
|
private _ZhanLiFont: fairygui.GObject;
|
|
private _ZhanLiFont: fairygui.GObject;
|
|
private _UserHead: UserHead;
|
|
private _UserHead: UserHead;
|
|
private _PbLv: fairygui.GProgressBar;
|
|
private _PbLv: fairygui.GProgressBar;
|
|
|
|
+ ItemGold: ItemCount;
|
|
|
|
+ ItemDiamond: ItemCount;
|
|
|
|
+ ItemSp: ItemCount;
|
|
public constructor(vm: fgui.GComponent) {
|
|
public constructor(vm: fgui.GComponent) {
|
|
this._HeadBtn = vm.getChild("HeadBtn")
|
|
this._HeadBtn = vm.getChild("HeadBtn")
|
|
this._NameFont = vm.getChild("NameFont")
|
|
this._NameFont = vm.getChild("NameFont")
|
|
@@ -23,24 +28,35 @@ export default class UIHeadTopView {
|
|
this._ZhanLiFont = vm.getChild("ZhanLiFont")
|
|
this._ZhanLiFont = vm.getChild("ZhanLiFont")
|
|
this._UserHead = vm.getChild("UserHead") as UserHead;
|
|
this._UserHead = vm.getChild("UserHead") as UserHead;
|
|
this._PbLv = vm.getChild("PbLv") as fgui.GProgressBar;
|
|
this._PbLv = vm.getChild("PbLv") as fgui.GProgressBar;
|
|
|
|
+ this.ItemGold = new ItemCount(vm.getChild("ItemGold") as fgui.GButton);
|
|
|
|
+ this.ItemDiamond = new ItemCount(vm.getChild("ItemDiamond") as fgui.GButton);
|
|
|
|
+ this.ItemSp = new ItemCount(vm.getChild("ItemSp") as fgui.GButton);
|
|
// FguiLoadMgr.loadItemIcon(vm.getChild("GoldImg").asLoader, ConstItem.coin, () => { }, 0.3);
|
|
// FguiLoadMgr.loadItemIcon(vm.getChild("GoldImg").asLoader, ConstItem.coin, () => { }, 0.3);
|
|
// FguiLoadMgr.loadItemIcon(vm.getChild("DiamondImg").asLoader, ConstItem.gem, () => { }, 0.3);
|
|
// FguiLoadMgr.loadItemIcon(vm.getChild("DiamondImg").asLoader, ConstItem.gem, () => { }, 0.3);
|
|
}
|
|
}
|
|
|
|
|
|
public onEnable(): void {
|
|
public onEnable(): void {
|
|
|
|
+ this.ItemGold.onEnable();
|
|
|
|
+ this.ItemDiamond.onEnable();
|
|
|
|
+ this.ItemSp.onEnable();
|
|
|
|
+ GameDataCenter.item.sendItemInfo();
|
|
EventMng.on(ItemEvent.UP_ITEM, this.onUpItem, this)
|
|
EventMng.on(ItemEvent.UP_ITEM, this.onUpItem, this)
|
|
|
|
+ EventMng.on(GridEvent.HC_SP_UP, this.onUpSp, this)
|
|
EventMng.on(ZhanLiEvent.ZHANLI_UP_HOME_ZHANLI, this.onUpZhanLi, this)
|
|
EventMng.on(ZhanLiEvent.ZHANLI_UP_HOME_ZHANLI, this.onUpZhanLi, this)
|
|
EventMng.on(UserEvent.SET_NAME_SUCC, this.onUpUser, this);
|
|
EventMng.on(UserEvent.SET_NAME_SUCC, this.onUpUser, this);
|
|
EventMng.on(UserEvent.UP_USER, this.onUpUser, this);
|
|
EventMng.on(UserEvent.UP_USER, this.onUpUser, this);
|
|
this._HeadBtn.onClick(this.OnClickHeadBtn, this)
|
|
this._HeadBtn.onClick(this.OnClickHeadBtn, this)
|
|
this.onUpUser()
|
|
this.onUpUser()
|
|
- this.onUpItem()
|
|
|
|
this.onUpZhanLi();
|
|
this.onUpZhanLi();
|
|
this.onUpRed();
|
|
this.onUpRed();
|
|
}
|
|
}
|
|
|
|
|
|
public onDisable(): void {
|
|
public onDisable(): void {
|
|
|
|
+ this.ItemGold.onDisable();
|
|
|
|
+ this.ItemDiamond.onDisable();
|
|
|
|
+ this.ItemSp.onDisable();
|
|
EventMng.off(ItemEvent.UP_ITEM, this.onUpItem, this)
|
|
EventMng.off(ItemEvent.UP_ITEM, this.onUpItem, this)
|
|
|
|
+ EventMng.off(GridEvent.HC_SP_UP, this.onUpSp, this)
|
|
EventMng.off(ZhanLiEvent.ZHANLI_UP_HOME_ZHANLI, this.onUpZhanLi, this)
|
|
EventMng.off(ZhanLiEvent.ZHANLI_UP_HOME_ZHANLI, this.onUpZhanLi, this)
|
|
EventMng.off(UserEvent.SET_NAME_SUCC, this.onUpUser, this);
|
|
EventMng.off(UserEvent.SET_NAME_SUCC, this.onUpUser, this);
|
|
EventMng.off(UserEvent.UP_USER, this.onUpUser, this);
|
|
EventMng.off(UserEvent.UP_USER, this.onUpUser, this);
|
|
@@ -73,7 +89,28 @@ export default class UIHeadTopView {
|
|
}
|
|
}
|
|
|
|
|
|
onUpItem() {
|
|
onUpItem() {
|
|
-
|
|
|
|
|
|
+ let param: ItemCountExtraParam = {
|
|
|
|
+ showAddBtn: true,
|
|
|
|
+ fullNumberShow: true,
|
|
|
|
+ isBuyItem: true,
|
|
|
|
+ notEnoughRed: false
|
|
|
|
+ }
|
|
|
|
+ let goldInfo = GameDataCenter.item.getKindItem(ConstItem.coin);
|
|
|
|
+ this.ItemGold.setData(goldInfo, null, param);
|
|
|
|
+ let gemInfo = GameDataCenter.item.getKindItem(ConstItem.gem);
|
|
|
|
+ this.ItemDiamond.setData(gemInfo, null, param);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ onUpSp() {
|
|
|
|
+ //体力单独读取
|
|
|
|
+ let spInfo = [ConstItem.sp[0], ConstItem.sp[1], GameDataCenter.gridMap.hcInfo?.tili];
|
|
|
|
+ let param: ItemCountExtraParam = {
|
|
|
|
+ showAddBtn: true,
|
|
|
|
+ fullNumberShow: true,
|
|
|
|
+ isBuyItem: true,
|
|
|
|
+ notEnoughRed: false
|
|
|
|
+ }
|
|
|
|
+ this.ItemSp.setData(spInfo, null, param);
|
|
}
|
|
}
|
|
|
|
|
|
onUpZhanLi() {
|
|
onUpZhanLi() {
|