mirror of
http://junepve.top:3000/chicrobot/CINC.git
synced 2026-10-30 07:41:29 +08:00
fix(scenes) 种田系统测试,添加按钮等
This commit is contained in:
1 parent
ce4e04740a
commit
761a9338ba
19 files changed
+1248
-86
No files matched your search
+17
-11
@@ -150,13 +150,21 @@ export default class Item extends Phaser.GameObjects.Sprite {
|
||||
* @param {Object} user - 使用物品的单位
|
||||
*/
|
||||
useFromInventory(user) {
|
||||
// 从用户对象中获取场景引用
|
||||
if (user && user.scene) {
|
||||
this.scene = user.scene;
|
||||
}
|
||||
// 使用物品
|
||||
this.use(user);
|
||||
|
||||
// 从背包中移除物品
|
||||
if (user.inventory) {
|
||||
user.inventory.removeItem(this.id);
|
||||
}
|
||||
// 注意:物品的具体使用方法(如useSeed)中已经处理了从背包移除的逻辑
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置物品的场景引用
|
||||
* @param {Object} scene - 场景对象
|
||||
*/
|
||||
setScene(scene) {
|
||||
this.scene = scene;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,16 +218,14 @@ export default class Item extends Phaser.GameObjects.Sprite {
|
||||
console.log('DEBUG: 触发 plant-seed 事件');
|
||||
this.scene.events.emit('plant-seed', this, user);
|
||||
|
||||
// 从背包中移除种子
|
||||
if (user.inventory) {
|
||||
console.log(`DEBUG: 从背包中移除种子 ${this.id}`);
|
||||
user.inventory.removeItem(this.id);
|
||||
}
|
||||
// 注意:不立即从背包中移除种子,而是在实际种植时移除
|
||||
// 这样用户可以取消种植而不会失去种子
|
||||
|
||||
// 显示种植提示
|
||||
this.scene.events.emit('show-message', `准备种植 ${this.name}`);
|
||||
} else {
|
||||
console.log('DEBUG: 种子不可种植');
|
||||
console.log(`DEBUG: ${this.name} 不可种植`);
|
||||
this.scene.events.emit('show-message', `${this.name} 不可种植`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user