102 lines
3.5 KiB
TypeScript
102 lines
3.5 KiB
TypeScript
/**
|
|
* Project-wide constants. This module is platform-agnostic and MUST NOT import
|
|
* from `cc` so that it can be unit-tested under Jest.
|
|
*
|
|
* All numeric values are defined against the landscape baseline design
|
|
* resolution 960x540 (16:9). Physical screen adaptation is handled by the
|
|
* UI layer (see `@ui/FloatingControlLayer`).
|
|
*/
|
|
|
|
/** Landscape design resolution baseline width (px). */
|
|
export const DESIGN_WIDTH = 960;
|
|
|
|
/** Landscape design resolution baseline height (px). */
|
|
export const DESIGN_HEIGHT = 540;
|
|
|
|
/** Target frame rate (locked 30fps per performance requirement 18.1-18.3). */
|
|
export const TARGET_FPS = 30;
|
|
|
|
/** Max first-package size (bytes) per requirement 18.7. */
|
|
export const MAX_FIRST_PACKAGE_BYTES = 4 * 1024 * 1024;
|
|
|
|
/** Max audio bundle size (bytes) per requirement 16.5 / 19.7. */
|
|
export const MAX_AUDIO_BUNDLE_BYTES = 500 * 1024;
|
|
|
|
/** Max runtime memory peak (bytes) per requirement 18.4. */
|
|
export const MAX_MEMORY_PEAK_BYTES = 200 * 1024 * 1024;
|
|
|
|
/**
|
|
* Player character color states. Red = base (1-hit kill),
|
|
* Green = 1 crystal buff, Yellow = 2 crystals (faster movement).
|
|
* Per requirement 5.1-5.6.
|
|
*/
|
|
export enum PlayerColorState {
|
|
Red = 'red',
|
|
Green = 'green',
|
|
Yellow = 'yellow',
|
|
}
|
|
|
|
/** Horizontal movement speed (px/s) per color state, per requirement 5.1-5.2. */
|
|
export const MOVE_SPEED: Record<PlayerColorState, number> = {
|
|
[PlayerColorState.Red]: 100,
|
|
[PlayerColorState.Green]: 100,
|
|
[PlayerColorState.Yellow]: 150,
|
|
};
|
|
|
|
/** Standard vertical jump height (px) per requirement 2.2 (red/green baseline). */
|
|
export const JUMP_HEIGHT_STANDARD = 250;
|
|
|
|
/** Charged jump height (px) per requirement 2.3. */
|
|
export const JUMP_HEIGHT_CHARGED = 375;
|
|
|
|
/** Yellow-state jump height (px) per requirement 2.2. */
|
|
export const JUMP_HEIGHT_YELLOW = 300;
|
|
|
|
/** Crouch delay before actually leaving the ground (ms) per requirement 2.8. */
|
|
export const JUMP_PREPARE_DELAY_MS = 150;
|
|
|
|
/** Long-press threshold to trigger charged jump (ms) per requirement 2.3. */
|
|
export const JUMP_CHARGE_THRESHOLD_MS = 500;
|
|
|
|
/**
|
|
* Parabolic jump angle tolerance windows (degrees). A joystick direction that
|
|
* lies within ±ANGLE_TOLERANCE of 45° or 135° triggers a parabolic jump.
|
|
* Per requirement 2.5 and requirement 20.3 (>=95% recognition rate).
|
|
*/
|
|
export const PARABOLIC_ANGLE_RIGHT = 45;
|
|
export const PARABOLIC_ANGLE_LEFT = 135;
|
|
export const PARABOLIC_ANGLE_TOLERANCE = 15;
|
|
|
|
/** Weapon attack intervals (s). Per requirement 3.4 / 3.6. */
|
|
export const SHURIKEN_INTERVAL_BASE = 0.3;
|
|
export const SHURIKEN_INTERVAL_UPGRADED = 0.25;
|
|
export const SWORD_INTERVAL = 0.5;
|
|
|
|
/** Max shuriken burst count when long-pressing attack button (req 3.5). */
|
|
export const SHURIKEN_BURST_MAX = 3;
|
|
|
|
/** Combo-input recognition window (ms) for "jump + attack" per req 4.1. */
|
|
export const COMBO_INPUT_WINDOW_MS = 100;
|
|
|
|
/** Player invincibility frames duration (s) after a knockback per req 10.2. */
|
|
export const PLAYER_IFRAME_SECONDS = 0.5;
|
|
|
|
/**
|
|
* Performance KPI thresholds used by Logger / BI埋点 layer.
|
|
* Per requirement 20.1-20.6.
|
|
*/
|
|
export const PERF_TOUCH_RESPONSE_MAX_MS = 50;
|
|
export const PERF_JUMP_STATE_TOGGLE_MAX_MS = 50;
|
|
export const PERF_COMBO_RECOGNITION_MAX_MS = 100;
|
|
export const PERF_PARABOLIC_ANGLE_ACCURACY_TARGET = 0.95;
|
|
export const PERF_AIR_JUMP_BLOCK_RATE_TARGET = 0.99;
|
|
|
|
/** Local storage keys (req 17.1-17.5, 19.5). */
|
|
export const STORAGE_KEY = {
|
|
LevelUnlock: 'kl_level_unlock',
|
|
ControlLayout: 'kl_control_layout',
|
|
AudioVolume: 'kl_audio_volume',
|
|
TutorialDone: 'kl_tutorial_done',
|
|
StoryIntroSeen: 'kl_story_intro_seen',
|
|
} as const;
|