diff --git a/autoload/BGM/script/bgm.gd b/autoload/BGM/script/bgm.gd index 7d0da1d..d8bfad8 100644 --- a/autoload/BGM/script/bgm.gd +++ b/autoload/BGM/script/bgm.gd @@ -12,3 +12,11 @@ func set_bgm(value): %BGM.play() tween = get_tree().create_tween() tween.tween_property(%BGM, "volume_db",0 , 0.5) +func play_effect(value): + %Effect.stream=value + %Effect.play() + + +func _on_bgm_finished() -> void: + %BGM.play() + pass # Replace with function body. diff --git a/autoload/BGM/tscn/bgm.tscn b/autoload/BGM/tscn/bgm.tscn index 419d1df..e3c7aa2 100644 --- a/autoload/BGM/tscn/bgm.tscn +++ b/autoload/BGM/tscn/bgm.tscn @@ -8,3 +8,9 @@ script = ExtResource("1_ah4s8") [node name="BGM" type="AudioStreamPlayer" parent="."] unique_name_in_owner = true bus = &"BGM" + +[node name="Effect" type="AudioStreamPlayer" parent="."] +unique_name_in_owner = true +bus = &"Effect" + +[connection signal="finished" from="BGM" to="." method="_on_bgm_finished"] diff --git a/autoload/global/script/global.gd b/autoload/global/script/global.gd index c169fc2..8d3cdf1 100644 --- a/autoload/global/script/global.gd +++ b/autoload/global/script/global.gd @@ -34,8 +34,30 @@ var now_game_data:Dictionary={ "gold":9999, "health":100, "spirit":999, - "map":"map_01" + "map":"map_01", + "move_ability":1, + "time_unix":999999 } +var triger:Dictionary={ + "change_event":func (data):now_game_flow.show_event(data), + "change_texture": func (data):now_game_flow.event_panel.change_texture(data), + "change_text":func(data):now_game_flow.event_panel.change_text(data), + "change_choice":func(data):now_game_flow.event_panel.change_choice(data), + "increase_health":func (data):now_game_data.health-=data, + +} +func call_triger(triger_type:String,data): + if triger.has(triger_type): + return triger[triger_type].call(data) + else: + return null +func move_scene(scene_id:String,distance): + + + + pass +func get_now_scene(): + return now_game_data["now_scene"] var now_game_flow:GameFlow func get_now_character_data(): return now_game_data["character_data"] @@ -45,6 +67,7 @@ func _ready() -> void: load_event_data() load_scene_data() load_character_data() + load_map_data() func load_texture_data(): var file=FileAccess.open(texture_json_path,FileAccess.READ) var str=file.get_as_text() diff --git a/class/map/map_class.gd b/class/map/map_class.gd index 773f704..ca813c9 100644 --- a/class/map/map_class.gd +++ b/class/map/map_class.gd @@ -4,13 +4,12 @@ class_name MapIndex signal click(scene_id:String) - - - - -func _on_linyi_pressed() -> void: - pass # Replace with function body. - - -func _on_jining_pressed() -> void: - pass # Replace with function body. +##点击某个场景后应当调用 +func click_scene(scene_id:String): + click.emit(scene_id) +##预留的获取地图坐标的接口,用来放置玩家当前位置图标 +func get_scene_global_pos(scene_id:String)->Vector2: + return Vector2(0,0) +##获取两地距离的接口 +func get_scene_distance(scene_from:String,scene_to:String): + return 100 diff --git a/json/event.json b/json/event.json index c70c58e..422b496 100644 --- a/json/event.json +++ b/json/event.json @@ -7,37 +7,59 @@ { "name":"测试选项1", "triger":[{ - "type":"change_scene" - }, - { - "type":"change_event", - "data":"event_01" + "type":"change_scene", + "data":"" }, + { "type":"change_texture", "data":"test_character" }, { - "type":"music", + "type":"change_choice", + "data":[ + { + "name":"测试选项更改后", + "triger":[] + } + ] + }, + { + "type":"play_effects", "data":"res://test/audio/attack_0.wav" }, { - "type":"fight" + "type":"BGM", + "data":"res://test/audio/attack_0.wav" }, { - "type":"identification" + "type":"fight", + "data":"" + }, { - "type":"change_attribute" + "type":"identification", + "data":"" }, { - "type":"change_value" + "type":"change_attribute", + "data":"" + }, + { + "type":"change_value", + "data":"" }, ] }, { - "name":"测试选项2" + "name":"测试选项2", + "triger":[ + { + "type":"change_event", + "data":"event_01" + }, + ] } ] } diff --git a/json/map.json b/json/map.json index dfc095e..c1576c2 100644 --- a/json/map.json +++ b/json/map.json @@ -2,6 +2,12 @@ "map_01": { "name":"测试地图01", - "index":[] + "index":["res://test/scene/map_example0.tscn", + "res://test/scene/map_example1.tscn", + "res://test/scene/map_example2.tscn" + ], + "scale_index":[1.2,2], + "scale_limit":[1,3], + "init_size":[1920,1080] } } diff --git a/scene/event.gd b/scene/event.gd index ba30bf2..af46fdb 100644 --- a/scene/event.gd +++ b/scene/event.gd @@ -40,23 +40,21 @@ func choice_click(event_data:Dictionary): - match i["type"]: - "change_event": - set_event_data(i["data"]) - "change_texture": - - event_texture.texture=Global.get_texture(i["data"]) - pass - "end": - hide() - "music": - audio_stream_player.stream=load(i["data"]) - audio_stream_player.play() - pass - - - pass + Global.call_triger(i["type"],i["data"]) pass pass - +func change_texture(texture_id:String): + event_texture.texture=Global.get_texture(texture_id) +func change_text(text:String): + event_intro.text=text + +func change_choice(choice_data:Array): + for i in choice_add_pos.get_children(): + i.queue_free() + for i in choice_data: + var new_btn=EVENT_CHOICE_BUTTON.instantiate() + choice_add_pos.add_child(new_btn) + new_btn.set_data(i) + new_btn.click.connect(choice_click) + pass diff --git a/scene/game_flow.gd b/scene/game_flow.gd index b42ddf8..be9a25f 100644 --- a/scene/game_flow.gd +++ b/scene/game_flow.gd @@ -29,7 +29,7 @@ func set_scene(id:String): var new_btn=GAME_FLOW_EVENT.instantiate() event.add_child(new_btn) new_btn.set_data(i) - new_btn.pressed.connect(event_pressed) + new_btn.pressed.connect(show_event) for i in scene_data["linked_scene"]: var new_place=GAME_FLOW_PLACE.instantiate() place_add.add_child(new_place) @@ -48,7 +48,7 @@ func place_pressed(data:Dictionary): await animation_player.animation_finished animation_mask.hide() pass -func event_pressed(event_data:Dictionary): +func show_event(event_id:String): event_panel.show() - event_panel.set_event_data(event_data["event"]) + event_panel.set_event_data(event_id) pass diff --git a/scene/game_flow_event.gd b/scene/game_flow_event.gd index 6896389..1172ebe 100644 --- a/scene/game_flow_event.gd +++ b/scene/game_flow_event.gd @@ -1,6 +1,6 @@ extends Panel @onready var label: Label = $Label -signal pressed(data:Dictionary) +signal pressed(event_id:String) var data:Dictionary func set_data(d:Dictionary): data=d @@ -8,5 +8,5 @@ func set_data(d:Dictionary): func _on_tool_button_pressed() -> void: - pressed.emit(data) + pressed.emit(data["event"]) pass # Replace with function body. diff --git a/scene/map.gd b/scene/map.gd index 06bdf9f..c5e85d2 100644 --- a/scene/map.gd +++ b/scene/map.gd @@ -5,13 +5,15 @@ extends Control @onready var pos: Label = $TextureRect/pos @onready var h_box_container: HBoxContainer = $ScrollContainer/HBoxContainer @onready var scroll_container: ScrollContainer = $ScrollContainer -@onready var map_0=$ScrollContainer/HBoxContainer/TabContainer/map_example -@onready var map_1=$ScrollContainer/HBoxContainer/TabContainer/TextureRect -@onready var map_2=$ScrollContainer/HBoxContainer/TabContainer/TextureRect2 -@onready var map_now:=$ScrollContainer/HBoxContainer/TabContainer/map_example +@onready var map_0 +@onready var map_1 +@onready var map_2 +@onready var map_now +@onready var map_add_pos: MarginContainer = $ScrollContainer/HBoxContainer/map_add_pos + var scale_rag:float=1: set(val): - if val>1.3 and val<1.5 and (scale_rag<1.3 or scale_rag>1.5): + if val>scale_index_1 and valscale_index_2): var t=get_tree().create_tween() t.tween_property(map_now,"modulate:a",0,0.1) t.tween_callback(map_now.hide) @@ -20,7 +22,7 @@ var scale_rag:float=1: map_1.show() map_now=map_1 t2.tween_property(map_1,"modulate:a",1,0.1) - elif val<=1.3 and scale_rag>1.3: + elif val<=scale_index_1 and scale_rag>scale_index_1: var t=get_tree().create_tween() t.tween_property(map_now,"modulate:a",0,0.1) t.tween_callback(map_now.hide) @@ -29,7 +31,7 @@ var scale_rag:float=1: map_0.show() map_now=map_0 t2.tween_property(map_0,"modulate:a",1,0.1) - elif val>1.5 and scale_rag<1.5: + elif val>scale_index_2 and scale_rag void: + set_map("map_01") h_box_container.custom_minimum_size=init_size pass # Replace with function body. @@ -78,12 +114,12 @@ func _gui_input(event: InputEvent) -> void: else: keep_tween.stop() keep_tween=create_tween() - keep_tween.tween_property(self,"scale_rag",clamp(scale_rag+0.2,scale_limit.x,scale_limit.y),0.1) + keep_tween.tween_property(self,"scale_rag",clamp(scale_rag+0.2,scale_limit_min,scale_limit_max),0.1) if Input.is_action_just_pressed("mouse_down"): if keep_tween==null: keep_tween=create_tween() else: keep_tween.stop() keep_tween=create_tween() - keep_tween.tween_property(self,"scale_rag",clamp(scale_rag-0.2,scale_limit.x,scale_limit.y),0.1) + keep_tween.tween_property(self,"scale_rag",clamp(scale_rag-0.2,scale_limit_min,scale_limit_max),0.1) diff --git a/scene/map.tscn b/scene/map.tscn index a0a7829..04c5944 100644 --- a/scene/map.tscn +++ b/scene/map.tscn @@ -49,18 +49,18 @@ size_flags_horizontal = 0 texture = ExtResource("2_slael") expand_mode = 3 -[node name="TabContainer" type="MarginContainer" parent="ScrollContainer/HBoxContainer"] +[node name="map_add_pos" type="MarginContainer" parent="ScrollContainer/HBoxContainer"] layout_mode = 2 size_flags_horizontal = 3 -[node name="map_example" parent="ScrollContainer/HBoxContainer/TabContainer" instance=ExtResource("5_jn1dj")] +[node name="map_example" parent="ScrollContainer/HBoxContainer/map_add_pos" instance=ExtResource("5_jn1dj")] layout_mode = 2 -[node name="TextureRect" parent="ScrollContainer/HBoxContainer/TabContainer" instance=ExtResource("6_a88yc")] +[node name="TextureRect" parent="ScrollContainer/HBoxContainer/map_add_pos" instance=ExtResource("6_a88yc")] visible = false layout_mode = 2 -[node name="TextureRect2" parent="ScrollContainer/HBoxContainer/TabContainer" instance=ExtResource("7_bvfra")] +[node name="TextureRect2" parent="ScrollContainer/HBoxContainer/map_add_pos" instance=ExtResource("7_bvfra")] visible = false layout_mode = 2 diff --git a/test/scene/map_example0.tscn b/test/scene/map_example0.tscn index 1e5fea3..2eb790c 100644 --- a/test/scene/map_example0.tscn +++ b/test/scene/map_example0.tscn @@ -10,7 +10,7 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 size_flags_horizontal = 3 -size_flags_vertical = 3 +size_flags_vertical = 6 texture = ExtResource("1_ihnyk") -expand_mode = 1 +expand_mode = 5 script = ExtResource("1_iwfll") diff --git a/test/scene/map_example1.tscn b/test/scene/map_example1.tscn index adeadad..b7296c7 100644 --- a/test/scene/map_example1.tscn +++ b/test/scene/map_example1.tscn @@ -9,6 +9,6 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 size_flags_horizontal = 3 -size_flags_vertical = 3 +size_flags_vertical = 6 texture = ExtResource("1_fj1ma") -expand_mode = 1 +expand_mode = 5 diff --git a/test/scene/map_example2.tscn b/test/scene/map_example2.tscn index 3678f2a..1a8bc02 100644 --- a/test/scene/map_example2.tscn +++ b/test/scene/map_example2.tscn @@ -9,6 +9,6 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 size_flags_horizontal = 3 -size_flags_vertical = 3 +size_flags_vertical = 6 texture = ExtResource("1_cnx2r") -expand_mode = 1 +expand_mode = 5