This commit is contained in:
wfz
2026-04-25 22:09:27 +08:00
parent 9be6b17593
commit 7bffe41d41
33 changed files with 3461 additions and 581 deletions

View File

@@ -1,33 +1,48 @@
// ========== 地图尺寸常量 ==========
// 地图网格大小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'
PISTOL: 'pistol', // 手枪
MACHINE_GUN: 'machine_gun', // 机枪
SHOTGUN: 'shotgun', // 霰弹枪
GRENADE: 'grenade' // 手雷
}
// ========== 武器配置 ==========
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
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,
@@ -35,12 +50,13 @@ export const WEAPON_CONFIG = {
ammo: 100,
maxAmmo: 100,
speed: 25,
spread: 0.05,
spread: 0.05, // 小幅散布
pellets: 1,
range: 25,
auto: true,
auto: true, // 自动武器
chargeable: false
},
// 霰弹枪配置
[WEAPONS.SHOTGUN]: {
name: 'Shotgun',
damage: 20,
@@ -48,12 +64,13 @@ export const WEAPON_CONFIG = {
ammo: 20,
maxAmmo: 20,
speed: 18,
spread: 0.15,
pellets: 6,
spread: 0.15, // 大幅散布
pellets: 6, // 每次6颗弹丸
range: 12,
auto: false,
chargeable: false
},
// 手雷配置
[WEAPONS.GRENADE]: {
name: 'Grenade',
damage: 100,
@@ -65,45 +82,48 @@ export const WEAPON_CONFIG = {
pellets: 1,
range: 15,
auto: false,
chargeable: true,
maxCharge: 2000,
explosionRadius: 3
chargeable: true, // 可蓄力
maxCharge: 2000, // 最大蓄力时间(毫秒)
explosionRadius: 3 // 爆炸半径
}
}
// ========== 僵尸配置 ==========
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
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
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'
}
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' // 心跳响应
}