-
当界面显示时事件
/
private onDisplay() {
// 刷新角色
this.refreshActorList();
// 刷新焦点
this.refreshFocus();
// 刷新道具列表
this.refreshItems(0);
// 刷新装备
this.refreshActorEquips();
this.actorEquipList.selectedIndex = -1;
this.goodsList.selectedIndex = 0;
if (this.discardArea) this.discardArea.visible = false;
}
/*
-
当退出时
/
private onBack(): boolean {
if (this.targetUI.visible) {
this.targetUI.visible = false;
return false;
}
return true;
}
/*
-
键盘事件
*/
private onKeyDown(e: EventObject): void {
if (!this.stage) return;
// -- 使用道具
if (GUI_Setting.IS_KEY(e.keyCode, GUI_Setting.KEY_BOARD.A)) {
if (UIList.focus == this.goodsList) {
this.doItemUse();
}
else if (UIList.focus == this.actorEquipList) {
let lastGoodsSelectedIndex = this.goodsList.selectedIndex;
this.takeoffEquipFromEquipList(null);
// this.jumpToActorEquipList = false;
this.goodsList.selectedIndex = lastGoodsSelectedIndex;
}
}
// -- 焦点至装备栏
else if (GUI_Setting.IS_KEY(e.keyCode, GUI_Setting.KEY_BOARD.RIGHT)) {
if (UIList.focus == this.goodsList) {
if (this.goodsList.selectedIndex % this.goodsList.repeatX == this.goodsList.repeatX - 1) {
if (this.jumpToActorEquipList) {
this.jumpToActorEquipList = false;
UIList.focus = this.actorEquipList;
}
else {
this.jumpToActorEquipList = true;
}
}
}
}
// -- 焦点至背包栏
else if (GUI_Setting.IS_KEY(e.keyCode, GUI_Setting.KEY_BOARD.LEFT)) {
this.jumpToActorEquipList = false;
this.jumpToSummonrMonsterList = false;
if (UIList.focus == this.actorEquipList) {
UIList.focus = this.goodsList;
this.actorEquipList.selectedIndex = -1;
this.jumpToActorEquipList = true;
}
}
// -- L1
else if (GUI_Setting.IS_KEY(e.keyCode, GUI_Setting.KEY_BOARD.L1)) {
this.setSelectActorIndex(this.actorList.selectedIndex - 1);
}
// -- R1
else if (GUI_Setting.IS_KEY(e.keyCode, GUI_Setting.KEY_BOARD.R1)) {
this.setSelectActorIndex(this.actorList.selectedIndex + 1);
}
// -- X
else if (GUI_Setting.IS_KEY(e.keyCode, GUI_Setting.KEY_BOARD.X)) {
if (this.dissolutionBtn.visible) {
this.dissolutionBtn.event(EventObject.CLICK);
}
}
}
/**
-
刷新焦点
/
private refreshFocus(): void {
this.jumpToActorEquipList = false;
this.jumpToSummonrMonsterList = false
this.actorEquipList.selectedIndex = -1;
UIList.focus = this.goodsList;
this.refreshDescribe();
this.refreshActorDataPanel();
}
//------------------------------------------------------------------------------------------------------
// 接口
//------------------------------------------------------------------------------------------------------
/*
-
解散选定的角色
/
static dissolutionPartyActor(): void {
var uiActor = GameUI.get(4) as GUI_Actor;
if (!uiActor) return;
if (!uiActor.selectedActorDS) return;
if (Game.player.data.party.length == 1 || !uiActor.selectedActorDS.dissolutionEnabled) {
GameAudio.playSE(WorldData.disalbeSE);
return;
}
GameAudio.playSE(WorldData.sureSE);
ProjectPlayer.removePlayerActorByInPartyIndex(uiActor.actorList.selectedIndex);
uiActor.refreshActorList();
FocusButtonsManager.closeFocus();
UIList.focus = uiActor.actorList;
uiActor.actorList.selectedIndex = 0;
uiActor.refreshFocus();
}
//------------------------------------------------------------------------------------------------------
// 数据
//------------------------------------------------------------------------------------------------------
/*
-
获取当前选中的角色DS
-
@return [DataStructure_inPartyActor]
/
private get selectedActorDS(): DataStructure_inPartyActor {
let selectedIndex = Math.min(Math.max(0, this.actorList.selectedIndex), Game.player.data.party.length - 1);
return Game.player.data.party[selectedIndex];
}
private get selectedActorDSIndex(): number {
let selectedIndex = Math.min(Math.max(0, this.actorList.selectedIndex), Game.player.data.party.length - 1);
return selectedIndex;
}
private get selectedSceneObject() {
return ProjectPlayer.getPlayerPartyBattler(this.targetActorList.selectedIndex);
}
private setSelectActorIndex(n: number): void {
if (n < 0) n = this.actorList.length - 1;
else if (n >= this.actorList.length) n = 0;
this.actorList.selectedIndex = n;
}
//------------------------------------------------------------------------------------------------------
// 角色列表
//------------------------------------------------------------------------------------------------------
/*
-
刷新角色
/
private refreshActorList(): void {
let lastActorListIndex = this.actorList.selectedIndex;
let arr = [];
// 遍历我的队伍
for (let i = 0; i < Game.player.data.party.length; i++) {
// 获取角色DS格式数据
let actorDS: DataStructure_inPartyActor = Game.player.data.party[i];
// 获取角色模块数据
let actor: Module_Actor = actorDS.actor;
// 创建列表的项数据
let d = new ListItem_1011;
// 头像
d.face = actor.face;
// 绑定数据,以免后面直接访问
d.data = actorDS;
// 添加至数组中
arr.push(d);
}
this.actorList.items = arr;
if (lastActorListIndex == -1) this.actorList.selectedIndex = 0;
else this.actorList.selectedIndex = lastActorListIndex;
}
/*
-
刷新角色
/
private refreshActor(): void {
this.refreshActorEquips();
this.refreshActorDataPanel();
let selectedActorDS = this.selectedActorDS;
if (selectedActorDS) {
this.dissolutionBtn.visible = selectedActorDS.dissolutionEnabled;
}
}
/*
-
当创建可装备的道具栏项时
/
private onCreateActorItem(ui: GUI_1011, data: ListItem_1011, index: number) {
let actorDS: DataStructure_inPartyActor = data.data;
if (actorDS) {
let battler = ProjectPlayer.getPlayerPartyBattler(index);
let battlerModule = battler.getModule(6) as SoModule_Battler;
ui.deadSign.visible = battlerModule.isDead ? true : false;
}
}
/*
-
当角色列表-鼠标悬停
/
private onActorListMouseOver(e): void {
UIList.focus = this.actorList;
}
//------------------------------------------------------------------------------------------------------
// 道具
//------------------------------------------------------------------------------------------------------
/*
-
目标角色列表
-
@return [UIList]
/
private get targetActorList(): UIList {
return this.targetUI.actorList;
}
/*
-
当道具项创建时
/
private onItemCreate(ui: GUI_1002, data: ListItem_1002, index: number): void {
let itemDS: DataStructure_packageItem = data.data;
DragUtils.reg(ui, ui.icon, Callback.New(this.onItemMouseDown, this, [ui, index]), Callback.New(this.onItemMouseUp, this, [ui, index]), Callback.New((index: number) => {
return Game.player.data.package[index] != null;
}, this, [index]));
ui.on(EventObject.MOUSE_OVER, this, this.onItemMouseOver, [ui, index]);
ui.on(EventObject.MOUSE_OUT, this, this.onItemMouseOut, [ui]);
}
/*
-
当道具发生变更时
/
private onItemChange() {
if (this.stage) this.refreshItems(0);
}
/*
-
刷新道具列表
-
@param state
/
private refreshItems(state: number) {
if (state != 0) return;
let arr: ListItem_1002[] = [];
// 遍历玩家自定义数据-背包
for (let i = 0; i < Game.player.data.packageCapacity; i++) {
// 创建对应的背包物品项数据,该项数据由系统自动生成
let d = new ListItem_1002;
// 获取背包的道具DS格式
let itemDS = Game.player.data.package[i];
// 绑定项数据,项显示对象会自动根据项数据设置对应的值,参考UIList.api头部注释(CTRL+SHIFT+R搜索UIList.api)
d.data = itemDS; // 项数据记录对应的道具,以便能够通过项数据找到其对应的道具
if (itemDS) {
if (itemDS.isEquip) {
d.icon = itemDS.equip.icon; // 设置图标
}
else {
d.icon = itemDS.item.icon; // 设置图标
}
d.itemNum = itemDS.number > 1 ? "x" + itemDS.number.toString() : ""; // 设置道具数目
}
else {
d.icon = "";
d.itemNum = "";
}
arr.push(d);
}
// 刷新列表
this.goodsList.items = arr;
UIList.focus = this.goodsList;
this.goodsList.selectedIndex = -1;
}
/*
-
使用道具
/
doItemUse() {
// 锁定状态下时不触发使用效果
if (this.useItemLock) return;
// 关闭目标界面
this.targetUI.visible = false;
// 获取当前选中的列表项
let selectedItem = this.goodsList.selectedItem;
if (selectedItem && selectedItem.data) {
// 获取道具DS格式(此结构额外追加储存了道具的数目)
let itemDS: DataStructure_packageItem = selectedItem.data;
// 如果是装备的话,穿戴
if (itemDS.isEquip) {
let selectedIndex = this.goodsList.selectedIndex;
this.wearEquipFromPackage(this.goodsList.selectedIndex, true);
UIList.focus = this.goodsList;
this.goodsList.selectedIndex = selectedIndex;
return;
}
// 获取道具
let item = itemDS.item;
// 可使用道具且允许在背包中使用的情况
if (item.isUse && itemDS.number > 0) {
// 指定单个目标的话,弹出目标窗口以便选择目标后使用该道具
if (item.isSingleTarget) {
this.startSelectTarget(() => { this.onUseItem(itemDS); });
}
// 否则直接使用
else {
this.onUseItem(itemDS);
}
}
// 否则禁止使用的场合播放禁用音效
else {
GameAudio.playSE(WorldData.disalbeSE);
return;
}
}
}
/*
-
当使用道具时
-
@param itemDS
/
private onUseItem(itemDS: DataStructure_packageItem): void {
// 如果没有该道具的情况
if (itemDS.number <= 0) {
GameAudio.playSE(WorldData.disalbeSE);
return;
}
let item = itemDS.item;
// 获取角色
let targetActorDS: DataStructure_inPartyActor;
let targetActor: Module_Actor;
if (item.isSingleTarget) {
targetActorDS = ProjectPlayer.getPlayerActorDSByInPartyIndex(this.targetActorList.selectedIndex);
targetActor = targetActorDS.actor;
let targetSceneObject = ProjectPlayer.getPlayerPartyBattler(this.targetActorList.selectedIndex);
let targetSceneObjectModule = targetSceneObject.getModule(6) as SoModule_Battler;
// 如果是指向已死亡的目标时目标未死亡则忽略 or 如果是指向未死亡的目标时目标已死亡则忽略
if ((item.applyDeadBattler && !targetSceneObjectModule.isDead) || (!item.applyDeadBattler && targetSceneObjectModule.isDead)) {
GameAudio.playSE(WorldData.disalbeSE);
return;
}
// 状态已满的情况不允许使用
if (!targetSceneObjectModule.isDead && !item.applyDeadBattler) {
if ((item.recoveryHP > 0 && item.recoverySP > 0 && targetActor.hp == targetActor.MaxHP && targetActor.sp == targetActor.MaxSP) ||
(item.recoveryHP > 0 && item.recoverySP == 0 && targetActor.hp == targetActor.MaxHP) ||
(item.recoveryHP == 0 && item.recoverySP > 0 && targetActor.sp == targetActor.MaxSP)) {
GameAudio.playSE(WorldData.disalbeSE);
return;
}
}
}
// 锁定,在执行完毕事件前不允许再次使用
this.useItemLock = true;
// 播放使用音效
if (item.se) GameAudio.playSE(item.se);
// 获取指定角色
let targetSceneObject = item.isSingleTarget ? ProjectPlayer.getPlayerPartyBattler(this.targetActorList.selectedIndex) : ProjectPlayer.ctrlActorSceneObject;
let trigger: CommandTrigger = null;
if (targetSceneObject) {
let targetSceneObjectModule = targetSceneObject.getModule(6) as SoModule_Battler;
if (targetSceneObjectModule) {
// -- 执行片段事件
trigger = CommandPage.startTriggerFragmentEvent(item.callEvent, targetSceneObject, targetSceneObject, Callback.New(() => {
// 使用道具
if (item.isSingleTarget) {
// -- 复活
if (item.applyDeadBattler && item.recoveryHP > 0 && targetSceneObjectModule.isDead) {
GameBattleData.resuscitate(targetSceneObject);
this.refreshActorList();
}
// -- 恢复
if (!targetSceneObjectModule.isDead) {
targetActor.hp += item.recoveryHP;
targetActor.sp += item.recoverySP;
}
// -- 刷新属性
Game.refreshActorAttribute(targetActor, targetActorDS.lv, targetSceneObject);
}
// -- 刷新目标角色列表(可能队伍发生了变更或角色属性发生变更)
this.targetUI.refreshTargetPanel();
// -- 解锁
this.useItemLock = false;
}, this));
// -- 增减状态
for (let i = 0; i < item.removeStatus.length; i++) {
let statusID = item.removeStatus[i];
GameBattleData.removeStatus(targetSceneObject, statusID, true);
}
for (let i = 0; i < item.addStatus.length; i++) {
let statusID = item.addStatus[i];
GameBattleData.addStatus(targetSceneObject, statusID, targetSceneObject, false, true);
}
// -- 刷新属性
if (this.selectedSceneObject) Game.refreshActorAttribute(this.selectedActorDS.actor, this.selectedActorDS.lv, this.selectedSceneObject);
// -- 刷新面板
this.refreshActorDataPanel();
this.targetUI.refreshTargetPanel();
}
}
if (!trigger) this.useItemLock = false;
// 消耗品的情况:道具-1
if (item.isConsumables) {
ProjectPlayer.changeItemNumber(item.id, -1, false, false);
let selectedIndex = this.goodsList.selectedIndex;
let goodsUI = this.goodsList.getItemUI(selectedIndex) as GUI_1002;
if (goodsUI) {
let itemDS = ProjectPlayer.getItemDSByIndex(selectedIndex);
this.setPackageData(selectedIndex, itemDS, false);
}
UIList.focus = this.targetActorList;
}
}
/*
-
拖拽道具:当道具项-鼠标按下后
/
private onItemMouseDown(ui: GUI_1002, index: number): void {
// 忽略空格子
if (!Game.player.data.package[index]) return;
ui.itemNum.visible = false;
this.startDragState = true;
this.discardArea.visible = true;
}
/*
-
拖拽道具:当道具项-鼠标弹起后
/
private onItemMouseUp(ui: GUI_1002, index: number): void {
let itemDS = Game.player.data.package[index];
ui.itemNum.visible = true;
this.startDragState = false;
this.discardArea.visible = false;
// 位于装备格子时
if (UIList.focus == this.actorEquipList) {
let lastSelectedIndex = this.actorEquipList.selectedIndex;
this.wearEquipFromPackage(index);
UIList.focus = this.actorEquipList;
this.goodsList.selectedIndex = -1;
this.actorEquipList.selectedIndex = lastSelectedIndex;
this.refreshDescribe();
}
// 位于背包格子时(交换)
else if (this.putItemPostion != null) {
let sIcon = ui.icon.image;
let sItemNum = ui.itemNum.text;
let sItemData = this.goodsList.items[index].data;
let targetUI: GUI_1002 = this.goodsList.getItemUI(this.putItemPostion) as any;
let fromIndex = index;
let toIndex = this.putItemPostion;
ui.icon.image = targetUI.icon.image;
ui.itemNum.text = targetUI.itemNum.text;
targetUI.icon.image = sIcon;
targetUI.itemNum.text = sItemNum;
this.goodsList.items[fromIndex].data = this.goodsList.items[toIndex].data;
this.goodsList.items[toIndex].data = sItemData;
ArrayUtils.swap(Game.player.data.package, fromIndex, toIndex);
GameAudio.playSE(WorldData.swapItemSE);
}
// 位于场景上时:丢弃
else {
let inUIPanel = false;
for (var i = 0; i < this.numChildren; i++) {
let child = this.getChildAt(i) as GameSprite;
let bound = child.getSelfBounds();
if (child.visible && bound.contains(child.mouseX, child.mouseY)) {
inUIPanel = true;
break;
}
}
// 位于指定的组件上时也算为丢弃
if (this.discardArea) {
let bound = this.discardArea.getSelfBounds();
if (bound.contains(this.discardArea.mouseX, this.discardArea.mouseY)) {
inUIPanel = false;
}
}
if (!inUIPanel) {
new SceneItem(itemDS.isEquip ? itemDS.equip : itemDS.item, ProjectPlayer.ctrlActorSceneObject.x, ProjectPlayer.ctrlActorSceneObject.y, itemDS.isEquip, itemDS.number);
this.setPackageData(index, null, true);
GameAudio.playSE(WorldData.discardItemSE);
}
}
this.refreshDescribe();
}
/*
-
拖拽道具:当鼠标悬停
-
@param ui
-
@param index
/
private onItemMouseOver(ui: GUI_1002, index: number): void {
this.putItemPostion = index;
}
/*
-
拖拽道具:当鼠标移出
-
@param ui
/
private onItemMouseOut(ui: GUI_1002): void {
this.putItemPostion = null;
}
/*
-
当背包列表-鼠标悬停时
/
private onPackageMouseOver(): void {
this.targetUI.visible = false;
if (UIList.focus != this.goodsList) {
UIList.focus = this.goodsList;
this.actorEquipList.selectedIndex = -1;
this.goodsList.selectedIndex = -1;
}
}
/*
-
当背包按下时
/
private onItemClick(): void {
if (this.startDragState) return;
this.doItemUse();
}
/*
-
当背包右键按下时
/
private onItemRightClick(e: EventObject): void {
e.stopPropagation();
let itemDS: DataStructure_packageItem = this.goodsList.selectedItem?.data as any;
if (itemDS) {
this.doItemUse();
}
}
/*
-
设置背包数据
-
@param index 索引
-
@param itemDS 数据
-
@param changePlayerPackage 修改玩家背包数据
/
private setPackageData(index: number, itemDS: DataStructure_packageItem, changePlayerPackage: boolean): void {
let ui = this.goodsList.getItemUI(index) as GUI_1002;
if (changePlayerPackage) Game.player.data.package[index] = itemDS;
let item = itemDS ? (itemDS.isEquip ? itemDS.equip : itemDS.item) : null;
ui.icon.image = item ? item.icon : "";
ui.itemNum.text = itemDS ? "x" + itemDS.number.toString() : "";
this.goodsList.items[index].data = itemDS;
}
//------------------------------------------------------------------------------------------------------
// 装备
//------------------------------------------------------------------------------------------------------
/*
-
当道具项创建时
/
private onEquipCreate(ui: GUI_1012, data: ListItem_1012, index: number): void {
let equip: Module_Equip = data.data;
DragUtils.reg(ui, ui.icon, Callback.New(this.onEquipMouseDown, this, [ui, index, equip]), Callback.New(this.onEquipMouseUp, this, [ui, index, equip]), Callback.New((equip: Module_Equip) => {
return equip != null;
}, this, [equip]));
ui.on(EventObject.MOUSE_OVER, this, this.onItemMouseOver, [ui, index]);
ui.on(EventObject.MOUSE_OUT, this, this.onItemMouseOut, [ui]);
}
/*
-
刷新装备
/
private refreshActorEquips(): void {
let selectedActorDS = this.selectedActorDS;
if (!selectedActorDS) return;
let arr = [];
// 遍历部件
let equipPartsLength = GameData.getLength(19, 1);
for (let i = 1; i <= equipPartsLength; i++) {
let equip: Module_Equip = Game.getActorEquipByPartID(selectedActorDS.actor, i);
// 创建对应的背包物品项数据,该项数据由系统自动生成
let d = new ListItem_1012;
// 该部件存在装备的情况下
if (equip) {
d.data = equip;
d.icon = equip.icon;
}
else {
d.icon = "";
}
d.partName = GameData.getModuleData(19, i).name;
arr.push(d);
}
this.actorEquipList.items = arr;
}
/*
-
当装备栏列表-鼠标悬停时
/
private onEquipMouseOver(): void {
this.goodsList.selectedIndex = -1;
if (UIList.focus != this.actorEquipList) {
UIList.focus = this.actorEquipList;
this.actorEquipList.selectedIndex = -1;
this.refreshDescribe();
}
}
/*
-
刷新装备信息
/
private refreshEquipInfo(): void {
this.refreshDescribe();
}
/*
-
佩戴装备(从背包)
-
@param index 索引
-
@param autoPart[可选] 默认值=false 自动部位
/
private wearEquipFromPackage(packageIndex: number, autoPart: boolean = false): void {
let itemDS = Game.player.data.package[packageIndex];
// -- 忽略非装备
if (!itemDS || !itemDS.isEquip) return;
let equip = itemDS.equip;
// -- 忽略部位不对
if (!autoPart && equip.partID != this.actorEquipList.selectedIndex + 1) return;
// -- 忽略无法佩戴的装备
if (!ProjectPlayer.canWearPlayerActorEquip(this.selectedActorDSIndex, equip)) return;
// -- 佩戴装备
let wearInfo = ProjectPlayer.wearPlayerActorEquip(this.selectedActorDSIndex, equip);
if (wearInfo.success) {
GameAudio.playSE(WorldData.equipSE);
this.refreshActorEquips();
Game.refreshActorAttribute(this.selectedActorDS.actor, this.selectedActorDS.lv, ProjectPlayer.getPlayerPartyBattler(this.selectedActorDSIndex));
this.refreshActorDataPanel();
}
}
/*
-
当背包右键按下时
/
private takeoffEquipFromEquipList(e: EventObject): boolean {
e && e.stopPropagation();
let equip: Module_Equip = this.actorEquipList.selectedItem?.data as any;
if (equip) {
let takeoffEquip = ProjectPlayer.takeOffPlayerActorEquipByPartID(this.selectedActorDSIndex, equip.partID);
if (takeoffEquip) {
GameAudio.playSE(WorldData.unequipSE);
this.refreshActorEquips();
Game.refreshActorAttribute(this.selectedActorDS.actor, this.selectedActorDS.lv, ProjectPlayer.getPlayerPartyBattler(this.selectedActorDSIndex));
this.refreshActorDataPanel();
UIList.focus = this.actorEquipList;
return true;
}
else {
GameAudio.playSE(WorldData.disalbeSE);
}
}
return false;
}
/*
-
拖拽装备:当装备项-鼠标按下后
/
private onEquipMouseDown(ui: GUI_1012, index: number, equip: Module_Equip): void {
if (equip == null) return;
this.startDragState = true;
}
/*
-
拖拽装备:当装备项-鼠标弹起后
/
private onEquipMouseUp(ui: GUI_1012, index: number, equip: Module_Equip): void {
this.startDragState = false;
// 位于背包格子时
if (this.putItemPostion != null) {
// -- 空格子:卸载
let itemDS = Game.player.data.package[this.putItemPostion];
if (itemDS == null) {
let takeoffEquip = ProjectPlayer.takeOffPlayerActorEquipByPartID(this.selectedActorDSIndex, equip.partID, true, true, this.putItemPostion);
if (takeoffEquip) {
GameAudio.playSE(WorldData.unequipSE);
this.refreshActorEquips();
Game.refreshActorAttribute(this.selectedActorDS.actor, this.selectedActorDS.lv, ProjectPlayer.getPlayerPartyBattler(this.selectedActorDSIndex));
this.refreshActorDataPanel();
}
else {
GameAudio.playSE(WorldData.disalbeSE);
return;
}
}
// -- 装备
else if (itemDS.isEquip) {
// -- 部位匹配且允许佩戴
if (equip.partID == itemDS.equip.partID && ProjectPlayer.canWearPlayerActorEquip(this.selectedActorDSIndex, itemDS.equip)) {
let wearInfo = ProjectPlayer.wearPlayerActorEquip(this.selectedActorDSIndex, itemDS.equip);
if (wearInfo.success) {
GameAudio.playSE(WorldData.equipSE);
this.refreshActorEquips();
Game.refreshActorAttribute(this.selectedActorDS.actor, this.selectedActorDS.lv, ProjectPlayer.getPlayerPartyBattler(this.selectedActorDSIndex));
this.refreshActorDataPanel();
UIList.focus = this.goodsList;
this.goodsList.selectedIndex = this.putItemPostion;
}
}
}
}
this.refreshDescribe();
}
/*
-
刷新装备变更时的属性差预览
*/
private refreshPreEquipChangeInfo(): void {
let actor = this.selectedActorDS.actor;
this.attributeChangeBox.visible = true;
// 计算更换装备的属性变更预览
let previewChangeEquipDS: DataStructure_packageItem = UIList.focus == this.actorEquipList ? null : this.goodsList.selectedItem?.data;
if ((UIList.focus == this.actorEquipList) || (UIList.focus == this.goodsList && previewChangeEquipDS && previewChangeEquipDS.isEquip && ProjectPlayer.canWearPlayerActorEquip(this.selectedActorDSIndex, previewChangeEquipDS.equip))) {
let previewChangeEquip = previewChangeEquipDS ? previewChangeEquipDS.equip : null;
let previewChangeEquipIndex = previewChangeEquip ? previewChangeEquip.partID - 1 : this.actorEquipList.selectedIndex;
let previewChangeEquipID = previewChangeEquipIndex + 1;
CustomGameNumber.attributeRes = Game.clacActorAttribute(actor, this.selectedActorDS.lv, 2, previewChangeEquipID, previewChangeEquip);
// 属性变更显示
this.setEquipChangePreviewAttributeLabel(this.MaxHP2, actor.MaxHP, CustomGameNumber.attributeRes.MaxHP);
this.setEquipChangePreviewAttributeLabel(this.MaxSP2, actor.MaxSP, CustomGameNumber.attributeRes.MaxSP);
this.setEquipChangePreviewAttributeLabel(this.ATK2, actor.ATK, CustomGameNumber.attributeRes.ATK);
this.setEquipChangePreviewAttributeLabel(this.DEF2, actor.DEF, CustomGameNumber.attributeRes.DEF);
this.setEquipChangePreviewAttributeLabel(this.MAG2, actor.MAG, CustomGameNumber.attributeRes.MAG);
this.setEquipChangePreviewAttributeLabel(this.MagDef2, actor.MagDef, CustomGameNumber.attributeRes.MagDef);
this.setEquipChangePreviewAttributeLabel(this.HIT2, actor.HIT, CustomGameNumber.attributeRes.HIT);
this.setEquipChangePreviewAttributeLabel(this.DOD2, actor.DOD, CustomGameNumber.attributeRes.DOD);
this.setEquipChangePreviewAttributeLabel(this.CRIT2, actor.CRIT, CustomGameNumber.attributeRes.CRIT);
this.setEquipChangePreviewAttributeLabel(this.MagCrit2, actor.MagCrit, CustomGameNumber.attributeRes.MagCrit);
this.setEquipChangePreviewAttributeLabel(this.MoveSpeed2, actor.MoveSpeed, CustomGameNumber.attributeRes.MoveSpeed);
this.setEquipChangePreviewAttributeLabel(this.AtkSpeed2, actor.AtkSpeed, CustomGameNumber.attributeRes.AtkSpeed * 0.01 + 1);
for (let i = 1; i <= actor.extendAttributes.length; i++) {
let attributeStr = this[`E` + i];
if (attributeStr) this.setEquipChangePreviewAttributeLabel(attributeStr, actor.extendAttributes[i], CustomGameNumber.attributeRes.extendAttributes[i]);
}
}
else {
this.attributeChangeBox.visible = false;
}
}
/**
-
设置属性变更颜色和文本显示
-
@param attributeStr
-
@param value
-
@param toValue
/
private setEquipChangePreviewAttributeLabel(attributeStr: UIString, value: number, toValue: number) {
if (value == toValue) {
attributeStr.visible = false;
}
else {
attributeStr.visible = true;
if (toValue > value) {
attributeStr.color = this.increaseColor.color;
}
else {
attributeStr.color = this.reduceColor.color;
}
}
}
//------------------------------------------------------------------------------------------------------
// 角色目标窗口
//------------------------------------------------------------------------------------------------------
/*
-
当角色项确认时:使用道具
/
private onActorItemClick() {
// 记录使用者角色索引
GUI_Actor.actorSelectedIndex = this.targetActorList.selectedIndex;
// 使用道具
this.onSelectTargetUseItem.apply(this);
}
/*
-
开始选择目标
-
@param onSelectTargetUseItem 当选择角色时回调
/
private startSelectTarget(onSelectTargetUseItem: Function) {
// 播放确定音效
GameAudio.playSE(WorldData.sureSE);
// 打开目标窗口
this.targetUI.visible = true;
// 刷新目标窗口数值显示
this.targetUI.refreshTargetPanel();
// 焦点指向目标窗口的角色列表
UIList.focus = this.targetActorList;
// 记录当选择角色时回调
this.onSelectTargetUseItem = onSelectTargetUseItem;
}
//------------------------------------------------------------------------------------------------------
// 属性
//------------------------------------------------------------------------------------------------------
/*
-
刷新角色数据面板
/
private refreshActorDataPanel() {
let selectedActorDS = this.selectedActorDS;
if (!selectedActorDS) return;
let selectedActor = selectedActorDS.actor;
// 基本信息
this.actorName.text = selectedActor.name;
this.smallAvatar.avatarID = selectedActor.avatar;
let classData: Module_Class = GameData.getModuleData(7, selectedActor.class);
this.actorClass.text = classData ? classData.name : "";
this.classIcon.image = classData ? classData.icon : "";
// 等级和经验
if (selectedActor.growUpEnabled) {
this.LevelRoot.visible = true;
let nextExp = Game.getLevelUpNeedExp(selectedActor, selectedActorDS.lv);
this.actorExpSlider.value = selectedActor.currentEXP * 100 / nextExp;
}
else {
this.LevelRoot.visible = false;
this.actorExpSlider.value = 100;
}
}
//------------------------------------------------------------------------------------------------------
// 描述
//------------------------------------------------------------------------------------------------------
/*
-
刷新描述
/
private refreshDescribe(): void {
let name = "";
let desc = "";
this.itemName.color = this.itemNameInitColor;
// 焦点在装备栏
if (UIList.focus == this.actorEquipList) {
let equip: Module_Equip = this.actorEquipList.selectedItem?.data;
if (equip) {
name = equip.name + ${WorldData.word_equiped};
desc = GUI_Manager.equipDesc(equip);
this.itemName.color = GUI_Manager.getEquipNameColorByInstance(equip);
}
this.refreshPreEquipChangeInfo();
}
// 背包
else {
this.itemName.text = name;
this.itemIntro.text = desc;
this.refreshItemInfo();
this.refreshPreEquipChangeInfo();
return;
}
this.itemName.text = name;
this.itemIntro.text = desc;
this.itemIntro.height = this.itemIntro.textHeight;
this.itemIntroRoot.refresh();
}
/*
-
刷新道具详情
*/
private refreshItemInfo() {
// 获取选中的项数据
let selectedItem = this.goodsList.selectedItem;
// 未选中任何道具的情况
if (!selectedItem || !selectedItem.data) {
this.itemName.text = "";
this.itemIntro.text = "";
}
// 已选中道具的情况:显示该道具详情
else {
let itemDS: DataStructure_packageItem = selectedItem.data;
// 如果是装备,则显示为装备的名称和介绍
if (itemDS.isEquip) {
this.itemName.text = itemDS.equip.name;
this.itemIntro.text = GUI_Manager.equipDesc(itemDS.equip);
this.itemName.color = GUI_Manager.getEquipNameColorByInstance(itemDS.equip);
}
// 否则显示道具的名称和介绍
else {
this.itemName.text = itemDS.item.name;
this.itemIntro.text = itemDS.item.intro;
}
}
this.itemIntro.height = this.itemIntro.textHeight;
this.itemIntroRoot.refresh();
}
}
这是游戏内背包的代码,结合上面的信息可不可以出一个修改武器属性的这么一个事件指令,为了方便测试我们就修改武器属性中的血量就好了,你看看能不能做,就是修改它背包里面的装备的属性,这样就也相当于强化了