| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- import { _decorator, Component, log } from 'cc';
- import { ConfigManager } from '../Core/ConfigManager';
- const { ccclass, property } = _decorator;
- /**
- * 敌人配置测试组件
- * 用于验证敌人配置加载功能
- */
- @ccclass('EnemyConfigTest')
- export class EnemyConfigTest extends Component {
- async start() {
- // 等待一段时间确保ConfigManager初始化完成
- setTimeout(() => {
- this.testEnemyConfig();
- }, 3000);
- }
- private testEnemyConfig() {
- console.log('=== 敌人配置测试开始 ===');
-
- const configManager = ConfigManager.getInstance();
-
- // 检查配置是否已加载
- if (!configManager.isConfigLoaded()) {
- console.error('❌ ConfigManager配置尚未加载完成');
- return;
- }
-
- // 获取所有敌人配置
- const enemies = configManager.getAllEnemies();
-
- if (enemies && enemies.length > 0) {
- console.log(`✅ 敌人配置加载成功,共 ${enemies.length} 个敌人`);
-
- // 测试特定敌人ID
- const testEnemyIds = ['normal_zombie', 'roadblock_zombie', 'mage_zombie', 'boss1_gatekeeper'];
-
- testEnemyIds.forEach(enemyId => {
- const enemy = configManager.getEnemyById(enemyId);
- if (enemy) {
- console.log(`✅ 找到敌人: ${enemyId} - ${enemy.name}`);
- } else {
- console.error(`❌ 未找到敌人: ${enemyId}`);
- }
- });
-
- // 打印前5个敌人的基本信息
- console.log('前5个敌人信息:');
- enemies.slice(0, 5).forEach((enemy, index) => {
- console.log(`${index + 1}. ID: ${enemy.id}, 名称: ${enemy.name}, 类型: ${enemy.type}`);
- });
-
- } else {
- console.error('❌ 敌人配置为空或加载失败');
- }
-
- console.log('=== 敌人配置测试结束 ===');
- }
-
- /**
- * 手动测试方法,可以在Inspector中调用
- */
- public manualTest() {
- this.testEnemyConfig();
- }
- }
|