Files
mygame/game/config.py
2026-05-20 21:23:46 +08:00

154 lines
7.8 KiB
Python

import pygame
# Window
WINDOW_WIDTH = 800
WINDOW_HEIGHT = 600
UI_TOP_HEIGHT = 40
UI_BOTTOM_HEIGHT = 60
GAME_HEIGHT = WINDOW_HEIGHT - UI_TOP_HEIGHT - UI_BOTTOM_HEIGHT
FPS = 60
# Grid
CELL_SIZE = 40
GRID_COLS = WINDOW_WIDTH // CELL_SIZE
GRID_ROWS = GAME_HEIGHT // CELL_SIZE
# Colors
COLOR_BG = (34, 40, 49)
COLOR_GRASS = (44, 62, 44)
COLOR_PATH = (139, 119, 101)
COLOR_GRID_LINE = (50, 58, 50)
COLOR_WHITE = (255, 255, 255)
COLOR_BLACK = (0, 0, 0)
COLOR_RED = (220, 50, 50)
COLOR_DARK_RED = (160, 30, 30)
COLOR_GREEN = (50, 200, 50)
COLOR_BLUE = (70, 130, 230)
COLOR_YELLOW = (230, 200, 50)
COLOR_PURPLE = (150, 50, 200)
COLOR_ORANGE = (230, 150, 50)
COLOR_CYAN = (50, 200, 200)
COLOR_GRAY = (120, 120, 120)
COLOR_DARK_GRAY = (60, 60, 60)
COLOR_GOLD = (255, 215, 0)
COLOR_HIGHLIGHT = (255, 255, 255, 80)
COLOR_DARK_BLUE = (30, 60, 150)
COLOR_DARK_GREEN = (30, 130, 50)
COLOR_BRIGHT_PURPLE = (180, 80, 255)
COLOR_BRIGHT_GREEN = (100, 255, 100)
COLOR_SILVER = (192, 192, 210)
COLOR_PINK = (255, 130, 170)
COLOR_LIGHT_BLUE = (100, 150, 255, 40)
# Game params
INITIAL_GOLD = 200
INITIAL_LIVES = 10
TOTAL_WAVES = 10
# Tower stats
TOWER_DATA = {
"arrow": {"damage": 20, "range": 120, "fire_rate": 0.5, "price": 50, "color": COLOR_BLUE, "name": "箭塔"},
"cannon": {"damage": 80, "range": 100, "fire_rate": 1.5, "price": 100, "color": COLOR_ORANGE, "name": "炮塔", "splash": 60},
"slow": {"damage": 5, "range": 130, "fire_rate": 0.8, "price": 75, "color": COLOR_CYAN, "name": "减速塔", "slow_factor": 0.5, "slow_duration": 2.0},
"sniper": {"damage": 120, "range": 200, "fire_rate": 2.0, "price": 120, "color": COLOR_DARK_BLUE, "name": "狙击塔"},
"poison": {"damage": 5, "range": 110, "fire_rate": 1.2, "price": 80, "color": COLOR_DARK_GREEN, "name": "毒塔", "poison_dps": 8, "poison_duration": 3.0},
"lightning": {"damage": 40, "range": 140, "fire_rate": 1.0, "price": 150, "color": COLOR_BRIGHT_PURPLE, "name": "雷电塔", "chain_count": 2, "chain_range": 80, "chain_decay": 0.5},
}
# Enemy stats
ENEMY_DATA = {
"normal": {"hp": 100, "speed": 2, "reward": 10, "color": COLOR_RED, "size": 12, "name": "普通兵"},
"fast": {"hp": 60, "speed": 4, "reward": 8, "color": COLOR_YELLOW, "size": 10, "name": "快速兵"},
"heavy": {"hp": 300, "speed": 1, "reward": 25, "color": COLOR_PURPLE, "size": 14, "name": "重装兵"},
"boss": {"hp": 800, "speed": 0.8, "reward": 100, "color": COLOR_DARK_RED, "size": 20, "name": "BOSS"},
"swarm": {"hp": 30, "speed": 5, "reward": 3, "color": COLOR_BRIGHT_GREEN, "size": 7, "name": "虫群兵"},
"shield": {"hp": 200, "speed": 1.5, "reward": 20, "color": COLOR_SILVER, "size": 15, "name": "护盾兵", "shield_hp": 200},
"healer": {"hp": 150, "speed": 1.8, "reward": 30, "color": COLOR_PINK, "size": 12, "name": "治疗兵", "heal_range": 100, "heal_amount": 30, "heal_interval": 2.0},
}
# Path waypoints (pixel coordinates) — default/legacy
PATH_WAYPOINTS = [
(0, 180),
(160, 180),
(160, 340),
(400, 340),
(400, 100),
(600, 100),
(600, 340),
(760, 340),
(760, 220),
(800, 220),
]
# Level definitions
LEVELS = [
{
"name": "第一关 - 森林小径",
"color": (44, 72, 44),
"start_gold": 200,
"start_lives": 10,
"waypoints": [
(0, 180), (160, 180), (160, 340), (400, 340),
(400, 100), (600, 100), (600, 340), (760, 340),
(760, 220), (800, 220),
],
"waves": [
[{"type": "normal", "count": 5, "interval": 1.0}],
[{"type": "normal", "count": 6, "interval": 0.8}, {"type": "swarm", "count": 4, "interval": 0.3}],
[{"type": "normal", "count": 5, "interval": 0.8}, {"type": "fast", "count": 3, "interval": 0.6}],
[{"type": "swarm", "count": 10, "interval": 0.25}, {"type": "normal", "count": 5, "interval": 0.7}],
[{"type": "normal", "count": 5, "interval": 0.6}, {"type": "heavy", "count": 2, "interval": 1.5}, {"type": "boss", "count": 1, "interval": 2.0}],
[{"type": "normal", "count": 8, "interval": 0.5}, {"type": "fast", "count": 5, "interval": 0.4}, {"type": "swarm", "count": 8, "interval": 0.2}],
[{"type": "shield", "count": 3, "interval": 1.2}, {"type": "healer", "count": 2, "interval": 1.5}, {"type": "normal", "count": 6, "interval": 0.6}],
[{"type": "heavy", "count": 4, "interval": 0.8}, {"type": "fast", "count": 5, "interval": 0.5}, {"type": "shield", "count": 3, "interval": 1.0}],
],
},
{
"name": "第二关 - 沙漠要塞",
"color": (82, 77, 50),
"start_gold": 180,
"start_lives": 8,
"waypoints": [
(0, 60), (200, 60), (200, 180), (60, 180),
(60, 300), (340, 300), (340, 180), (480, 180),
(480, 300), (620, 300), (620, 100), (800, 100),
],
"waves": [
[{"type": "normal", "count": 8, "interval": 0.8}],
[{"type": "fast", "count": 6, "interval": 0.5}, {"type": "swarm", "count": 6, "interval": 0.25}],
[{"type": "normal", "count": 6, "interval": 0.6}, {"type": "heavy", "count": 3, "interval": 1.2}],
[{"type": "swarm", "count": 12, "interval": 0.2}, {"type": "shield", "count": 2, "interval": 1.5}],
[{"type": "fast", "count": 8, "interval": 0.4}, {"type": "healer", "count": 2, "interval": 1.0}],
[{"type": "heavy", "count": 5, "interval": 0.8}, {"type": "normal", "count": 8, "interval": 0.5}],
[{"type": "shield", "count": 4, "interval": 1.0}, {"type": "fast", "count": 6, "interval": 0.4}, {"type": "boss", "count": 1, "interval": 2.0}],
[{"type": "swarm", "count": 15, "interval": 0.15}, {"type": "heavy", "count": 4, "interval": 0.7}],
[{"type": "normal", "count": 10, "interval": 0.4}, {"type": "shield", "count": 4, "interval": 0.8}, {"type": "healer", "count": 3, "interval": 1.0}],
[{"type": "heavy", "count": 6, "interval": 0.6}, {"type": "fast", "count": 10, "interval": 0.3}, {"type": "boss", "count": 2, "interval": 2.0}],
],
},
{
"name": "第三关 - 暗夜城堡",
"color": (35, 30, 45),
"start_gold": 150,
"start_lives": 8,
"waypoints": [
(0, 260), (120, 260), (120, 60), (280, 60),
(280, 180), (440, 180), (440, 60), (560, 60),
(560, 260), (680, 260), (680, 100), (800, 100),
],
"waves": [
[{"type": "normal", "count": 8, "interval": 0.7}, {"type": "fast", "count": 4, "interval": 0.5}],
[{"type": "heavy", "count": 4, "interval": 1.0}, {"type": "swarm", "count": 8, "interval": 0.2}],
[{"type": "shield", "count": 4, "interval": 1.0}, {"type": "fast", "count": 6, "interval": 0.4}],
[{"type": "healer", "count": 3, "interval": 1.0}, {"type": "normal", "count": 10, "interval": 0.5}],
[{"type": "swarm", "count": 15, "interval": 0.15}, {"type": "heavy", "count": 5, "interval": 0.8}, {"type": "boss", "count": 1, "interval": 2.0}],
[{"type": "shield", "count": 5, "interval": 0.8}, {"type": "healer", "count": 3, "interval": 0.8}, {"type": "fast", "count": 8, "interval": 0.3}],
[{"type": "heavy", "count": 6, "interval": 0.6}, {"type": "swarm", "count": 12, "interval": 0.15}],
[{"type": "normal", "count": 12, "interval": 0.3}, {"type": "shield", "count": 5, "interval": 0.7}, {"type": "boss", "count": 1, "interval": 2.0}],
[{"type": "fast", "count": 12, "interval": 0.25}, {"type": "healer", "count": 4, "interval": 0.7}],
[{"type": "heavy", "count": 8, "interval": 0.5}, {"type": "shield", "count": 6, "interval": 0.6}, {"type": "swarm", "count": 15, "interval": 0.12}],
[{"type": "normal", "count": 12, "interval": 0.25}, {"type": "heavy", "count": 6, "interval": 0.5}, {"type": "fast", "count": 10, "interval": 0.2}, {"type": "boss", "count": 3, "interval": 2.0}],
],
},
]