mirror of
http://junepve.top:3000/chicrobot/CINC.git
synced 2026-10-30 01:41:29 +08:00
feat(control) 多角色控制
This commit is contained in:
1 parent
be5ee91328
commit
f86e5f3a79
11 files changed
+431
No files matched your search
@@ -0,0 +1,31 @@
|
||||
// systems/CommandSystem.js
|
||||
import { activeUnit, selectedUnits } from './ControlMode.js';
|
||||
|
||||
export class CommandSystem {
|
||||
constructor(scene) {
|
||||
this.scene = scene;
|
||||
|
||||
scene.events.on('move-relative', this.onMoveRelative, this);
|
||||
scene.events.on('move-to-point', this.onMoveToPoint, this);
|
||||
scene.events.on('select-unit', this.onSelectUnit, this);
|
||||
}
|
||||
|
||||
onMoveRelative(dir) {
|
||||
if (activeUnit) {
|
||||
activeUnit.moveRelative(dir.x, dir.y);
|
||||
}
|
||||
}
|
||||
|
||||
onMoveToPoint(x, y) {
|
||||
const targets = selectedUnits.length > 0 ? selectedUnits : (activeUnit ? [activeUnit] : []);
|
||||
targets.forEach(unit => unit.moveTo(x, y));
|
||||
}
|
||||
|
||||
onSelectUnit(unit) {
|
||||
// 切换单位
|
||||
import('./ControlMode.js').then(mod => {
|
||||
mod.setActiveUnit(unit);
|
||||
this.scene.events.emit('unit-activated', unit);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user