同步主站 Cocos 当前工程:关卡资源、运行脚本与打包工具。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,10 +5,12 @@
|
||||
* frontKey = -(cellX + cellY) * CELL // 更小 x+y → 屏幕更靠下 → 更靠前
|
||||
* + typeRank // 同对角条带内:地板 < 金币 < 载具 < 角色 < 墙
|
||||
*
|
||||
* 移动中采样拆开:
|
||||
* - 角色:朝前落点 / 朝后起点
|
||||
* - 载具:朝前起点(防浮到前砖上)/ 朝后落点(防途中比落点更靠前而不被下方砖挡)
|
||||
* 移动中:当前格与下一格的排序值按位移进度插值,落地后再钉新格。
|
||||
* 载具 rank 低于矮砖,墙砖仍更高所以能挡住载具。
|
||||
* 贴墙南/西立面格上的实体:抬到该墙之上(露脚)。
|
||||
* 角色按 frontKey 插入;漏到后面的矮砖补到角色下面,遇到该挡人的墙即停。
|
||||
* 砖与砖进关后冻结,走路不改。
|
||||
* 载具与矮砖仍按 frontKey,可被镜头方向的矮砖挡住。
|
||||
* 角色永远盖过同条带载具。
|
||||
*/
|
||||
|
||||
@@ -30,7 +32,6 @@ const CELL = 100;
|
||||
/** 同对角条带内层级:地板 < 金币 < 载具 < 角色 < 墙立面 */
|
||||
const RANK_FLOOR = 0;
|
||||
const RANK_PICKABLE = 20;
|
||||
const RANK_VEHICLE = 30;
|
||||
const RANK_PLAYER = 35;
|
||||
const RANK_WALL = 40;
|
||||
|
||||
@@ -42,6 +43,11 @@ export function isWalkableTileName(tileName: string): boolean {
|
||||
return tileName === CommonDefine.BlockBase || tileName === CommonDefine.BlockJump;
|
||||
}
|
||||
|
||||
/** 矮砖:仅 Baseblock / kuai11。不含 JumpBlock、墙砖 WallBlock。 */
|
||||
export function isShortFloorTile(tileName: string): boolean {
|
||||
return tileName === CommonDefine.BlockBase || tileName === 'kuai11';
|
||||
}
|
||||
|
||||
export function unityTileIndividualSortingOrder(cellX: number, cellY: number): number {
|
||||
return UNITY_SORTING_ORDER.tilemap - cellX - cellY;
|
||||
}
|
||||
@@ -107,7 +113,8 @@ function typeRankForTile(tileName: string): number {
|
||||
function typeRankForEntity(entity: UnitySortableEntity): number {
|
||||
if (entity.isPickable) return RANK_PICKABLE;
|
||||
if (entity.isPlayer) return RANK_PLAYER;
|
||||
return RANK_VEHICLE;
|
||||
// 载具始终低于矮砖:墙 RANK_WALL 仍更高所以能挡住;移动中若用落点+载具 rank 会漏到矮砖上面
|
||||
return RANK_FLOOR - 1;
|
||||
}
|
||||
|
||||
/** 越大越靠前(后绘制) */
|
||||
@@ -132,7 +139,7 @@ export function entityFaceLiftOverWall(
|
||||
tile: UnitySortableTile,
|
||||
): number | null {
|
||||
if (!isWallBlockTileName(tile.tileName)) return null;
|
||||
const cell = { x: entity.cellX, y: entity.cellY };
|
||||
const cell = { x: Math.round(entity.cellX), y: Math.round(entity.cellY) };
|
||||
for (const face of wallFaceSamples(tile.cellX, tile.cellY)) {
|
||||
if (face.x === cell.x && face.y === cell.y) {
|
||||
return tileDrawFrontKey(tile);
|
||||
@@ -169,15 +176,14 @@ export function compareUnityEntityToEntity(a: UnitySortableEntity, b: UnitySorta
|
||||
}
|
||||
|
||||
/**
|
||||
* 实体 vs 砖:统一用 frontKey。
|
||||
* (保留函数供外部/测试调用;排序主路径用 build 里的 key)
|
||||
* 实体 vs 砖:载具仍用 frontKey(镜头方向的矮砖可以挡住载具)。
|
||||
* 角色对矮砖(Baseblock / kuai11)永远在上;墙砖仍按 frontKey / 贴墙抬升。
|
||||
*/
|
||||
export function compareUnityEntityToTile(
|
||||
entity: UnitySortableEntity,
|
||||
tile: UnitySortableTile,
|
||||
): number {
|
||||
if (!isWallBlockTileName(tile.tileName)) {
|
||||
// 地板永在实体下
|
||||
if (entity.isPlayer && isShortFloorTile(tile.tileName)) {
|
||||
return 1;
|
||||
}
|
||||
const lift = entityFaceLiftOverWall(entity, tile);
|
||||
|
||||
Reference in New Issue
Block a user