feat(FTS) 新增种田系统

This commit is contained in:
chicrobot committed 2026-01-09 18:58:23 +08:00
1 parent f6874d1ee9
commit ce4e04740a
8 files changed
+933 -2

No files matched your search

+29
View File
@@ -189,11 +189,40 @@ export default class Item extends Phaser.GameObjects.Sprite {
case 'weapon':
this.equipWeapon(user);
break;
case 'seed':
this.useSeed(user);
break;
default:
console.log(`无法使用物品:${this.name}`);
}
}
/**
* 使用种子物品
* @param {Object} user - 使用物品的单位
*/
useSeed(user) {
console.log('DEBUG: useSeed 方法被调用');
if (this.properties.plantable) {
console.log(`DEBUG: ${user.name} 准备种植 ${this.name}`);
// 触发种植事件,让场景处理具体的种植逻辑
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: 种子不可种植');
}
}
/**
* 使用食物物品
* @param {Object} user - 使用物品的单位