准备发布正式版
This commit is contained in:
@@ -95,7 +95,7 @@ var berserker_triggered: bool = false # 是否已触发过狂暴(防止重复
|
||||
var is_berserker: bool = false # 是否处于狂暴状态
|
||||
var berserker_end_time: float = 0.0 # 狂暴结束时间
|
||||
|
||||
#技能-自爆
|
||||
#技能-死亡自爆
|
||||
var enable_self_destruct_skill: bool = false
|
||||
var self_destruct_damage: float = 50.0 # 自爆伤害值
|
||||
|
||||
@@ -112,6 +112,12 @@ var respawn_health_percentage: float = 0.3 # 重生时恢复的血量百分比
|
||||
var max_respawn_count: int = 1 # 最大重生次数
|
||||
var current_respawn_count: int = 0 # 当前已重生次数
|
||||
|
||||
#技能-反弹伤害
|
||||
var enable_damage_reflection_skill: bool = false
|
||||
var damage_reflection_cooldown: float = 10.0 # 反弹伤害冷却时间(秒)
|
||||
var damage_reflection_cooldown_end_time: float = 0.0 # 反弹伤害冷却结束时间
|
||||
var damage_reflection_percentage: float = 0.5 # 反弹伤害百分比(50%)
|
||||
|
||||
#击退效果
|
||||
var enable_knockback: bool = true # 是否启用击退效果
|
||||
var knockback_force: float = 300.0 # 击退力度(像素/秒)
|
||||
@@ -179,6 +185,8 @@ var update_ui_timer: float = 0.0
|
||||
var ui_update_interval: float = 0.2 # UI更新间隔,减少频繁更新
|
||||
var ai_update_timer: float = 0.0
|
||||
var ai_update_interval: float = 0.05 # AI更新间隔,平衡性能和反应速度
|
||||
|
||||
var last_direction_x = -1 # 假设初始向右
|
||||
#============================杂项未处理===============================
|
||||
|
||||
|
||||
@@ -359,25 +367,31 @@ func move_towards_target():
|
||||
var direction = (current_target.global_position - global_position).normalized()
|
||||
velocity = direction * move_speed
|
||||
|
||||
# 翻转精灵
|
||||
if direction.x < 0:
|
||||
pet_image.flip_h = false
|
||||
left_tool_image.flip_h = true
|
||||
right_tool_image.flip_h = true
|
||||
left_tool_image.position = Vector2(-12.5,3.5)
|
||||
right_tool_image.position = Vector2(-7.5,-6.25)
|
||||
#left_tool_image.rotation = 21.8
|
||||
#right_tool_image.rotation = -14.5
|
||||
#==================只有当方向发生变化时才执行翻转逻辑=======================
|
||||
if direction.x != last_direction_x:
|
||||
if direction.x < 0:
|
||||
# 向左转
|
||||
pet_image.flip_h = false
|
||||
left_tool_image.flip_h = true
|
||||
right_tool_image.flip_h = true
|
||||
|
||||
# 只翻转一次位置(使用初始位置的相反数)
|
||||
left_tool_image.position.x = -abs(left_tool_image.position.x)
|
||||
right_tool_image.position.x = -abs(right_tool_image.position.x)
|
||||
else:
|
||||
# 向右转
|
||||
pet_image.flip_h = true
|
||||
left_tool_image.flip_h = false
|
||||
right_tool_image.flip_h = false
|
||||
|
||||
# 只翻转一次位置(使用初始位置的绝对值)
|
||||
left_tool_image.position.x = abs(left_tool_image.position.x)
|
||||
right_tool_image.position.x = abs(right_tool_image.position.x)
|
||||
|
||||
# 更新上一次的方向记录
|
||||
last_direction_x = direction.x
|
||||
#==================只有当方向发生变化时才执行翻转逻辑=======================
|
||||
|
||||
else:
|
||||
pet_image.flip_h = true
|
||||
left_tool_image.flip_h = false
|
||||
right_tool_image.flip_h = false
|
||||
left_tool_image.position = Vector2(12.5,3.5)
|
||||
right_tool_image.position = Vector2(7.5,-6.25)
|
||||
#left_tool_image.rotation = -21.8
|
||||
#right_tool_image.rotation = 14.5
|
||||
|
||||
#检查边界碰撞并处理反弹和伤害
|
||||
func check_boundary_collision():
|
||||
@@ -462,7 +476,6 @@ func perform_melee_attack():
|
||||
current_state = PetState.IDLE
|
||||
)
|
||||
|
||||
|
||||
#应用宠物外观图片
|
||||
func apply_pet_image(pet: NewPetBase, image_path: String):
|
||||
"""应用宠物外观图片"""
|
||||
@@ -614,6 +627,20 @@ func take_damage(damage: float, attacker: NewPetBase):
|
||||
# 闪避成功
|
||||
return # 闪避成功
|
||||
|
||||
# 反弹伤害技能检查
|
||||
if enable_damage_reflection_skill and attacker != null and is_instance_valid(attacker) and attacker != self:
|
||||
var current_time = Time.get_ticks_msec() / 1000.0
|
||||
# 检查冷却时间
|
||||
if current_time >= damage_reflection_cooldown_end_time:
|
||||
# 计算反弹伤害
|
||||
var reflection_damage = damage * damage_reflection_percentage
|
||||
# 对攻击者造成反弹伤害(不会再次触发反弹,避免无限循环)
|
||||
attacker.take_reflection_damage(reflection_damage, self)
|
||||
# 设置冷却时间
|
||||
damage_reflection_cooldown_end_time = current_time + damage_reflection_cooldown
|
||||
# 发射技能信号
|
||||
pet_skill_used.emit(self, "反弹伤害")
|
||||
|
||||
# 护盾优先吸收伤害
|
||||
if current_shield > 0:
|
||||
var shield_damage = min(current_shield, damage)
|
||||
@@ -638,6 +665,39 @@ func take_damage(damage: float, attacker: NewPetBase):
|
||||
if current_health <= 0:
|
||||
die()
|
||||
|
||||
#受到反弹伤害(不会再次触发反弹效果)
|
||||
func take_reflection_damage(damage: float, reflector: NewPetBase):
|
||||
"""受到反弹伤害(不会再次触发反弹效果)"""
|
||||
if not is_alive:
|
||||
return
|
||||
|
||||
# 闪避检查
|
||||
if randf() < dodge_rate:
|
||||
# 闪避成功
|
||||
return
|
||||
|
||||
# 护盾优先吸收伤害
|
||||
if current_shield > 0:
|
||||
var shield_damage = min(current_shield, damage)
|
||||
current_shield -= shield_damage
|
||||
damage -= shield_damage
|
||||
|
||||
# 护盾消耗完后,剩余伤害扣除生命值
|
||||
if damage > 0:
|
||||
current_health -= damage
|
||||
|
||||
# 受伤视觉效果(短暂变红)
|
||||
if not is_berserker:
|
||||
pet_image.modulate = Color(1.3, 0.7, 0.7, 1.0)
|
||||
get_tree().create_timer(0.15).timeout.connect(func():
|
||||
if not is_berserker and is_alive:
|
||||
pet_image.modulate = Color(1.0, 1.0, 1.0, 1.0)
|
||||
)
|
||||
|
||||
# 检查死亡
|
||||
if current_health <= 0:
|
||||
die()
|
||||
|
||||
#治疗
|
||||
func heal(amount: float):
|
||||
"""治疗"""
|
||||
@@ -1033,11 +1093,31 @@ func update_patrol_ai():
|
||||
pet_image.animation = "walk"
|
||||
velocity = direction * patrol_speed
|
||||
|
||||
# 翻转精灵
|
||||
if direction.x < 0:
|
||||
pet_image.flip_h = false
|
||||
else:
|
||||
pet_image.flip_h = true
|
||||
#==================只有当方向发生变化时才执行翻转逻辑=======================
|
||||
if direction.x != last_direction_x:
|
||||
if direction.x < 0:
|
||||
# 向左转
|
||||
pet_image.flip_h = false
|
||||
left_tool_image.flip_h = true
|
||||
right_tool_image.flip_h = true
|
||||
|
||||
# 只翻转一次位置(使用初始位置的相反数)
|
||||
left_tool_image.position.x = -abs(left_tool_image.position.x)
|
||||
right_tool_image.position.x = -abs(right_tool_image.position.x)
|
||||
else:
|
||||
# 向右转
|
||||
pet_image.flip_h = true
|
||||
left_tool_image.flip_h = false
|
||||
right_tool_image.flip_h = false
|
||||
|
||||
# 只翻转一次位置(使用初始位置的绝对值)
|
||||
left_tool_image.position.x = abs(left_tool_image.position.x)
|
||||
right_tool_image.position.x = abs(right_tool_image.position.x)
|
||||
|
||||
# 更新上一次的方向记录
|
||||
last_direction_x = direction.x
|
||||
#==================只有当方向发生变化时才执行翻转逻辑=======================
|
||||
|
||||
else:
|
||||
# 到达目标位置,待机
|
||||
current_state = PetState.IDLE
|
||||
|
||||
@@ -76,6 +76,11 @@ func _ready():
|
||||
# 初始化UI
|
||||
battle_end_panel.visible = false
|
||||
return_farm_button.pressed.connect(_on_return_farm_pressed)
|
||||
# 连接可见性改变信号
|
||||
visibility_changed.connect(_on_visibility_changed)
|
||||
# 连接确认弹窗信号
|
||||
confirm_dialog.confirmed.connect(_on_assist_confirmed)
|
||||
confirm_dialog.canceled.connect(_on_assist_canceled)
|
||||
# 初始化宠物配置系统
|
||||
pet_config = PetConfig.new()
|
||||
# 等待一帧确保PetConfig的_ready函数执行完毕
|
||||
@@ -83,9 +88,7 @@ func _ready():
|
||||
# 初始化战斗日志
|
||||
battle_details_text.text = "[color=green]战斗准备中...[/color]\n"
|
||||
|
||||
# 连接确认弹窗信号
|
||||
confirm_dialog.confirmed.connect(_on_assist_confirmed)
|
||||
confirm_dialog.canceled.connect(_on_assist_canceled)
|
||||
|
||||
|
||||
# 美化确认弹窗
|
||||
setup_confirm_dialog()
|
||||
@@ -93,11 +96,13 @@ func _ready():
|
||||
# 延迟一帧后设置演示数据,确保所有节点都已准备好
|
||||
await get_tree().process_frame
|
||||
#setup_farm_battle()
|
||||
# 可以调用测试函数进行本地测试
|
||||
#setup_test_battle()
|
||||
|
||||
func _process(delta):
|
||||
# 更新时间显示(无论什么状态都显示)
|
||||
update_time_display()
|
||||
|
||||
#
|
||||
# 更新辅助功能冷却计时器
|
||||
update_assist_cooldowns(delta)
|
||||
|
||||
@@ -131,6 +136,72 @@ func _process(delta):
|
||||
#========================基础函数======================
|
||||
|
||||
|
||||
#=====================本地测试函数===========================
|
||||
# 本地测试对战函数 - 方便调试各种宠物属性
|
||||
func setup_test_battle():
|
||||
"""设置本地测试对战,可以快速测试各种宠物配置和属性"""
|
||||
print("[测试] 开始设置本地测试对战")
|
||||
|
||||
# 清理现有战斗
|
||||
clear_all_pets()
|
||||
|
||||
# 设置队伍名称
|
||||
team_a_name = "测试队伍A"
|
||||
team_b_name = "测试队伍B"
|
||||
|
||||
# 创建测试队伍A的宠物数据(进攻方)
|
||||
var team_a_data = [
|
||||
{"config_key": "烈焰鸟"}, # 使用配置文件中的烈焰鸟
|
||||
]
|
||||
|
||||
# 创建测试队伍B的宠物数据(防守方)
|
||||
var team_b_data = [
|
||||
{"config_key": "小蓝虫"}, # 使用配置文件中的小蓝虫
|
||||
]
|
||||
|
||||
# 开始战斗
|
||||
start_battle(team_a_data, team_b_data)
|
||||
|
||||
# 等待宠物生成完成
|
||||
await get_tree().process_frame
|
||||
|
||||
# 获取生成的宠物进行属性调试
|
||||
var redman_pet = null # 烈焰鸟
|
||||
var bluebug_pet = null # 大蓝虫
|
||||
var smallbug_pet = null # 小蓝虫
|
||||
var smallblue_pet = null # 小蓝
|
||||
|
||||
# 查找特定宠物
|
||||
for pet in team_a_pets:
|
||||
if pet.pet_type == "烈焰鸟":
|
||||
redman_pet = pet
|
||||
elif pet.pet_type == "大蓝虫":
|
||||
bluebug_pet = pet
|
||||
|
||||
for pet in team_b_pets:
|
||||
if pet.pet_type == "小蓝虫":
|
||||
smallbug_pet = pet
|
||||
elif pet.pet_type == "小蓝":
|
||||
smallblue_pet = pet
|
||||
|
||||
# =================== 在这里可以一行代码调试宠物属性 ===================
|
||||
# 示例:开启烈焰鸟的反弹伤害技能
|
||||
if redman_pet:
|
||||
redman_pet.enable_damage_reflection_skill = true
|
||||
redman_pet.damage_reflection_percentage = 0.8 # 反弹80%伤害
|
||||
redman_pet.damage_reflection_cooldown = 5.0 # 5秒冷却
|
||||
print("[测试] 烈焰鸟开启反弹伤害技能")
|
||||
|
||||
|
||||
|
||||
print("[测试] 本地测试对战设置完成,可以观察宠物战斗效果")
|
||||
|
||||
# 添加测试日志
|
||||
add_battle_log("[color=cyan]本地测试对战开始![/color]")
|
||||
add_battle_log("[color=yellow]队伍A: 烈焰鸟(反弹伤害) + 大蓝虫(召唤增强)[/color]")
|
||||
add_battle_log("[color=yellow]队伍B: 小蓝虫(狂暴模式) + 小蓝(自爆技能)[/color]")
|
||||
|
||||
|
||||
#=====================UI显示===========================
|
||||
#更新时间显示
|
||||
func update_time_display():
|
||||
@@ -276,6 +347,14 @@ func _on_stop_battle_button_pressed() -> void:
|
||||
for bullet in bullets:
|
||||
bullet.queue_free()
|
||||
|
||||
# 面板显示时的处理
|
||||
func _on_visibility_changed():
|
||||
if visible:
|
||||
GlobalVariables.isZoomDisabled = true
|
||||
pass
|
||||
else:
|
||||
GlobalVariables.isZoomDisabled = false
|
||||
pass
|
||||
#=====================UI显示===========================
|
||||
|
||||
|
||||
@@ -394,7 +473,11 @@ func apply_server_pet_data(pet: NewPetBase, pet_data: Dictionary):
|
||||
# 生命与防御
|
||||
if pet_data.has("max_health"):
|
||||
pet.max_health = pet_data["max_health"]
|
||||
pet.current_health = pet.max_health
|
||||
# 优先使用服务器返回的当前生命值,否则使用最大生命值
|
||||
if pet_data.has("pet_current_health"):
|
||||
pet.current_health = pet_data["pet_current_health"]
|
||||
else:
|
||||
pet.current_health = pet.max_health
|
||||
if pet_data.has("enable_health_regen"):
|
||||
pet.enable_health_regen = pet_data["enable_health_regen"]
|
||||
if pet_data.has("health_regen"):
|
||||
@@ -974,10 +1057,6 @@ func setup_steal_battle(attacker_pets: Array, defender_pets: Array, attacker_nam
|
||||
team_a_name = attacker_name + "(攻击方)"
|
||||
team_b_name = defender_name + "(防守方)"
|
||||
|
||||
# 更新UI显示
|
||||
#team_a_label.text = team_a_name
|
||||
#team_b_label.text = team_b_name
|
||||
|
||||
# 获取队伍位置点
|
||||
var team_a_positions = get_team_positions(team_a_node)
|
||||
var team_b_positions = get_team_positions(team_b_node)
|
||||
|
||||
@@ -101,7 +101,7 @@ vertical_alignment = 1
|
||||
layout_mode = 0
|
||||
offset_top = 50.0
|
||||
offset_right = 257.0
|
||||
offset_bottom = 300.0
|
||||
offset_bottom = 578.0
|
||||
|
||||
[node name="TeamAHeal" type="Button" parent="PlayerSkillPanel/TeamASkills"]
|
||||
layout_mode = 2
|
||||
@@ -122,67 +122,67 @@ text = "团队护盾"
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 18
|
||||
disabled = true
|
||||
text = "测试"
|
||||
text = "暂无"
|
||||
|
||||
[node name="test2" type="Button" parent="PlayerSkillPanel/TeamASkills"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 18
|
||||
disabled = true
|
||||
text = "测试"
|
||||
text = "暂无"
|
||||
|
||||
[node name="test3" type="Button" parent="PlayerSkillPanel/TeamASkills"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 18
|
||||
disabled = true
|
||||
text = "测试"
|
||||
text = "暂无"
|
||||
|
||||
[node name="test4" type="Button" parent="PlayerSkillPanel/TeamASkills"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 18
|
||||
disabled = true
|
||||
text = "测试"
|
||||
text = "暂无"
|
||||
|
||||
[node name="test5" type="Button" parent="PlayerSkillPanel/TeamASkills"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 18
|
||||
disabled = true
|
||||
text = "测试"
|
||||
text = "暂无"
|
||||
|
||||
[node name="test6" type="Button" parent="PlayerSkillPanel/TeamASkills"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 18
|
||||
disabled = true
|
||||
text = "测试"
|
||||
text = "暂无"
|
||||
|
||||
[node name="test7" type="Button" parent="PlayerSkillPanel/TeamASkills"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 18
|
||||
disabled = true
|
||||
text = "测试"
|
||||
text = "暂无"
|
||||
|
||||
[node name="test8" type="Button" parent="PlayerSkillPanel/TeamASkills"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 18
|
||||
disabled = true
|
||||
text = "测试"
|
||||
text = "暂无"
|
||||
|
||||
[node name="test9" type="Button" parent="PlayerSkillPanel/TeamASkills"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 18
|
||||
disabled = true
|
||||
text = "测试"
|
||||
text = "暂无"
|
||||
|
||||
[node name="test10" type="Button" parent="PlayerSkillPanel/TeamASkills"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 18
|
||||
disabled = true
|
||||
text = "测试"
|
||||
text = "暂无"
|
||||
|
||||
[node name="test11" type="Button" parent="PlayerSkillPanel/TeamASkills"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 18
|
||||
disabled = true
|
||||
text = "测试"
|
||||
text = "暂无"
|
||||
|
||||
[node name="BattleControls" type="VBoxContainer" parent="PlayerSkillPanel"]
|
||||
layout_mode = 0
|
||||
|
||||
@@ -72,6 +72,11 @@ var summon_scale: float = 0.1 # 召唤小弟属性缩放比例(10%)
|
||||
#技能-死亡重生
|
||||
var enable_death_respawn_skill: bool = false
|
||||
var respawn_health_percentage: float = 0.3 # 重生时恢复的血量百分比(30%)
|
||||
|
||||
#技能-反弹伤害
|
||||
var enable_damage_reflection_skill: bool = false
|
||||
var damage_reflection_cooldown: float = 10.0 # 反弹伤害冷却时间(秒)
|
||||
var damage_reflection_percentage: float = 0.5 # 反弹伤害百分比(50%)
|
||||
#======================以后有新技能在这里添加==============================
|
||||
|
||||
# 移动属性
|
||||
@@ -121,6 +126,9 @@ var pet_configs: Dictionary = {
|
||||
"enable_summon_pet_skill": false,
|
||||
"enable_death_respawn_skill": true,
|
||||
"respawn_health_percentage": 0.4,
|
||||
"enable_damage_reflection_skill": true,
|
||||
"damage_reflection_cooldown": 8.0,
|
||||
"damage_reflection_percentage": 0.6,
|
||||
"move_speed": 180,
|
||||
"dodge_rate": 0.08,
|
||||
"element_type": "FIRE",
|
||||
@@ -160,6 +168,9 @@ var pet_configs: Dictionary = {
|
||||
"summon_count": 2,
|
||||
"summon_scale": 0.15,
|
||||
"enable_death_respawn_skill": false,
|
||||
"enable_damage_reflection_skill": true,
|
||||
"damage_reflection_cooldown": 12.0,
|
||||
"damage_reflection_percentage": 0.4,
|
||||
"move_speed": 120,
|
||||
"dodge_rate": 0.12,
|
||||
"element_type": "WATER",
|
||||
@@ -199,6 +210,9 @@ var pet_configs: Dictionary = {
|
||||
"summon_count": 2,
|
||||
"summon_scale": 0.15,
|
||||
"enable_death_respawn_skill": false,
|
||||
"enable_damage_reflection_skill": false,
|
||||
"damage_reflection_cooldown": 10.0,
|
||||
"damage_reflection_percentage": 0.5,
|
||||
"move_speed": 120,
|
||||
"dodge_rate": 0.12,
|
||||
"element_type": "WATER",
|
||||
@@ -238,6 +252,9 @@ var pet_configs: Dictionary = {
|
||||
"summon_count": 2,
|
||||
"summon_scale": 0.15,
|
||||
"enable_death_respawn_skill": false,
|
||||
"enable_damage_reflection_skill": false,
|
||||
"damage_reflection_cooldown": 10.0,
|
||||
"damage_reflection_percentage": 0.5,
|
||||
"move_speed": 120,
|
||||
"dodge_rate": 0.12,
|
||||
"element_type": "WATER",
|
||||
@@ -315,6 +332,9 @@ func get_default_config() -> Dictionary:
|
||||
"summon_scale": summon_scale,
|
||||
"enable_death_respawn_skill": enable_death_respawn_skill,
|
||||
"respawn_health_percentage": respawn_health_percentage,
|
||||
"enable_damage_reflection_skill": enable_damage_reflection_skill,
|
||||
"damage_reflection_cooldown": damage_reflection_cooldown,
|
||||
"damage_reflection_percentage": damage_reflection_percentage,
|
||||
"move_speed": move_speed,
|
||||
"dodge_rate": dodge_rate,
|
||||
"element_type": element_type,
|
||||
|
||||
Reference in New Issue
Block a user