diff --git a/resource/animation/character/_design_hero01.aseprite b/resource/animation/character/_design_hero01.aseprite index 45b32a7..912e720 100644 Binary files a/resource/animation/character/_design_hero01.aseprite and b/resource/animation/character/_design_hero01.aseprite differ diff --git a/resource/animation/character/_design_hero01.png b/resource/animation/character/_design_hero01.png index 35c0c39..2ae8d66 100644 Binary files a/resource/animation/character/_design_hero01.png and b/resource/animation/character/_design_hero01.png differ diff --git a/resource/animation/character/hero01_move.aseprite b/resource/animation/character/hero01_move.aseprite index 2ef69b9..b72231f 100644 Binary files a/resource/animation/character/hero01_move.aseprite and b/resource/animation/character/hero01_move.aseprite differ diff --git a/resource/animation/character/hero01_move.png b/resource/animation/character/hero01_move.png index 16a2a20..f3fe68e 100644 Binary files a/resource/animation/character/hero01_move.png and b/resource/animation/character/hero01_move.png differ diff --git a/scene/level/level01_front_alley.tscn b/scene/level/level01_front_alley.tscn index 9b7917f..8380e00 100644 --- a/scene/level/level01_front_alley.tscn +++ b/scene/level/level01_front_alley.tscn @@ -26,6 +26,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.4) mesh_library = ExtResource("2_q76ck") cell_size = Vector3(0.64, 0.64, 0.64) data = { -"cells": PackedInt32Array(19, 10, 0, 18, 10, 0, 17, 10, 0, 16, 10, 0, 15, 10, 917504, 14, 10, 917504, 13, 10, 917504, 12, 10, 917504, 11, 10, 917504, 8, 10, 917504, 7, 10, 917504, 6, 10, 0, 5, 10, 0, 4, 10, 0, 3, 10, 0, 2, 10, 0, 1, 10, 0, 0, 10, 0, 0, 65535, 917504, 1, 65535, 917504, 2, 65535, 917504, 3, 65535, 917504, 4, 65535, 917504, 5, 65535, 917504, 6, 65535, 917504, 7, 65535, 917504, 8, 65535, 917504, 9, 65535, 917504, 12, 65535, 917504, 13, 65535, 917504, 14, 65535, 917504, 15, 65535, 917504, 16, 65535, 917504, 17, 65535, 917504, 18, 65535, 917504, 19, 65535, 917504, 10, 65535, 917504, 11, 65535, 917504, 20, 65535, 917504, 21, 65535, 917504, 22, 65535, 917504, 23, 65535, 917504, 24, 65535, 917504, 25, 65535, 917504, 34, 65535, 1245184, 35, 65535, 917504, 36, 65535, 917504, 37, 65535, 917504, 38, 65535, 917504, 39, 65535, 917504, 39, 10, 917504, 38, 10, 917504, 37, 10, 917504, 36, 10, 917504, 35, 10, 917504, 34, 10, 917504, 29, 10, 917504, 28, 10, 917504, 27, 10, 917504, 26, 10, 917504, 25, 10, 917504, 24, 10, 917504, 23, 10, 917504, 22, 10, 917504, 21, 10, 917504, 20, 10, 917504, 9, 10, 917504, 10, 10, 917504, 40, 65535, 1245184, 41, 65535, 1245184, 42, 65535, 1245184, 43, 65535, 1245184, 44, 65535, 1245184, 45, 65535, 1245184, 46, 65535, 1245184, 47, 65535, 1245184, 48, 65535, 1245184, 59, 65535, 1245184, 58, 65535, 1245184, 57, 65535, 1245184, 56, 65535, 1245184, 55, 65535, 1245184, 54, 65535, 1245184, 53, 65535, 1245184, 52, 65535, 1245184, 51, 65535, 1245184, 50, 65535, 1245184, 49, 65535, 1245184, 59, 0, 1245184, 59, 1, 1245184, 59, 2, 1245184, 59, 3, 1245184, 59, 6, 1245184, 59, 7, 1245184, 59, 8, 1245184, 59, 9, 1245184, 59, 10, 1245184, 58, 10, 1245184, 57, 10, 1245184, 56, 10, 1245184, 55, 10, 1245184, 54, 10, 1245184, 53, 10, 1245184, 52, 10, 1245184, 51, 10, 1245184, 50, 10, 1245184, 49, 10, 1245184, 48, 10, 1245184, 47, 10, 1245184, 46, 10, 1245184, 45, 10, 1245184, 44, 10, 1245184, 43, 10, 1245184, 42, 10, 1245184, 41, 10, 1245184, 40, 10, 1245184, 0, 0, 1245184, 0, 1, 1245184, 0, 2, 1245184, 0, 3, 1245184, 0, 6, 1245184, 0, 7, 1245184, 0, 8, 1245184, 0, 9, 1245184, 26, 65535, 1245184, 27, 65535, 1245184, 28, 65535, 1245184, 33, 65535, 1245184, 32, 65535, 1245184) +"cells": PackedInt32Array(19, 10, 0, 18, 10, 0, 17, 10, 0, 16, 10, 0, 15, 10, 917504, 14, 10, 917504, 13, 10, 917504, 12, 10, 917504, 11, 10, 917504, 8, 10, 917504, 7, 10, 917504, 6, 10, 0, 5, 10, 0, 4, 10, 0, 3, 10, 0, 2, 10, 0, 1, 10, 0, 0, 10, 0, 0, 65535, 917504, 1, 65535, 917504, 2, 65535, 917504, 3, 65535, 917504, 4, 65535, 917504, 5, 65535, 917504, 6, 65535, 917504, 7, 65535, 917504, 8, 65535, 917504, 9, 65535, 917504, 12, 65535, 917504, 13, 65535, 917504, 14, 65535, 917504, 15, 65535, 917504, 16, 65535, 917504, 17, 65535, 917504, 18, 65535, 917504, 19, 65535, 917504, 10, 65535, 917504, 11, 65535, 917504, 20, 65535, 917504, 21, 65535, 917504, 22, 65535, 917504, 23, 65535, 917504, 24, 65535, 917504, 25, 65535, 917504, 34, 65535, 1245184, 35, 65535, 917504, 36, 65535, 917504, 37, 65535, 917504, 38, 65535, 917504, 39, 65535, 917504, 39, 10, 917504, 38, 10, 917504, 37, 10, 917504, 36, 10, 917504, 35, 10, 917504, 34, 10, 917504, 29, 10, 917504, 28, 10, 917504, 27, 10, 917504, 26, 10, 917504, 25, 10, 917504, 24, 10, 917504, 23, 10, 917504, 22, 10, 917504, 21, 10, 917504, 20, 10, 917504, 9, 10, 917504, 10, 10, 917504, 40, 65535, 1245184, 41, 65535, 1245184, 42, 65535, 1245184, 43, 65535, 1245184, 44, 65535, 1245184, 45, 65535, 1245184, 46, 65535, 1245184, 47, 65535, 1245184, 48, 65535, 1245184, 59, 65535, 1245184, 58, 65535, 1245184, 57, 65535, 1245184, 56, 65535, 1245184, 55, 65535, 1245184, 54, 65535, 1245184, 53, 65535, 1245184, 52, 65535, 1245184, 51, 65535, 1245184, 50, 65535, 1245184, 49, 65535, 1245184, 59, 0, 1245184, 59, 1, 1245184, 59, 2, 1245184, 59, 3, 1245184, 59, 6, 1245184, 59, 7, 1245184, 59, 8, 1245184, 59, 9, 1245184, 59, 10, 1245184, 58, 10, 1245184, 57, 10, 1245184, 56, 10, 1245184, 55, 10, 1245184, 54, 10, 1245184, 53, 10, 1245184, 52, 10, 1245184, 51, 10, 1245184, 50, 10, 1245184, 49, 10, 1245184, 48, 10, 1245184, 47, 10, 1245184, 46, 10, 1245184, 45, 10, 1245184, 44, 10, 1245184, 43, 10, 1245184, 42, 10, 1245184, 41, 10, 1245184, 40, 10, 1245184, 0, 0, 1245184, 0, 1, 1245184, 0, 2, 1245184, 0, 3, 1245184, 0, 6, 1245184, 0, 7, 1245184, 0, 8, 1245184, 0, 9, 1245184, 26, 65535, 1245184, 27, 65535, 1245184, 33, 65535, 1245184, 32, 65535, 1245184) } metadata/_editor_floor_ = Vector3(0, 0, 0) diff --git a/scene/ui/hud_screen.tscn b/scene/ui/hud_screen.tscn index 9e1e92d..5b00be9 100644 --- a/scene/ui/hud_screen.tscn +++ b/scene/ui/hud_screen.tscn @@ -1,8 +1,45 @@ -[gd_scene load_steps=4 format=3 uid="uid://126wph4owvoy"] +[gd_scene load_steps=8 format=3 uid="uid://126wph4owvoy"] [ext_resource type="Texture2D" uid="uid://cwhu1ec03t3c8" path="res://resource/ui/hud/headbar_hp_empty.png" id="1_flgf6"] [ext_resource type="Texture2D" uid="uid://b4ly1exl0owck" path="res://resource/ui/hud/headbar_hp.png" id="2_sktwb"] -[ext_resource type="Script" path="res://script/ui/headbar/headbar_page.gd" id="3_fb4si"] +[ext_resource type="Script" path="res://script/ui/hud/headbar_page.gd" id="3_6chl0"] +[ext_resource type="Script" path="res://script/ui/hud/loading_page.gd" id="4_jqajt"] + +[sub_resource type="Animation" id="Animation_x6v17"] +resource_name = "start" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("ColorRect:color") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.2), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Color(0, 0, 0, 0), Color(0, 0, 0, 1)] +} + +[sub_resource type="Animation" id="Animation_4kxot"] +resource_name = "end" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("ColorRect:color") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.3), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Color(0, 0, 0, 1), Color(0, 0, 0, 0)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_fofuj"] +_data = { +"end": SubResource("Animation_4kxot"), +"start": SubResource("Animation_x6v17") +} [node name="HudScreen" type="CanvasLayer"] @@ -38,4 +75,23 @@ layout_mode = 3 anchors_preset = 0 offset_right = 40.0 offset_bottom = 40.0 -script = ExtResource("3_fb4si") +script = ExtResource("3_6chl0") + +[node name="LoadingPage" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 0 +offset_right = 40.0 +offset_bottom = 40.0 +script = ExtResource("4_jqajt") + +[node name="ColorRect" type="ColorRect" parent="LoadingPage"] +layout_mode = 0 +offset_right = 640.0 +offset_bottom = 360.0 +color = Color(0, 0, 0, 1) + +[node name="AnimationPlayer" type="AnimationPlayer" parent="LoadingPage"] +unique_name_in_owner = true +libraries = { +"": SubResource("AnimationLibrary_fofuj") +} diff --git a/scene/ui/item/headbar.tscn b/scene/ui/item/headbar.tscn index 4c406d9..8bf214d 100644 --- a/scene/ui/item/headbar.tscn +++ b/scene/ui/item/headbar.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://dy0u26ba7dle"] -[ext_resource type="Script" path="res://script/ui/headbar/headbar.gd" id="1_j1xlt"] +[ext_resource type="Script" path="res://script/ui/hud/headbar.gd" id="1_k0rtd"] [ext_resource type="Texture2D" uid="uid://cwhu1ec03t3c8" path="res://resource/ui/hud/headbar_hp_empty.png" id="2_g5t31"] [ext_resource type="Texture2D" uid="uid://b4ly1exl0owck" path="res://resource/ui/hud/headbar_hp.png" id="3_vh1p5"] @@ -11,7 +11,7 @@ offset_left = 256.0 offset_top = 88.0 offset_right = 256.0 offset_bottom = 88.0 -script = ExtResource("1_j1xlt") +script = ExtResource("1_k0rtd") [node name="HpBar" type="TextureProgressBar" parent="."] unique_name_in_owner = true diff --git a/scene/ui/item/hit_text.tscn b/scene/ui/item/hit_text.tscn index ef58757..216d32f 100644 --- a/scene/ui/item/hit_text.tscn +++ b/scene/ui/item/hit_text.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=10 format=3 uid="uid://cxyly5ithpv5i"] -[ext_resource type="Script" path="res://script/ui/headbar/hit_text.gd" id="1_re03i"] +[ext_resource type="Script" path="res://script/ui/hud/hit_text.gd" id="1_c1sms"] [sub_resource type="Animation" id="Animation_b5roo"] length = 0.001 @@ -218,7 +218,7 @@ offset_bottom = 15.0 grow_horizontal = 2 grow_vertical = 2 pivot_offset = Vector2(20, 20) -script = ExtResource("1_re03i") +script = ExtResource("1_c1sms") [node name="Label" type="Label" parent="."] unique_name_in_owner = true @@ -229,9 +229,10 @@ anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -offset_top = -20.0 -offset_right = 59.9996 -offset_bottom = 10.0 +offset_left = 60.0 +offset_top = 10.0 +offset_right = 120.0 +offset_bottom = 40.0 grow_horizontal = 2 grow_vertical = 2 scale = Vector2(0.5, 0.5) diff --git a/script/_global/global.gd b/script/_global/global.gd index ea22df7..85f4f31 100644 --- a/script/_global/global.gd +++ b/script/_global/global.gd @@ -1,5 +1,8 @@ extends Node3D -var camera_mgr:CameraManager -var character_mgr:CharacterManager -var level_mgr:LevelManager +var camera_mgr : CameraManager +var character_mgr : CharacterManager +var level_mgr : LevelManager + +#全局状态 +var is_level_loading : bool diff --git a/script/_global/setting.gd b/script/_global/setting.gd index 40a53ba..820609e 100644 --- a/script/_global/setting.gd +++ b/script/_global/setting.gd @@ -12,3 +12,4 @@ const drag_air : float = 5 #地图 const starting_level : String = "level01_forecourt.tscn" +const level_loading_min_time : float = 0.2 diff --git a/script/character/buff.gd b/script/character/buff.gd index 809d94b..4df401f 100644 --- a/script/character/buff.gd +++ b/script/character/buff.gd @@ -126,6 +126,8 @@ func on_update_stun_recover(rate): remove_buff("stun_recover") #表现 +func on_start_freeze(rate):status.is_pause = true +func on_end_freeze(rate):status.is_pause = false func on_second_pause(rate):status.is_pause = true func on_end_pause(rate):status.is_pause = false diff --git a/script/character/player/player_info.gd b/script/character/player/player_info.gd index 0cf51cc..5888ab6 100644 --- a/script/character/player/player_info.gd +++ b/script/character/player/player_info.gd @@ -3,4 +3,6 @@ extends Node3D @onready var character = (get_owner() as Character) func _process(delta): + if Global.is_level_loading: + return MetSys.set_player_position(character.pos2D()) diff --git a/script/manager/character_manager.gd b/script/manager/character_manager.gd index 22e6d28..1025f03 100644 --- a/script/manager/character_manager.gd +++ b/script/manager/character_manager.gd @@ -7,7 +7,21 @@ var player_id : int func _ready(): Global.character_mgr = self + SignalManager.level_loading_start.connect(on_level_loading_start) + SignalManager.level_loading_end.connect(on_level_loading_end) +func on_level_loading_start(): + var player = get_player() + if player: + player.add_buff("freeze",-1) + for enemy in get_enemy_list(player_id): + SignalManager.character_die.emit(enemy.id()) + destroy_character(enemy.id()) + +func on_level_loading_end(): + var player = get_player() + if player:player.remove_buff("freeze") + func create_character(cfg:CharacterCfg,team:Enum.ETeam,pos:Vector3): var characterNode:Node match cfg.type: diff --git a/script/manager/level_manager.gd b/script/manager/level_manager.gd index 6374107..40779b4 100644 --- a/script/manager/level_manager.gd +++ b/script/manager/level_manager.gd @@ -3,6 +3,8 @@ extends Node3D class_name LevelManager var level: Node3D +var level_path : String +var load_time : float func _ready(): Global.level_mgr = self @@ -12,14 +14,45 @@ func init(): goto_level(MetSys.get_full_room_path(Setting.starting_level)) MetSys.room_changed.connect(on_room_changed) -func goto_level(level_path: String): +func _process(delta): + if not Global.is_level_loading: + return + if load_time > 0: + load_time -= delta + return + var status = ResourceLoader.load_threaded_get_status(level_path) + match status: + ResourceLoader.ThreadLoadStatus.THREAD_LOAD_IN_PROGRESS:return + ResourceLoader.ThreadLoadStatus.THREAD_LOAD_LOADED:pass + _:print("关卡加载错误");return + goto_level_end() + +func on_room_changed(target_level: String): + goto_level(MetSys.get_full_room_path(target_level)) + +func goto_level(new_level_path: String): + if Global.is_level_loading: + print("连续进入关卡:",new_level_path) + return + print("goto_level:",new_level_path) + level_path = new_level_path + ResourceLoader.load_threaded_request(level_path) + Global.is_level_loading = true + if level: + load_time = Setting.level_loading_min_time + SignalManager.level_loading_start.emit() + else: + load_time = 0 + goto_level_end() + +func goto_level_end(): var prev_level_position := Vector2i.MAX if level: prev_level_position = MetSys.get_current_room_instance().get_base_coords() level.queue_free() level = null - - level = load(level_path).instantiate() + + level = ResourceLoader.load_threaded_get(level_path).instantiate() add_child(level) MetSys.current_layer = MetSys.get_current_room_instance().get_layer() var level_size = MetSys.get_current_room_instance().get_size() @@ -32,8 +65,7 @@ func goto_level(level_path: String): var pos_change_xz = Vector2(level_position_now - prev_level_position) * MetSys.settings.in_game_cell_size pos_pre.x -= pos_change_xz.x pos_pre.z -= pos_change_xz.y - print(player.pos(),pos_pre) player.set_pos(pos_pre) - -func on_room_changed(target_level: String): - goto_level(MetSys.get_full_room_path(target_level)) + + Global.is_level_loading = false + SignalManager.level_loading_end.emit() diff --git a/script/manager/signal_manager.gd b/script/manager/signal_manager.gd index c03f9e8..3c2e858 100644 --- a/script/manager/signal_manager.gd +++ b/script/manager/signal_manager.gd @@ -20,3 +20,5 @@ signal character_hit_damage #level signal level_size_change +signal level_loading_start +signal level_loading_end diff --git a/script/ui/headbar/headbar.gd b/script/ui/hud/headbar.gd similarity index 100% rename from script/ui/headbar/headbar.gd rename to script/ui/hud/headbar.gd diff --git a/script/ui/headbar/headbar_page.gd b/script/ui/hud/headbar_page.gd similarity index 100% rename from script/ui/headbar/headbar_page.gd rename to script/ui/hud/headbar_page.gd diff --git a/script/ui/headbar/hit_text.gd b/script/ui/hud/hit_text.gd similarity index 100% rename from script/ui/headbar/hit_text.gd rename to script/ui/hud/hit_text.gd diff --git a/script/ui/hud/loading_page.gd b/script/ui/hud/loading_page.gd new file mode 100644 index 0000000..5f72347 --- /dev/null +++ b/script/ui/hud/loading_page.gd @@ -0,0 +1,14 @@ +extends Control + +@onready var animation = %AnimationPlayer as AnimationPlayer + +func _ready(): + SignalManager.level_loading_start.connect(on_level_loading_start) + SignalManager.level_loading_end.connect(on_level_loading_end) + +func on_level_loading_start(): + animation.play("start") + +func on_level_loading_end(): + animation.play("end") +