Skip to content

Commit

Permalink
整理代码
Browse files Browse the repository at this point in the history
  • Loading branch information
wszqkzqk committed May 15, 2022
1 parent bd59b16 commit 47ec636
Showing 1 changed file with 107 additions and 77 deletions.
184 changes: 107 additions & 77 deletions source/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,27 @@

# 地图类型集合
# 白天场地(泛指蘑菇睡觉的场地)
DAYTIME_BACKGROUNDS = { BACKGROUND_DAY, BACKGROUND_POOL,
BACKGROUND_ROOF, BACKGROUND_WALLNUTBOWLING,
BACKGROUND_SINGLE, BACKGROUND_TRIPLE,
}
DAYTIME_BACKGROUNDS = {
BACKGROUND_DAY, BACKGROUND_POOL,
BACKGROUND_ROOF, BACKGROUND_WALLNUTBOWLING,
BACKGROUND_SINGLE, BACKGROUND_TRIPLE,
}

# 带有泳池的场地
POOL_EQUIPPED_BACKGROUNDS = { BACKGROUND_POOL, BACKGROUND_FOG,
}
POOL_EQUIPPED_BACKGROUNDS = {
BACKGROUND_POOL, BACKGROUND_FOG,
}

# 屋顶上的场地
ON_ROOF_BACKGROUNDS = { BACKGROUND_ROOF, BACKGROUND_ROOFNIGHT,
}
ON_ROOF_BACKGROUNDS = {
BACKGROUND_ROOF, BACKGROUND_ROOFNIGHT,
}

# BACKGROUND_DAY场地的变体
BACKGROUND_DAY_LIKE_BACKGROUNDS = { BACKGROUND_DAY, BACKGROUND_SINGLE,
BACKGROUND_TRIPLE,
}
BACKGROUND_DAY_LIKE_BACKGROUNDS = {
BACKGROUND_DAY, BACKGROUND_SINGLE,
BACKGROUND_TRIPLE,
}

# 夜晚地图的墓碑数量等级
GRADE_GRAVES = 'grade_graves'
Expand Down Expand Up @@ -232,60 +239,77 @@
GRAVEBUSTER = 'GraveBuster'
FUMESHROOM = 'FumeShroom'

# 植物集体属性

# 植物集体属性集合
# 在生效时不用与僵尸进行碰撞检测的对象
SKIP_ZOMBIE_COLLISION_CHECK_WHEN_WORKING = {# 注意爆炸坚果的触发也是啃食类碰撞,因此这里不能省略
SQUASH, ICESHROOM,
REDWALLNUTBOWLING, CHERRYBOMB,
JALAPENO, DOOMSHROOM,
POTATOMINE,
}
SKIP_ZOMBIE_COLLISION_CHECK_WHEN_WORKING = {
# 注意爆炸坚果的触发也是啃食类碰撞,因此这里不能省略
SQUASH, ICESHROOM,
REDWALLNUTBOWLING, CHERRYBOMB,
JALAPENO, DOOMSHROOM,
POTATOMINE,
}

# 非植物对象
NON_PLANT_OBJECTS = { HOLE, ICE_FROZEN_PLOT,
GRAVE,
}
NON_PLANT_OBJECTS = {
HOLE, ICE_FROZEN_PLOT,
GRAVE,
}

# 所有可能不用与僵尸进行碰撞检测的对象
CAN_SKIP_ZOMBIE_COLLISION_CHECK = ( # 生效时不检测的植物
SKIP_ZOMBIE_COLLISION_CHECK_WHEN_WORKING |
# 非植物对象
NON_PLANT_OBJECTS |
# 地刺类
{SPIKEWEED, }
)
CAN_SKIP_ZOMBIE_COLLISION_CHECK = ( # 这里运用了集合运算
# 生效时不检测的植物
SKIP_ZOMBIE_COLLISION_CHECK_WHEN_WORKING |
# 非植物对象
NON_PLANT_OBJECTS |
# 地刺类
{SPIKEWEED, }
)

# 死亡时不触发音效的对象
PLANT_DIE_SOUND_EXCEPTIONS = { WALLNUTBOWLING, TANGLEKLEP,
ICE_FROZEN_PLOT, HOLE,
GRAVE, JALAPENO,
REDWALLNUTBOWLING, CHERRYBOMB,
}
PLANT_DIE_SOUND_EXCEPTIONS = {
WALLNUTBOWLING, TANGLEKLEP,
ICE_FROZEN_PLOT, HOLE,
GRAVE, JALAPENO,
REDWALLNUTBOWLING, CHERRYBOMB,
}

# color_key为白色的对象
PLANT_COLOR_KEY_WHITE = { POTATOMINE, SPIKEWEED,
JALAPENO, SCAREDYSHROOM,
SUNSHROOM, ICESHROOM,
HYPNOSHROOM, SQUASH,
WALLNUTBOWLING, REDWALLNUTBOWLING,
}
PLANT_COLOR_KEY_WHITE = {
POTATOMINE, SPIKEWEED,
JALAPENO, SCAREDYSHROOM,
SUNSHROOM, ICESHROOM,
HYPNOSHROOM, SQUASH,
WALLNUTBOWLING, REDWALLNUTBOWLING,
}

# 直接水生植物
WATER_PLANTS = { LILYPAD, SEASHROOM,
TANGLEKLEP,
}
WATER_PLANTS = {
LILYPAD, SEASHROOM,
TANGLEKLEP,
}

# 不用使用通用方法检验攻击状态的植物
PLANT_NON_CHECK_ATTACK_STATE = ({ # 单独指定攻击状态的植物
WALLNUTBOWLING,
# 没有攻击状态的植物
WALLNUT, TALLNUT,
TORCHWOOD, SUNFLOWER,
SUNSHROOM, COFFEEBEAN,
GRAVEBUSTER, LILYPAD,
HYPNOSHROOM,
} |
# 非植物类
NON_PLANT_OBJECTS
)
PLANT_NON_CHECK_ATTACK_STATE = ( # 这里运用了集合运算
{# 单独指定攻击状态的植物
WALLNUTBOWLING,
# 没有攻击状态的植物
WALLNUT, TALLNUT,
TORCHWOOD, SUNFLOWER,
SUNSHROOM, COFFEEBEAN,
GRAVEBUSTER, LILYPAD,
HYPNOSHROOM,
} |
# 非植物类
NON_PLANT_OBJECTS
)

# 范围爆炸植物,即灰烬植物与寒冰菇
ASH_PLANTS_AND_ICESHROOM = { REDWALLNUTBOWLING, CHERRYBOMB,
JALAPENO, DOOMSHROOM,
ICESHROOM,}
ASH_PLANTS_AND_ICESHROOM = {
REDWALLNUTBOWLING, CHERRYBOMB,
JALAPENO, DOOMSHROOM,
ICESHROOM,}


# 植物生命值
PLANT_HEALTH = 300
Expand Down Expand Up @@ -419,30 +443,36 @@
# 僵尸生成位置
ZOMBIE_START_X = SCREEN_WIDTH + 50 # 场宽度不一样,用于拟合

# 僵尸集体属性

# 僵尸集体属性集合
# 僵尸生成信息字典:包含生成僵尸名称、僵尸级别、生成权重
CREATE_ZOMBIE_DICT = { # 生成僵尸:(级别, 权重)
NORMAL_ZOMBIE:(1, 4000),
FLAG_ZOMBIE:(1, 0),
CONEHEAD_ZOMBIE:(2, 4000),
BUCKETHEAD_ZOMBIE:(4, 3000),
NEWSPAPER_ZOMBIE:(2, 1000),
FOOTBALL_ZOMBIE:(7, 2000),
DUCKY_TUBE_ZOMBIE:(1, 0), # 作为变种,不主动生成
CONEHEAD_DUCKY_TUBE_ZOMBIE:(2, 0), # 作为变种,不主动生成
BUCKETHEAD_DUCKY_TUBE_ZOMBIE:(4, 0), # 作为变种,不主动生成
SCREEN_DOOR_ZOMBIE:(4, 3500),
POLE_VAULTING_ZOMBIE:(2, 2000),
ZOMBONI:(7, 2000),
}
NORMAL_ZOMBIE: (1, 4000),
FLAG_ZOMBIE: (1, 0),
CONEHEAD_ZOMBIE: (2, 4000),
BUCKETHEAD_ZOMBIE: (4, 3000),
NEWSPAPER_ZOMBIE: (2, 1000),
FOOTBALL_ZOMBIE: (7, 2000),
DUCKY_TUBE_ZOMBIE: (1, 0), # 作为变种,不主动生成
CONEHEAD_DUCKY_TUBE_ZOMBIE: (2, 0), # 作为变种,不主动生成
BUCKETHEAD_DUCKY_TUBE_ZOMBIE: (4, 0), # 作为变种,不主动生成
SCREEN_DOOR_ZOMBIE: (4, 3500),
POLE_VAULTING_ZOMBIE: (2, 2000),
ZOMBONI: (7, 2000),
}

# 记录陆生僵尸的水生变种
CONVERT_ZOMBIE_IN_POOL = { NORMAL_ZOMBIE:DUCKY_TUBE_ZOMBIE,
CONEHEAD_ZOMBIE:CONEHEAD_DUCKY_TUBE_ZOMBIE,
BUCKETHEAD_ZOMBIE:BUCKETHEAD_DUCKY_TUBE_ZOMBIE}
CONVERT_ZOMBIE_IN_POOL = {
NORMAL_ZOMBIE: DUCKY_TUBE_ZOMBIE,
CONEHEAD_ZOMBIE: CONEHEAD_DUCKY_TUBE_ZOMBIE,
BUCKETHEAD_ZOMBIE: BUCKETHEAD_DUCKY_TUBE_ZOMBIE}

# 水上僵尸集合
WATER_ZOMBIE = { DUCKY_TUBE_ZOMBIE, CONEHEAD_DUCKY_TUBE_ZOMBIE,
BUCKETHEAD_DUCKY_TUBE_ZOMBIE,
}
WATER_ZOMBIE = {
DUCKY_TUBE_ZOMBIE, CONEHEAD_DUCKY_TUBE_ZOMBIE,
BUCKETHEAD_DUCKY_TUBE_ZOMBIE,
}


# 状态类型
IDLE = 'idle'
Expand Down

0 comments on commit 47ec636

Please sign in to comment.