181404010226 4 сар өмнө
parent
commit
9bbc817a53

+ 0 - 177
Pellet白色尾迹实现说明.md

@@ -1,177 +0,0 @@
-# Pellet子弹白色尾迹实现说明
-
-## 概述
-
-本文档说明了如何为 `Pellet.prefab` 预制体添加白色尾迹效果的完整实现方案。通过粒子系统和自定义控制脚本,实现了动态的白色尾迹效果。
-
-## 实现方案
-
-### 1. 预制体结构修改
-
-**文件**: `d:\CocosGame\Pong\assets\assets\Prefabs\Pellet.prefab`
-
-- 在原有的 `ParticleSystem` 子节点中添加了完整的 `ParticleSystem2D` 组件配置
-- 配置了白色尾迹的粒子效果参数:
-  - 起始颜色:白色 (255, 255, 255, 255)
-  - 结束颜色:透明白色 (255, 255, 255, 0)
-  - 粒子生命周期:0.8秒
-  - 发射速度:80像素/秒
-  - 粒子大小:从8像素渐变到2像素
-
-### 2. 尾迹控制器脚本
-
-**文件**: `d:\CocosGame\Pong\assets\scripts\Animations\PelletTrailController.ts`
-
-**功能特性**:
-- 自动检测子弹移动方向并调整粒子发射角度
-- 根据子弹速度动态调整粒子发射率和速度
-- 提供颜色自定义接口
-- 支持启用/禁用尾迹效果
-
-**主要方法**:
-```typescript
-// 设置尾迹颜色
-setTrailColor(r: number, g: number, b: number, a: number = 255)
-
-// 启用/禁用尾迹效果
-setTrailEnabled(enabled: boolean)
-```
-
-### 3. 集成到现有子弹系统
-
-**文件**: `d:\CocosGame\Pong\assets\scripts\CombatSystem\WeaponBullet.ts`
-
-**修改内容**:
-- 导入 `PelletTrailController` 类
-- 在子弹初始化时自动添加尾迹控制器组件
-- 默认设置为白色尾迹效果
-
-**集成代码**:
-```typescript
-// 初始化尾迹控制器
-this.pelletTrailController = this.getComponent(PelletTrailController) || this.addComponent(PelletTrailController);
-// 设置白色尾迹
-this.pelletTrailController.setTrailColor(255, 255, 255, 255);
-this.pelletTrailController.setTrailEnabled(true);
-```
-
-### 4. 测试脚本
-
-**文件**: `d:\CocosGame\Pong\assets\scripts\TestScene\TestPelletTrail.ts`
-
-**功能**:
-- 每2秒自动发射一颗测试子弹
-- 验证白色尾迹效果是否正常工作
-- 提供手动测试接口
-
-## 使用方法
-
-### 自动应用(推荐)
-
-所有通过 `WeaponBullet` 系统创建的子弹都会自动应用白色尾迹效果,无需额外配置。
-
-### 手动控制
-
-如果需要自定义尾迹效果,可以获取 `PelletTrailController` 组件进行配置:
-
-```typescript
-const trailController = bulletNode.getComponent(PelletTrailController);
-if (trailController) {
-    // 设置红色尾迹
-    trailController.setTrailColor(255, 0, 0, 255);
-    
-    // 禁用尾迹
-    trailController.setTrailEnabled(false);
-}
-```
-
-### 测试验证
-
-1. 将 `TestPelletTrail` 脚本添加到场景中的任意节点
-2. 运行游戏,观察是否有带白色尾迹的测试子弹发射
-3. 或者在编辑器中调用 `fireTestBulletManual()` 方法手动测试
-
-## 技术细节
-
-### 粒子系统配置
-
-- **发射模式**: 重力模式 (emitterMode: 0)
-- **位置类型**: 相对位置 (positionType: 1)
-- **粒子总数**: 50个
-- **发射率**: 30个/秒(动态调整)
-- **角度**: 根据子弹移动方向动态计算
-
-### 性能优化
-
-- 粒子数量限制在50个以内
-- 子弹静止时自动停止粒子发射
-- 使用相对位置模式减少计算开销
-
-### 兼容性
-
-- 完全兼容现有的 `WeaponBullet` 系统
-- 不影响子弹的物理行为和碰撞检测
-- 支持所有类型的武器和子弹配置
-
-## 故障排除
-
-### 尾迹不显示
-
-1. 检查 `ParticleSystem2D` 组件是否正确配置
-2. 确认 `PelletTrailController` 组件已添加到子弹节点
-3. 验证粒子系统的 `enabled` 属性为 `true`
-
-### 尾迹方向错误
-
-1. 检查子弹的 `RigidBody2D` 组件是否正常工作
-2. 确认子弹有实际的移动速度
-3. 验证 `updateParticleDirection` 方法的角度计算
-
-### 性能问题
-
-1. 减少 `totalParticles` 数量
-2. 降低 `emissionRate` 发射率
-3. 缩短粒子 `life` 生命周期
-
-## 扩展功能
-
-### 多色尾迹
-
-可以根据子弹类型或武器等级设置不同颜色的尾迹:
-
-```typescript
-// 根据武器类型设置尾迹颜色
-switch (weaponType) {
-    case 'fire':
-        trailController.setTrailColor(255, 100, 0, 255); // 橙色
-        break;
-    case 'ice':
-        trailController.setTrailColor(100, 200, 255, 255); // 蓝色
-        break;
-    default:
-        trailController.setTrailColor(255, 255, 255, 255); // 白色
-}
-```
-
-### 动态尾迹强度
-
-根据子弹伤害或速度调整尾迹的强度:
-
-```typescript
-// 根据子弹速度调整尾迹强度
-const speed = velocity.length();
-const intensity = Math.min(1, speed / 200); // 最大速度200时达到满强度
-trailController.setTrailColor(255, 255, 255, 255 * intensity);
-```
-
-## 总结
-
-通过以上实现,成功为 `Pellet.prefab` 添加了白色尾迹效果。该方案具有以下优势:
-
-1. **自动化**: 所有子弹自动应用尾迹效果
-2. **可定制**: 支持颜色和强度的自定义
-3. **高性能**: 优化的粒子系统配置
-4. **兼容性**: 完全兼容现有系统
-5. **可扩展**: 易于添加新的视觉效果
-
-该实现为游戏的视觉效果提升奠定了良好的基础,可以根据需要进一步扩展和优化。

+ 2 - 2
assets/Scenes/GameLevel.scene

@@ -10165,7 +10165,7 @@
         "__id__": 292
       }
     ],
-    "_active": true,
+    "_active": false,
     "_components": [
       {
         "__id__": 319
@@ -16142,7 +16142,7 @@
       "a": 255
     },
     "_spriteFrame": {
-      "__uuid__": "5944b4e8-375d-482d-9aa4-08a85b75d9b7@f9941",
+      "__uuid__": "73c48f15-e6b2-4b0d-811a-57fac7fd8583@f9941",
       "__expectedType__": "cc.SpriteFrame"
     },
     "_type": 0,

+ 7 - 95
assets/assets/Prefabs/Pellet.prefab

@@ -82,9 +82,6 @@
     "_components": [
       {
         "__id__": 3
-      },
-      {
-        "__id__": 4
       }
     ],
     "_prefab": {
@@ -119,97 +116,6 @@
     },
     "_id": ""
   },
-  {
-    "__type__": "cc.ParticleSystem2D",
-    "_name": "",
-    "_objFlags": 0,
-    "__editorExtras__": {},
-    "node": {
-      "__id__": 2
-    },
-    "_enabled": true,
-    "__prefab": null,
-    "_custom": true,
-    "_file": null,
-    "_spriteFrame": null,
-    "_totalParticles": 50,
-    "_duration": -1,
-    "_emissionRate": 30,
-    "_life": 0.8,
-    "_lifeVar": 0.2,
-    "_startColor": {
-      "__type__": "cc.Color",
-      "r": 255,
-      "g": 255,
-      "b": 255,
-      "a": 255
-    },
-    "_startColorVar": {
-      "__type__": "cc.Color",
-      "r": 0,
-      "g": 0,
-      "b": 0,
-      "a": 0
-    },
-    "_endColor": {
-      "__type__": "cc.Color",
-      "r": 255,
-      "g": 255,
-      "b": 255,
-      "a": 0
-    },
-    "_endColorVar": {
-      "__type__": "cc.Color",
-      "r": 0,
-      "g": 0,
-      "b": 0,
-      "a": 0
-    },
-    "_angle": 180,
-    "_angleVar": 10,
-    "_startSize": 8,
-    "_startSizeVar": 2,
-    "_endSize": 2,
-    "_endSizeVar": 1,
-    "_startSpin": 0,
-    "_startSpinVar": 0,
-    "_endSpin": 0,
-    "_endSpinVar": 0,
-    "_sourcePos": {
-      "__type__": "cc.Vec2",
-      "x": 0,
-      "y": 0
-    },
-    "_posVar": {
-      "__type__": "cc.Vec2",
-      "x": 2,
-      "y": 2
-    },
-    "_positionType": 1,
-    "_emitterMode": 0,
-    "_gravity": {
-      "__type__": "cc.Vec2",
-      "x": 0,
-      "y": 0
-    },
-    "_speed": 80,
-    "_speedVar": 20,
-    "_tangentialAccel": 0,
-    "_tangentialAccelVar": 0,
-    "_radialAccel": 0,
-    "_radialAccelVar": 0,
-    "_rotationIsDir": false,
-    "_startRadius": 0,
-    "_startRadiusVar": 0,
-    "_endRadius": 0,
-    "_endRadiusVar": 0,
-    "_rotatePerS": 0,
-    "_rotatePerSVar": 0,
-    "_N$preview": true,
-    "playOnLoad": true,
-    "autoRemoveOnFinish": false,
-    "_id": ""
-  },
   {
     "__type__": "cc.UITransform",
     "_name": "",
@@ -219,7 +125,9 @@
       "__id__": 2
     },
     "_enabled": true,
-    "__prefab": null,
+    "__prefab": {
+      "__id__": 4
+    },
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 100,
@@ -232,6 +140,10 @@
     },
     "_id": ""
   },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "0aN40gSsxAVbvdTd83wVdT"
+  },
   {
     "__type__": "cc.PrefabInfo",
     "root": {

+ 2 - 2
assets/resources/data/excel/config_manager.py

@@ -1010,7 +1010,7 @@ class ConfigManagerGUI:
                     'description': str(basic_row['描述']) if pd.notna(basic_row['描述']) else '',
                     'backgroundImage': str(basic_row['关卡背景图路径']) if pd.notna(basic_row['关卡背景图路径']) else 'images/LevelBackground/BG1',
                     'availableWeapons': available_weapons,
-                    'coinReward': int(basic_row['金币奖励']) if pd.notna(basic_row['金币奖励']) else 100,
+                    'coinReward': int(basic_row['钞票奖励']) if pd.notna(basic_row['钞票奖励']) else 100,
                     'diamondReward': int(basic_row['钻石奖励']) if pd.notna(basic_row['钻石奖励']) else 0,
                     'timeLimit': 300,  # 默认值
                     'difficulty': 'normal',  # 默认值
@@ -3142,7 +3142,7 @@ class ConfigManagerGUI:
             }
             
             # 添加可选字段(如果存在,支持中英文字段名)
-            coin_reward = item.get('coinReward', item.get('金币奖励'))
+            coin_reward = item.get('coinReward', item.get('钞票奖励'))
             if coin_reward is not None:
                 level_data["coinReward"] = int(coin_reward)
             elif 'coinReward' in existing_data:

BIN
assets/resources/images/UI/主界面/bg.jpg


+ 134 - 0
assets/resources/images/UI/主界面/bg.jpg.meta

@@ -0,0 +1,134 @@
+{
+  "ver": "1.0.27",
+  "importer": "image",
+  "imported": true,
+  "uuid": "73c48f15-e6b2-4b0d-811a-57fac7fd8583",
+  "files": [
+    ".jpg",
+    ".json"
+  ],
+  "subMetas": {
+    "6c48a": {
+      "importer": "texture",
+      "uuid": "73c48f15-e6b2-4b0d-811a-57fac7fd8583@6c48a",
+      "displayName": "bg",
+      "id": "6c48a",
+      "name": "texture",
+      "userData": {
+        "wrapModeS": "clamp-to-edge",
+        "wrapModeT": "clamp-to-edge",
+        "imageUuidOrDatabaseUri": "73c48f15-e6b2-4b0d-811a-57fac7fd8583",
+        "isUuid": true,
+        "visible": false,
+        "minfilter": "linear",
+        "magfilter": "linear",
+        "mipfilter": "none",
+        "anisotropy": 0
+      },
+      "ver": "1.0.22",
+      "imported": true,
+      "files": [
+        ".json"
+      ],
+      "subMetas": {}
+    },
+    "f9941": {
+      "importer": "sprite-frame",
+      "uuid": "73c48f15-e6b2-4b0d-811a-57fac7fd8583@f9941",
+      "displayName": "bg",
+      "id": "f9941",
+      "name": "spriteFrame",
+      "userData": {
+        "trimThreshold": 1,
+        "rotated": false,
+        "offsetX": 0,
+        "offsetY": 0,
+        "trimX": 0,
+        "trimY": 0,
+        "width": 720,
+        "height": 1334,
+        "rawWidth": 720,
+        "rawHeight": 1334,
+        "borderTop": 0,
+        "borderBottom": 0,
+        "borderLeft": 0,
+        "borderRight": 0,
+        "packable": true,
+        "pixelsToUnit": 100,
+        "pivotX": 0.5,
+        "pivotY": 0.5,
+        "meshType": 0,
+        "vertices": {
+          "rawPosition": [
+            -360,
+            -667,
+            0,
+            360,
+            -667,
+            0,
+            -360,
+            667,
+            0,
+            360,
+            667,
+            0
+          ],
+          "indexes": [
+            0,
+            1,
+            2,
+            2,
+            1,
+            3
+          ],
+          "uv": [
+            0,
+            1334,
+            720,
+            1334,
+            0,
+            0,
+            720,
+            0
+          ],
+          "nuv": [
+            0,
+            0,
+            1,
+            0,
+            0,
+            1,
+            1,
+            1
+          ],
+          "minPos": [
+            -360,
+            -667,
+            0
+          ],
+          "maxPos": [
+            360,
+            667,
+            0
+          ]
+        },
+        "isUuid": true,
+        "imageUuidOrDatabaseUri": "73c48f15-e6b2-4b0d-811a-57fac7fd8583@6c48a",
+        "atlasUuid": "",
+        "trimType": "auto"
+      },
+      "ver": "1.0.12",
+      "imported": true,
+      "files": [
+        ".json"
+      ],
+      "subMetas": {}
+    }
+  },
+  "userData": {
+    "type": "sprite-frame",
+    "hasAlpha": false,
+    "fixAlphaTransparencyArtifacts": false,
+    "redirect": "73c48f15-e6b2-4b0d-811a-57fac7fd8583@6c48a"
+  }
+}

+ 0 - 101
assets/scripts/Animations/PelletTrailController.ts

@@ -1,101 +0,0 @@
-import { _decorator, Component, Node, ParticleSystem2D, Vec2, RigidBody2D } from 'cc';
-const { ccclass, property } = _decorator;
-
-/**
- * 子弹尾迹控制器
- * 控制子弹的粒子系统尾迹效果
- */
-@ccclass('PelletTrailController')
-export class PelletTrailController extends Component {
-    @property(ParticleSystem2D)
-    particleSystem: ParticleSystem2D = null;
-    
-    @property(RigidBody2D)
-    rigidBody: RigidBody2D = null;
-    
-    private lastVelocity: Vec2 = new Vec2();
-    
-    onLoad() {
-        // 自动获取组件引用
-        if (!this.particleSystem) {
-            this.particleSystem = this.node.getComponentInChildren(ParticleSystem2D);
-        }
-        if (!this.rigidBody) {
-            this.rigidBody = this.node.getComponent(RigidBody2D);
-        }
-    }
-    
-    start() {
-        // 启动粒子系统
-        if (this.particleSystem) {
-            this.particleSystem.resetSystem();
-        }
-    }
-    
-    update(deltaTime: number) {
-        if (!this.particleSystem || !this.rigidBody) return;
-        
-        // 获取当前速度
-        const velocity = this.rigidBody.linearVelocity;
-        
-        // 如果速度发生变化,更新粒子发射角度
-        if (!velocity.equals(this.lastVelocity)) {
-            this.updateParticleDirection(velocity);
-            this.lastVelocity.set(velocity);
-        }
-        
-        // 根据速度调整粒子发射率
-        const speed = velocity.length();
-        if (speed > 0) {
-            // 速度越快,尾迹越明显
-            this.particleSystem.emissionRate = Math.max(20, speed * 0.5);
-            this.particleSystem.enabled = true;
-        } else {
-            // 静止时停止发射粒子
-            this.particleSystem.enabled = false;
-        }
-    }
-    
-    /**
-     * 根据子弹移动方向更新粒子发射方向
-     * @param velocity 子弹速度向量
-     */
-    private updateParticleDirection(velocity: Vec2) {
-        if (velocity.length() === 0) return;
-        
-        // 计算速度方向角度(弧度转角度)
-        const angle = Math.atan2(velocity.y, velocity.x) * 180 / Math.PI;
-        
-        // 粒子向相反方向发射,形成尾迹效果
-        this.particleSystem.angle = angle + 180;
-        
-        // 根据速度调整粒子初始速度
-        const speed = velocity.length();
-        this.particleSystem.speed = Math.min(100, speed * 0.8);
-        this.particleSystem.speedVar = Math.min(30, speed * 0.2);
-    }
-    
-    /**
-     * 设置尾迹颜色
-     * @param color 颜色值 (0-255)
-     */
-    public setTrailColor(r: number, g: number, b: number, a: number = 255) {
-        if (!this.particleSystem) return;
-        
-        this.particleSystem.startColor.set(r, g, b, a);
-        // 结束颜色保持透明
-        this.particleSystem.endColor.set(r, g, b, 0);
-    }
-    
-    /**
-     * 启用/禁用尾迹效果
-     */
-    public setTrailEnabled(enabled: boolean) {
-        if (this.particleSystem) {
-            this.particleSystem.enabled = enabled;
-            if (enabled) {
-                this.particleSystem.resetSystem();
-            }
-        }
-    }
-}

+ 0 - 8
assets/scripts/CombatSystem/WeaponBullet.ts

@@ -7,7 +7,6 @@ import { ConfigManager, WeaponConfig, BulletCountConfig, BulletTrajectoryConfig,
 import  EventBus,{ GameEvents } from '../Core/EventBus';
 import { PersistentSkillManager } from '../FourUI/SkillSystem/PersistentSkillManager';
 import { SaveDataManager } from '../LevelSystem/SaveDataManager';
-import { PelletTrailController } from '../Animations/PelletTrailController';
 
 const { ccclass, property } = _decorator;
 
@@ -43,7 +42,6 @@ export class WeaponBullet extends Component {
     private bulletTrajectory: BulletTrajectory = null;
     private bulletHitEffect: BulletHitEffect = null;
     private bulletLifecycle: BulletLifecycle = null;
-    private pelletTrailController: PelletTrailController = null;
     
     // 武器配置和状态
     private weaponConfig: WeaponConfig = null;
@@ -306,12 +304,6 @@ export class WeaponBullet extends Component {
         this.bulletLifecycle = this.getComponent(BulletLifecycle) || this.addComponent(BulletLifecycle);
         this.bulletLifecycle.init(config.lifecycle, initData.firePosition);
         
-        // 初始化尾迹控制器
-        this.pelletTrailController = this.getComponent(PelletTrailController) || this.addComponent(PelletTrailController);
-        // 设置白色尾迹
-        this.pelletTrailController.setTrailColor(255, 255, 255, 255);
-        this.pelletTrailController.setTrailEnabled(true);
-        
         // 设置碰撞监听
         this.setupCollisionListener();
         

+ 0 - 80
assets/scripts/TestScene/TestPelletTrail.ts

@@ -1,80 +0,0 @@
-import { _decorator, Component, Node, Vec3, find, instantiate, Prefab, resources } from 'cc';
-import { WeaponBullet, BulletInitData } from '../CombatSystem/WeaponBullet';
-
-const { ccclass, property } = _decorator;
-
-/**
- * 测试子弹尾迹效果的脚本
- */
-@ccclass('TestPelletTrail')
-export class TestPelletTrail extends Component {
-    
-    @property(Prefab)
-    pelletPrefab: Prefab = null;
-    
-    private testInterval: number = 2; // 每2秒发射一次测试子弹
-    private timer: number = 0;
-    
-    start() {
-        // 如果没有设置预制体,尝试从resources加载
-        if (!this.pelletPrefab) {
-            this.loadPelletPrefab();
-        }
-    }
-    
-    update(deltaTime: number) {
-        this.timer += deltaTime;
-        
-        if (this.timer >= this.testInterval && this.pelletPrefab) {
-            this.timer = 0;
-            this.fireTestBullet();
-        }
-    }
-    
-    private loadPelletPrefab() {
-        resources.load('prefabs/Pellet', Prefab, (err, prefab) => {
-            if (!err && prefab) {
-                this.pelletPrefab = prefab;
-                console.log('[TestPelletTrail] Pellet预制体加载成功');
-            } else {
-                console.warn('[TestPelletTrail] 无法加载Pellet预制体:', err);
-            }
-        });
-    }
-    
-    private fireTestBullet() {
-        if (!this.pelletPrefab) return;
-        
-        // 创建测试子弹初始化数据
-        const initData: BulletInitData = {
-            weaponId: 'pea_shooter', // 使用默认武器配置
-            firePosition: new Vec3(0, 0, 0), // 从屏幕中心发射
-            direction: new Vec3(1, 0.5, 0).normalize(), // 向右上方发射
-            autoTarget: false
-        };
-        
-        // 创建子弹实例
-        const bulletNode = instantiate(this.pelletPrefab);
-        
-        // 添加到场景中
-        const gameArea = find('Canvas/GameLevelUI/GameArea') || find('Canvas');
-        if (gameArea) {
-            gameArea.addChild(bulletNode);
-        } else {
-            this.node.addChild(bulletNode);
-        }
-        
-        // 初始化子弹
-        const weaponBullet = bulletNode.getComponent(WeaponBullet) || bulletNode.addComponent(WeaponBullet);
-        weaponBullet.init(initData);
-        
-        console.log('[TestPelletTrail] 发射测试子弹,带白色尾迹效果');
-    }
-    
-    /**
-     * 手动触发测试子弹发射(可在编辑器中调用)
-     */
-    public fireTestBulletManual() {
-        this.fireTestBullet();
-    }
-}