Files
zp1/frontend/src/utils/constants.js
2026-05-02 21:30:28 +08:00

176 lines
4.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// ========== 地图尺寸常量 ==========
// 地图网格大小32x32格子
export const GRID_SIZE = 32
// 每个格子的世界单位大小
export const CELL_SIZE = 1
// 玩家碰撞半径
export const PLAYER_SIZE = 0.8
// 僵尸碰撞半径
export const ZOMBIE_SIZE = 0.8
// 墙壁厚度
export const WALL_SIZE = 1
// 出生点标记
export const SPAWN_SIZE = 1
// ========== 游戏帧率常量 ==========
// 服务器每秒Tick数
export const TICK_RATE = 30
// 每Tick间隔毫秒
export const TICK_INTERVAL = 1000 / TICK_RATE
// ========== 武器枚举 ==========
export const WEAPONS = {
PISTOL: 'pistol', // 手枪
MACHINE_GUN: 'machine_gun', // 机枪
SHOTGUN: 'shotgun', // 霰弹枪
GRENADE: 'grenade', // 手雷
MOLOTOV: 'molotov', // 燃烧瓶
NUT_WALL: 'nut_wall', // 坚果墙体
AUTO_TURRET: 'auto_turret' // 自动机枪塔
}
// ========== 武器配置 ==========
export const WEAPON_CONFIG = {
// 手枪配置
[WEAPONS.PISTOL]: {
name: 'Pistol',
damage: 25, // 伤害
fireRate: 400, // 射击间隔(毫秒)
ammo: Infinity, // 弹药量(无限)
maxAmmo: Infinity, // 最大弹药
speed: 20, // 子弹速度
spread: 0, // 散布角度
pellets: 1, // 每次射击子弹数
range: 30, // 射程
auto: false, // 非自动武器
chargeable: false // 不可蓄力
},
// 机枪配置
[WEAPONS.MACHINE_GUN]: {
name: 'Machine Gun',
damage: 15,
fireRate: 100,
ammo: 100,
maxAmmo: 100,
speed: 25,
spread: 0.05, // 小幅散布
pellets: 1,
range: 25,
auto: true, // 自动武器
chargeable: false
},
// 霰弹枪配置
[WEAPONS.SHOTGUN]: {
name: 'Shotgun',
damage: 20,
fireRate: 800,
ammo: 20,
maxAmmo: 20,
speed: 18,
spread: 0.15, // 大幅散布
pellets: 6, // 每次6颗弹丸
range: 12,
auto: false,
chargeable: false
},
// 手雷配置
[WEAPONS.GRENADE]: {
name: 'Grenade',
damage: 100,
fireRate: 1500,
ammo: 10,
maxAmmo: 10,
speed: 12,
spread: 0,
pellets: 1,
range: 15,
auto: false,
chargeable: true, // 可蓄力
maxCharge: 2000, // 最大蓄力时间(毫秒)
explosionRadius: 3 // 爆炸半径
},
// 燃烧瓶配置
[WEAPONS.MOLOTOV]: {
name: 'Molotov',
damage: 80,
fireRate: 2000,
ammo: 10,
maxAmmo: 10,
speed: 12,
spread: 0,
pellets: 1,
range: 12,
auto: false,
chargeable: true, // 可蓄力
maxCharge: 2000,
explosionRadius: 2
},
// 坚果墙体配置
[WEAPONS.NUT_WALL]: {
name: 'Wall',
damage: 0,
fireRate: 1000,
ammo: 10,
maxAmmo: 10,
speed: 0,
spread: 0,
pellets: 0,
range: 0,
auto: false,
chargeable: false
},
// 自动机枪塔配置
[WEAPONS.AUTO_TURRET]: {
name: 'Turret',
damage: 0,
fireRate: 2000,
ammo: 5,
maxAmmo: 5,
speed: 0,
spread: 0,
pellets: 0,
range: 0,
auto: false,
chargeable: false
}
}
// ========== 僵尸配置 ==========
export const ZOMBIE_CONFIG = {
BASE_HEALTH: 100, // 基础生命值
BASE_SPEED: 2, // 基础移动速度
DAMAGE: 10, // 攻击伤害
ATTACK_RATE: 1000, // 攻击间隔(毫秒)
SPAWN_INTERVAL_BASE: 3000, // 基础生成间隔
SPAWN_INTERVAL_MIN: 800, // 最小生成间隔
DIFFICULTY_INCREASE_INTERVAL: 30000, // 难度增加间隔
HEALTH_INCREASE_PER_WAVE: 20, // 每波生命值增加
SPEED_INCREASE_PER_WAVE: 0.1, // 每波速度增加
LOOT_DROP_CHANCE: 0.3 // 掉落物概率
}
// ========== 玩家配置 ==========
export const PLAYER_CONFIG = {
MAX_HEALTH: 100, // 最大生命值
SPEED: 5, // 移动速度
INVULNERABLE_TIME: 500 // 无敌时间(受伤后)
}
// ========== 网络消息类型 ==========
export const MSG_TYPE = {
CREATE_ROOM: 'create_room', // 创建房间
JOIN_ROOM: 'join_room', // 加入房间
LEAVE_ROOM: 'leave_room', // 离开房间
ROOM_LIST: 'room_list', // 房间列表
ROOM_STATE: 'room_state', // 房间状态
READY: 'ready', // 玩家准备
START_GAME: 'start_game', // 开始游戏
GAME_STARTED: 'game_started', // 游戏开始
PLAYER_INPUT: 'player_input', // 玩家输入
GAME_STATE: 'game_state', // 游戏状态同步
PLAYER_JOIN: 'player_join', // 玩家加入
PLAYER_LEAVE: 'player_leave', // 玩家离开
ERROR: 'error', // 错误消息
PING: 'ping', // 心跳检测
PONG: 'pong' // 心跳响应
}