Forráskód Böngészése

(250724) 修复灰烟重置bug; 修复糖泡音效bug; 修复地震横波参数; 增加完全胜利

detopoi 1 éve
szülő
commit
47da10addd

+ 1 - 1
client_local/const/game.py

@@ -75,7 +75,7 @@ CAMERA = 1
 W_INCREMENT = 0
 H_INCREMENT = 0
 
-
+CUMULATION_INJURE = 0  # 一局游戏的累积受伤
 
 
 

+ 14 - 28
client_local/control.py

@@ -60,6 +60,7 @@ class Control:
         self.cfg_reset = None  # 用户自定义重启0
         self.text_font = None
         self.description_shown = False
+        self.map_name_json = None
 
         self.wall_walking = True
 
@@ -172,14 +173,12 @@ class Control:
         self.screen = pygame.display.set_mode(W.WINDOW_SIZE, flags=self.display_flags)
         pygame.display.set_icon(pygame.image.load("res/img/ui/icon.png").convert_alpha())
 
-
         for i in range(10):
             file_name = "itemNum_0_" + str(i) + ".png"
             img = pygame.image.load("res/img/ui/number/" + file_name).convert_alpha()
             G.NUMBER_IMG.append(img)
 
 
-
     def init_keys(self, keys_root):
         # 加载自定义按键
         self.orientations[keys_root["RIGHT"]] = "R"
@@ -296,7 +295,6 @@ class Control:
             pygame.time.Clock().tick(self.frame_rate)
 
 
-
     def key_pressed(self):
         # 键盘事件检测
         keys = pygame.key.get_pressed()
@@ -372,39 +370,34 @@ class Control:
         else:
             self.pause_old = False
 
-
     def player_reset(self, keys):
         if keys[self.cfg_reset]:
             if self.reset_old is True:
                 return
-            # print("C1:", G.CURRENT_LEVEL)
             G.CURRENT_LEVEL = 0
-            # print("C2:", G.CURRENT_LEVEL)
-            self.init_game()
-            self.proceed_game(is_reset=True)
             self.reset_old = True
             G.CHEAT = False
             G.HAS_RECORD = False
             G.LASTMAPTIME = G.TIME
             G.LAST_LEVEL_TIME = G.TIME
             G.ITEM = 0
+            G.SPECIAL_MAX_HP = 0
+            G.CUMULATION_INJURE = 0
             G.MONSTER_RECORD_LIST = []
             G.HAS_RECORD_FULL = False
             G.HAS_GOLDEN = False
-
             self.cfg_json = load_json("config.json")
             self.map_set_json = load_json("game/map_set/" + self.cfg_json["map_set"] + ".json")
             G.TOTAL_LEVEL = len(self.map_set_json["maps"])
-            self.map_name_json = load_json("game/map/" + self.map_set_json["maps"][0] + ".json")
-
+            self.map_name_json = load_json(f"game/map/{self.map_set_json['maps'][0]}.json")
             if "environment_effect" in self.map_name_json["basic"].keys():
                 G.ENVIRONMENT_EFFECT = self.map_name_json["basic"]["environment_effect"]
             else:
                 G.ENVIRONMENT_EFFECT = []
-
             if "player_light" in self.map_name_json["basic"].keys():
                 self.me.light = self.map_name_json["basic"]["player_light"]
-
+            self.init_game()
+            self.proceed_game(is_reset=True)
         else:
             self.reset_old = False
 
@@ -431,21 +424,6 @@ class Control:
                 self.message_old[idx] = False
 
     def reset(self, map_set):
-        '''
-        with open("config.json", "r", encoding="utf-8") as json_file:
-            mapsetdata = json.load(json_file)
-        mapsetdata["map_set"] = map_set
-        with open("config.json", "w", encoding="utf-8") as json_file:
-            json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
-        self.init_game()
-        '''
-        self.map_set_json = load_json("game/map_set/" + map_set + ".json")
-        self.map_set_at = 0
-        map_name = self.map_set_json["maps"][self.map_set_at]
-        hero_name = self.cfg_json["your_hero"]
-        character_color = self.cfg_json["your_character_color"]
-        self.set_level(self.your_name, map_name, hero_name, character_color, is_reset=True)
-
         self.reset_old = True
         G.CHEAT = False
         G.HAS_RECORD = False
@@ -454,6 +432,7 @@ class Control:
         G.LAST_LEVEL_TIME = G.TIME
         G.ITEM = 0
         G.SPECIAL_MAX_HP = 0
+        G.CUMULATION_INJURE = 0
         # G.MONSTER_RECORD_LIST = []
         G.HAS_RECORD_FULL = False
         G.HAS_GOLDEN = False
@@ -467,3 +446,10 @@ class Control:
         if "player_light" in self.map_name_json["basic"].keys():
             self.me.light = self.map_name_json["basic"]["player_light"]
 
+        self.map_set_json = load_json("game/map_set/" + map_set + ".json")
+        self.map_set_at = 0
+        map_name = self.map_set_json["maps"][self.map_set_at]
+        hero_name = self.cfg_json["your_hero"]
+        character_color = self.cfg_json["your_character_color"]
+        self.set_level(self.your_name, map_name, hero_name, character_color, is_reset=True)
+

+ 24 - 10
client_local/level/level.py

@@ -1,11 +1,12 @@
+import os
+import pygame
+import random
+import ast
 import json
 import math
+import time
 from json import JSONDecodeError
 import numpy as np
-import pygame
-import os
-import ast
-import time
 from collections import defaultdict
 
 from client_local.const import game as G
@@ -235,6 +236,7 @@ class Level:
         self.map_music_volume = music_volume  # 关卡背景音乐音量大小
         self.finish_at = None  # 地图过关点(x, y)
 
+        self.earth_quake_direction = None
         self.earth_quake_init_tick = 0  # 地震初始化tick
         self.earth_quake_left_times = 0  # 地震剩余次数
         self.earth_quake_strength = 0  # 地震强度
@@ -485,16 +487,23 @@ class Level:
         self.blood_bar.set_name(self.your_name)
         self.ui_instances_top.append(self.blood_bar)
 
-    def earth_quake_effect(self, strength=0.1, times=3, duration_per_time=200, decrease=True):
-        '''屏幕震动效果,强度表示移动像素数量,times表示震动次数,duration_per_time表示每次震动持续时间'''
+    def earth_quake_effect(self, strength=0.1, times=3, duration_per_time=200, decrease=True, direction=None):
+        """屏幕震动效果,强度表示移动像素数量,times表示震动次数,duration_per_time表示每次震动持续时间"""
+        if direction is None:
+            direction = random.choice([0, 1])
+        self.earth_quake_direction = direction
+        if direction == 0:
+            self.earth_quake_duration_per_time = duration_per_time
+            strength *= 2
+        else:
+            self.earth_quake_duration_per_time = duration_per_time // 2
         self.earth_quake_strength = strength
         self.earth_quake_times = times
-        self.earth_quake_duration_per_time = duration_per_time
         self.earth_quake_time = pygame.time.get_ticks()
         self.earth_quake_decrease = decrease
 
     def run_earth_quake_effect(self, screen: pygame.Surface = None):
-        '''运行屏幕震动效果'''
+        """运行屏幕震动效果"""
         global Y_SCALE_FACTOR
         if self.earth_quake_strength <= 0 or self.earth_quake_times <= 0:
             Y_SCALE_FACTOR = 1
@@ -604,11 +613,15 @@ class Level:
             encrypted_data["STAT"].append(new_data)
             with open(full_achievements_file_path, 'w') as file:
                 json.dump(encrypted_data, file, indent=2)
-
+        if G.CURRENT_LEVEL == G.TOTAL_LEVEL:
+            G.CUMULATION_INJURE += self.me.blood - self.me.remain_blood
         if self.check_achievement() and G.CURRENT_LEVEL == G.TOTAL_LEVEL and not G.HAS_RECORD:
             G.HAS_RECORD = True
             sound_player.playWin("PlayerWin")
-            WinEffect(self.me, self.me, "big", self.skill_instances)
+            if G.CUMULATION_INJURE == 0:
+                WinEffect(self.me, self.me, "super", self.skill_instances)
+            else:
+                WinEffect(self.me, self.me, "big", self.skill_instances)
             # 构建保存文件的路径
             user_documents_folder = os.path.expanduser("~\\Documents")  # 获取用户的"文档"文件夹路径
             qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE")  # 构建QQTPVE文件夹路径
@@ -943,6 +956,7 @@ class Level:
             if self.me.x == self.finish_at[0] and self.me.y == self.finish_at[1]:
                 self.finish_flag = True
                 G.LAST_LEVEL_TIME = self.times_num
+                G.CUMULATION_INJURE += (self.me.blood - self.me.remain_blood)
 
     # 传送门,参数格式: {"[x1,y1]":{"type": "level", "target": [x2,y2]}, "[x3,y3]":{"type": "map", "target": 3}, "[x4,y4]":{"type": "map_set", "target": "Mo1"}}
     def portal_map(self):

+ 2 - 2
client_local/skill/parametric2_skill.py

@@ -1977,7 +1977,7 @@ class CustomLightShield(Skill):
 
 
 
-
+# 地震特效, "params": {"strength": 0.1, "duration_per_time": 200, "times": 3, "decrease": true, "direction": 0}
 class CustomMapEarthQuake(Skill):
 
     def __init__(self, user=None, to=None, params=None, skill_instances=None):
@@ -1998,7 +1998,7 @@ class CustomMapEarthQuake(Skill):
 
 
 
-# 耗电原地召唤怪,"params": {"spawn_list": [充电召唤列表], "energy_cost": 3}
+# 耗电原地召唤怪, "params": {"spawn_list": [充电召唤列表], "energy_cost": 3}
 class CustomPointSpawnWithNameAndCharge(Skill):
 
     def __init__(self, user, to, params, skill_instances):

+ 1 - 1
client_local/skill/parametric_skill.py

@@ -2838,7 +2838,7 @@ class CustomDevilSmokeMagic(Skill):
                 G.SPECIAL_MAX_HP -= min(max(0,level.current_level.me.blood-self.damages[0]), self.damages[0])
                 level.current_level.blood_bar.max_blood = min(max(0, level.current_level.me.blood), 999999)
                 sound_player.play("cry")
-            for (x,y) in self.grids:
+            for (x, y) in self.grids:
                 an_effect = EffectInstance("devil_dizzy_explode", self.user, False, level.current_level.effects_front)
                 an_effect.set_xy(x, y)
                 self.effect_instances.append(an_effect)

+ 1 - 1
client_local/sound/sound_player.py

@@ -21,7 +21,7 @@ def play(name):
     current_time = pygame.time.get_ticks()
     try:
         # 检查是否超过时间间隔阈值
-        if current_time - last_play_time[name] > TIME_THRESHOLD:
+        if current_time - last_play_time[name] > TIME_THRESHOLD or name in {"bomb", "flame"}:
             sound = pygame.mixer.Sound(f"{PATH}/{name}.wav")
             sound.set_volume(G.SOUND_VOLUME)
             sound.play()

+ 1 - 0
client_local/sprite/hero.py

@@ -124,6 +124,7 @@ class Hero(Player):
         self.bomb_skin = bomb.get_bomb(self.hero_json["decorations"]["bomb_skin"])
         self.icon_img = self.hero_json["icon_img"]
         self.blood = self.hero_json["blood"] + G.SPECIAL_MAX_HP
+        print(self.blood, G.SPECIAL_MAX_HP)
         self.speed = (self.hero_json["speed"] * G.SPECIAL_SPEED * G.GAME_SQUARE) / 1000
         self.bomb = self.hero_json["bomb"] + G.SPECIAL_BOMB
         self.power = self.hero_json["power"] + G.SPECIAL_POWER

+ 1 - 1
client_local/sprite/npc.py

@@ -9,7 +9,6 @@ from client_local.const import game as G
 from client_local.frame import bomb, item
 from client_local.level import level
 from client_local.skill.skill import *
-from client_local.ui.game.blood_bar import BossBloodBar, BossHead
 from client_local.sound import sound_player
 from client_local.sprite.bomb_instance import BombInstance
 from client_local.sprite.ghost import Ghost
@@ -17,6 +16,7 @@ from client_local.sprite.hero import Hero
 from client_local.sprite.item_instance import ItemInstance
 from client_local.sprite.player import Player, PlayerState
 from client_local.sprite.throwable import Throwable
+from client_local.ui.game.blood_bar import BossBloodBar, BossHead
 from client_local.file_loader.fileLoader import load_json, load_png
 
 user_documents_folder = os.path.expanduser("~\\Documents")  # 获取用户的"文档"文件夹路径

+ 45 - 10
client_local/ui/game/blood_bar.py

@@ -70,16 +70,6 @@ class BloodBar(UIInstance):
         self.sheet.blit(text_img, (26, 24))
 
 
-
-
-
-
-
-
-
-
-
-
 class BossBloodBar(UIInstance):
 
     UI_IMG_GAME_ROOT = "res/img/ui/game/"
@@ -129,7 +119,52 @@ class BossBloodBar(UIInstance):
             self.sheet.blit(self.blood_slice_img, (i+2, 4))
 
 
+class MapBloodBar(UIInstance):
+
+    UI_IMG_GAME_ROOT = "res/img/ui/game/"
+
+    def __init__(self, user, pos):
+        super(MapBloodBar, self).__init__("game", "map_blood_bar")
+        self.rect.x = 96 + 200 * ((pos-1) % 3)
+        self.rect.y = 36 + 42 * int((pos-1)/3)
+        self.user = user
+        self.current_blood = 0
+        self.max_blood = 1
+        self.blood_slice_img = pygame.image.load(f"{BloodBar.UI_IMG_GAME_ROOT}/img_mapBlood.png").convert_alpha()
+        self.blood_slice_idx = 154  # 0~90 决定血条的长度
+        self.blood_slice_last_update_time = pygame.time.get_ticks()
+        self.init()
+
+    def init(self):
+        self.set_max_blood(self.user.blood-self.user.fake_blood)
+
+    def update(self):
+        self.redraw_trigger = True
+        current_time = pygame.time.get_ticks()
+        if current_time - self.blood_slice_last_update_time > 100:  # 每100ms刷新一次动画
+            # print('draw', self.user.chs_name)
+            self.blood_slice_last_update_time = current_time
+            self.sheet = pygame.Surface(self.rect.size, pygame.SRCALPHA, 32)
+            self.current_blood = self.user.remain_blood - self.user.fake_blood
+            self.set_blood(self.current_blood)
+            # 动画改变血条长度
+            idx = math.ceil(self.current_blood * 154 / self.max_blood)
+            if idx == self.blood_slice_idx:
+                return
+            if idx < self.blood_slice_idx:
+                self.blood_slice_idx -= 1
+            elif idx > self.blood_slice_idx:
+                self.blood_slice_idx += 1
+
+    def set_max_blood(self, max_blood):
+        self.max_blood = max(0, max_blood)
+        self.current_blood = self.max_blood
+        self.set_blood(self.current_blood)
 
+    def set_blood(self, blood: int):
+        blood = min(max(0, blood), self.max_blood)
+        for i in range(self.blood_slice_idx):
+            self.sheet.blit(self.blood_slice_img, (i+2, 4))
 
 
 

+ 1 - 1
client_local/ui/game/game_top.py

@@ -15,7 +15,7 @@ class GameTop(UIInstance):
     def __init__(self):
         super().__init__("game", "gameTop")
         self.font = pygame.font.Font(FONT_PATH, 16)
-        self.rend = self.font.render("v20250720", True, (0, 196, 255))
+        self.rend = self.font.render("v20250724", True, (0, 196, 255))
 
     def draw(self, screen: pygame.Surface):
         super().draw(screen)