|
@@ -2,6 +2,7 @@ import { _decorator, Component, Node, Button, Label, Sprite, SpriteFrame, Textur
|
|
|
import { SaveDataManager, WeaponData } from '../../LevelSystem/SaveDataManager';
|
|
import { SaveDataManager, WeaponData } from '../../LevelSystem/SaveDataManager';
|
|
|
import { TopBarController } from '../TopBarController';
|
|
import { TopBarController } from '../TopBarController';
|
|
|
import EventBus, { GameEvents } from '../../Core/EventBus';
|
|
import EventBus, { GameEvents } from '../../Core/EventBus';
|
|
|
|
|
+import { UpgradeAni } from './UpgradeAni';
|
|
|
|
|
|
|
|
const { ccclass, property } = _decorator;
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
|
@@ -56,6 +57,9 @@ export class UpgradeController extends Component {
|
|
|
@property(Prefab) lockedWeaponPrefab: Prefab = null; // Lock.prefab
|
|
@property(Prefab) lockedWeaponPrefab: Prefab = null; // Lock.prefab
|
|
|
@property(Prefab) unlockedWeaponPrefab: Prefab = null; // Unlock.prefab
|
|
@property(Prefab) unlockedWeaponPrefab: Prefab = null; // Unlock.prefab
|
|
|
|
|
|
|
|
|
|
+ // 动画控制器
|
|
|
|
|
+ @property(UpgradeAni) upgradeAni: UpgradeAni = null; // Canvas/UpgradeUI/UpgradePanel上的UpgradeAni组件
|
|
|
|
|
+
|
|
|
// 数据管理
|
|
// 数据管理
|
|
|
private saveDataManager: SaveDataManager = null;
|
|
private saveDataManager: SaveDataManager = null;
|
|
|
private weaponsConfig: { weapons: WeaponConfig[] } = null;
|
|
private weaponsConfig: { weapons: WeaponConfig[] } = null;
|
|
@@ -85,7 +89,13 @@ export class UpgradeController extends Component {
|
|
|
|
|
|
|
|
// 刷新UI
|
|
// 刷新UI
|
|
|
this.refreshWeaponList();
|
|
this.refreshWeaponList();
|
|
|
- this.upgradePanel.active = false;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 初始化升级面板状态
|
|
|
|
|
+ if (this.upgradeAni) {
|
|
|
|
|
+ this.upgradeAni.hidePanelImmediate();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.upgradePanel.active = false;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
console.log('[UpgradeController] 初始化完成');
|
|
console.log('[UpgradeController] 初始化完成');
|
|
|
}
|
|
}
|
|
@@ -384,7 +394,7 @@ export class UpgradeController extends Component {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 设置升级按钮 - Unlock.prefab中的Button节点
|
|
// 设置升级按钮 - Unlock.prefab中的Button节点
|
|
|
- const upgradeButton = weaponNode.getChildByName('Button')?.getComponent(Button);
|
|
|
|
|
|
|
+ const upgradeButton = weaponNode.getChildByName('Upgrade')?.getComponent(Button);
|
|
|
if (upgradeButton) {
|
|
if (upgradeButton) {
|
|
|
// 清除之前的事件监听
|
|
// 清除之前的事件监听
|
|
|
upgradeButton.node.off(Button.EventType.CLICK);
|
|
upgradeButton.node.off(Button.EventType.CLICK);
|
|
@@ -524,7 +534,7 @@ export class UpgradeController extends Component {
|
|
|
/**
|
|
/**
|
|
|
* 打开升级面板
|
|
* 打开升级面板
|
|
|
*/
|
|
*/
|
|
|
- private openUpgradePanel(weaponId: string) {
|
|
|
|
|
|
|
+ private async openUpgradePanel(weaponId: string) {
|
|
|
const weaponConfig = this.weaponsConfig.weapons.find(config => config.id === weaponId);
|
|
const weaponConfig = this.weaponsConfig.weapons.find(config => config.id === weaponId);
|
|
|
if (!weaponConfig) {
|
|
if (!weaponConfig) {
|
|
|
console.error(`未找到武器配置: ${weaponId}`);
|
|
console.error(`未找到武器配置: ${weaponId}`);
|
|
@@ -541,16 +551,29 @@ export class UpgradeController extends Component {
|
|
|
|
|
|
|
|
console.log(`打开升级面板: ${weaponConfig.name}, 当前等级: ${weaponData.level}`);
|
|
console.log(`打开升级面板: ${weaponConfig.name}, 当前等级: ${weaponData.level}`);
|
|
|
|
|
|
|
|
- // 显示升级面板
|
|
|
|
|
- this.upgradePanel.active = true;
|
|
|
|
|
|
|
+ // 刷新面板内容
|
|
|
this.refreshUpgradePanel();
|
|
this.refreshUpgradePanel();
|
|
|
|
|
+
|
|
|
|
|
+ // 使用动画显示升级面板
|
|
|
|
|
+ if (this.upgradeAni) {
|
|
|
|
|
+ await this.upgradeAni.showPanel();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 如果没有动画组件,直接显示
|
|
|
|
|
+ this.upgradePanel.active = true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 关闭升级面板
|
|
* 关闭升级面板
|
|
|
*/
|
|
*/
|
|
|
- private closeUpgradePanel() {
|
|
|
|
|
- this.upgradePanel.active = false;
|
|
|
|
|
|
|
+ private async closeUpgradePanel() {
|
|
|
|
|
+ // 使用动画隐藏升级面板
|
|
|
|
|
+ if (this.upgradeAni) {
|
|
|
|
|
+ await this.upgradeAni.hidePanel();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 如果没有动画组件,直接隐藏
|
|
|
|
|
+ this.upgradePanel.active = false;
|
|
|
|
|
+ }
|
|
|
this.currentSelectedWeapon = null;
|
|
this.currentSelectedWeapon = null;
|
|
|
}
|
|
}
|
|
|
|
|
|