同步主站 Cocos 当前工程:关卡资源、运行脚本与打包工具。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-12 14:40:34 +08:00
parent ae75fce80b
commit fac515a669
5609 changed files with 27744634 additions and 5653 deletions

View File

@@ -233,20 +233,27 @@ export class PlayerController extends Movement {
private onLevelInit = () => {
this.sendFinally = false;
this.coins = 0;
this.animator?.flushCycleWaiters();
this.resetMoveRuntime();
this.unbindVehicle();
this.refreshVisual(PlayerAction.Idle);
this.syncCommittedCellFromPosition();
this.snapMoverToCellStand();
this.resetToSpawn();
this.checkIfCurIsRide();
tryLinkPlayerVehicle(this);
};
private onInputEnd = () => {
const gm = GameManager.instance!;
this.externalCallResult(gm.allPropsCollected());
void this.settleInputEnd();
};
/** 等当前这一步落地并拾取后再判胜负,避免最后一格刚起步就失败 */
private async settleInputEnd() {
await this.waitUntilIdle();
const gm = GameManager.instance;
if (!gm || gm.gameState !== GameState.Run) return;
this.externalCallResult(gm.allPropsCollected());
}
protected override snapMoverToCellStand() {
const gm = GameManager.instance;
if (!gm || !this.committedCell) return;
@@ -357,14 +364,19 @@ export class PlayerController extends Movement {
if (isJump && this.targetGridType === GridType.Jump && this.vehicle) {
this.unbindVehicle();
}
this.animator?.setAction(isJump ? PlayerAction.Jump : PlayerAction.Move);
const next = isJump ? PlayerAction.Jump : PlayerAction.Move;
const keepCycle = this.animator?.getAction() === next;
this.animator?.setAction(next);
if (keepCycle) this.animator?.beginCycle();
if (isJump && this.targetGridType === GridType.Jump) {
this.targetPosition.y += scaledJumpArcOffset();
}
}
protected override playMoveAnim() {
const keepCycle = this.animator?.getAction() === PlayerAction.Move;
this.animator?.setAction(PlayerAction.Move);
if (keepCycle) this.animator?.beginCycle();
}
protected override syncRideAfterMoveStep() {
@@ -381,9 +393,7 @@ export class PlayerController extends Movement {
if (!this.sfxSource) return;
const action = this.animator?.getAction() ?? PlayerAction.Idle;
if (action === PlayerAction.Move) {
const key = vehicleFollowsLandingTile(this.targetGridType) && this.vehicle
? 'vehicleMove' : 'move';
void GameAudio.playSfxOnSource(this.sfxSource, key);
void GameAudio.playSfxOnSource(this.sfxSource, 'move');
} else if (action === PlayerAction.Jump) {
void GameAudio.playSfxOnSource(this.sfxSource, 'jump');
}
@@ -514,11 +524,15 @@ export class PlayerController extends Movement {
if (!gm) return;
if (gm.gameState === GameState.ResultWin) {
this.animator?.setAction(PlayerAction.Win);
} else if (gm.gameState === GameState.ResultFail) {
this.animator?.setAction(PlayerAction.Fail);
} else {
this.animator?.setAction(PlayerAction.Idle);
return;
}
if (gm.gameState === GameState.ResultFail) {
this.animator?.setAction(PlayerAction.Fail);
return;
}
// CallMove(n) 尚未走完:保持当前 Move/Jump避免每格切 Idle 重播第 0 帧
if (this.step > 0) return;
this.animator?.setAction(PlayerAction.Idle);
}
callPlayerInfo() {
@@ -561,12 +575,23 @@ export class PlayerController extends Movement {
externalCall() {
const gm = GameManager.instance!;
const list: ExternalDataList = { direction: this.direction, externalDatas: [] };
const sample = this.getGridSamplePosition();
const self = gm.worldToCell(sample);
this.emitProcessData(gm.worldToCell(sample), this.curGrid, sample);
}
/** 按指定逻辑格回传(提前 processData 时用落点,而不是当前脚底) */
private externalCallAtCell(cell: Vec3) {
const gm = GameManager.instance!;
const sample = cellToWorldCenter(cell);
this.emitProcessData(cell, gm.calculateGridTypeAtCell(cell), sample);
}
private emitProcessData(selfCell: Vec3, selfGrid: GridType, sample: Vec3) {
const gm = GameManager.instance!;
const list: ExternalDataList = { direction: this.direction, externalDatas: [] };
list.externalDatas.push({
position: { x: self.x, y: self.y, z: 0 },
gridType: this.curGrid,
position: { x: selfCell.x, y: selfCell.y, z: 0 },
gridType: selfGrid,
direction: 'self',
});
for (let d = Direction.North; d <= Direction.West; d++) {