9.22上午
This commit is contained in:
parent
f89a8a85ab
commit
20539613bd
@ -12,3 +12,11 @@ func set_bgm(value):
|
|||||||
%BGM.play()
|
%BGM.play()
|
||||||
tween = get_tree().create_tween()
|
tween = get_tree().create_tween()
|
||||||
tween.tween_property(%BGM, "volume_db",0 , 0.5)
|
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.
|
||||||
|
@ -8,3 +8,9 @@ script = ExtResource("1_ah4s8")
|
|||||||
[node name="BGM" type="AudioStreamPlayer" parent="."]
|
[node name="BGM" type="AudioStreamPlayer" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
bus = &"BGM"
|
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"]
|
||||||
|
@ -34,8 +34,30 @@ var now_game_data:Dictionary={
|
|||||||
"gold":9999,
|
"gold":9999,
|
||||||
"health":100,
|
"health":100,
|
||||||
"spirit":999,
|
"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
|
var now_game_flow:GameFlow
|
||||||
func get_now_character_data():
|
func get_now_character_data():
|
||||||
return now_game_data["character_data"]
|
return now_game_data["character_data"]
|
||||||
@ -45,6 +67,7 @@ func _ready() -> void:
|
|||||||
load_event_data()
|
load_event_data()
|
||||||
load_scene_data()
|
load_scene_data()
|
||||||
load_character_data()
|
load_character_data()
|
||||||
|
load_map_data()
|
||||||
func load_texture_data():
|
func load_texture_data():
|
||||||
var file=FileAccess.open(texture_json_path,FileAccess.READ)
|
var file=FileAccess.open(texture_json_path,FileAccess.READ)
|
||||||
var str=file.get_as_text()
|
var str=file.get_as_text()
|
||||||
|
@ -4,13 +4,12 @@ class_name MapIndex
|
|||||||
signal click(scene_id:String)
|
signal click(scene_id:String)
|
||||||
|
|
||||||
|
|
||||||
|
##点击某个场景后应当调用
|
||||||
|
func click_scene(scene_id:String):
|
||||||
|
click.emit(scene_id)
|
||||||
|
##预留的获取地图坐标的接口,用来放置玩家当前位置图标
|
||||||
func _on_linyi_pressed() -> void:
|
func get_scene_global_pos(scene_id:String)->Vector2:
|
||||||
pass # Replace with function body.
|
return Vector2(0,0)
|
||||||
|
##获取两地距离的接口
|
||||||
|
func get_scene_distance(scene_from:String,scene_to:String):
|
||||||
func _on_jining_pressed() -> void:
|
return 100
|
||||||
pass # Replace with function body.
|
|
||||||
|
@ -7,37 +7,59 @@
|
|||||||
{
|
{
|
||||||
"name":"测试选项1",
|
"name":"测试选项1",
|
||||||
"triger":[{
|
"triger":[{
|
||||||
"type":"change_scene"
|
"type":"change_scene",
|
||||||
},
|
"data":""
|
||||||
{
|
|
||||||
"type":"change_event",
|
|
||||||
"data":"event_01"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"type":"change_texture",
|
"type":"change_texture",
|
||||||
"data":"test_character"
|
"data":"test_character"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type":"music",
|
"type":"change_choice",
|
||||||
|
"data":[
|
||||||
|
{
|
||||||
|
"name":"测试选项更改后",
|
||||||
|
"triger":[]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type":"play_effects",
|
||||||
"data":"res://test/audio/attack_0.wav"
|
"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"
|
||||||
|
},
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,12 @@
|
|||||||
"map_01":
|
"map_01":
|
||||||
{
|
{
|
||||||
"name":"测试地图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]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,23 +40,21 @@ func choice_click(event_data:Dictionary):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
match i["type"]:
|
Global.call_triger(i["type"],i["data"])
|
||||||
"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
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
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
|
||||||
|
@ -29,7 +29,7 @@ func set_scene(id:String):
|
|||||||
var new_btn=GAME_FLOW_EVENT.instantiate()
|
var new_btn=GAME_FLOW_EVENT.instantiate()
|
||||||
event.add_child(new_btn)
|
event.add_child(new_btn)
|
||||||
new_btn.set_data(i)
|
new_btn.set_data(i)
|
||||||
new_btn.pressed.connect(event_pressed)
|
new_btn.pressed.connect(show_event)
|
||||||
for i in scene_data["linked_scene"]:
|
for i in scene_data["linked_scene"]:
|
||||||
var new_place=GAME_FLOW_PLACE.instantiate()
|
var new_place=GAME_FLOW_PLACE.instantiate()
|
||||||
place_add.add_child(new_place)
|
place_add.add_child(new_place)
|
||||||
@ -48,7 +48,7 @@ func place_pressed(data:Dictionary):
|
|||||||
await animation_player.animation_finished
|
await animation_player.animation_finished
|
||||||
animation_mask.hide()
|
animation_mask.hide()
|
||||||
pass
|
pass
|
||||||
func event_pressed(event_data:Dictionary):
|
func show_event(event_id:String):
|
||||||
event_panel.show()
|
event_panel.show()
|
||||||
event_panel.set_event_data(event_data["event"])
|
event_panel.set_event_data(event_id)
|
||||||
pass
|
pass
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
extends Panel
|
extends Panel
|
||||||
@onready var label: Label = $Label
|
@onready var label: Label = $Label
|
||||||
signal pressed(data:Dictionary)
|
signal pressed(event_id:String)
|
||||||
var data:Dictionary
|
var data:Dictionary
|
||||||
func set_data(d:Dictionary):
|
func set_data(d:Dictionary):
|
||||||
data=d
|
data=d
|
||||||
@ -8,5 +8,5 @@ func set_data(d:Dictionary):
|
|||||||
|
|
||||||
|
|
||||||
func _on_tool_button_pressed() -> void:
|
func _on_tool_button_pressed() -> void:
|
||||||
pressed.emit(data)
|
pressed.emit(data["event"])
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
56
scene/map.gd
56
scene/map.gd
@ -5,13 +5,15 @@ extends Control
|
|||||||
@onready var pos: Label = $TextureRect/pos
|
@onready var pos: Label = $TextureRect/pos
|
||||||
@onready var h_box_container: HBoxContainer = $ScrollContainer/HBoxContainer
|
@onready var h_box_container: HBoxContainer = $ScrollContainer/HBoxContainer
|
||||||
@onready var scroll_container: ScrollContainer = $ScrollContainer
|
@onready var scroll_container: ScrollContainer = $ScrollContainer
|
||||||
@onready var map_0=$ScrollContainer/HBoxContainer/TabContainer/map_example
|
@onready var map_0
|
||||||
@onready var map_1=$ScrollContainer/HBoxContainer/TabContainer/TextureRect
|
@onready var map_1
|
||||||
@onready var map_2=$ScrollContainer/HBoxContainer/TabContainer/TextureRect2
|
@onready var map_2
|
||||||
@onready var map_now:=$ScrollContainer/HBoxContainer/TabContainer/map_example
|
@onready var map_now
|
||||||
|
@onready var map_add_pos: MarginContainer = $ScrollContainer/HBoxContainer/map_add_pos
|
||||||
|
|
||||||
var scale_rag:float=1:
|
var scale_rag:float=1:
|
||||||
set(val):
|
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 val<scale_index_2 and (scale_rag<scale_index_1 or scale_rag>scale_index_2):
|
||||||
var t=get_tree().create_tween()
|
var t=get_tree().create_tween()
|
||||||
t.tween_property(map_now,"modulate:a",0,0.1)
|
t.tween_property(map_now,"modulate:a",0,0.1)
|
||||||
t.tween_callback(map_now.hide)
|
t.tween_callback(map_now.hide)
|
||||||
@ -20,7 +22,7 @@ var scale_rag:float=1:
|
|||||||
map_1.show()
|
map_1.show()
|
||||||
map_now=map_1
|
map_now=map_1
|
||||||
t2.tween_property(map_1,"modulate:a",1,0.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()
|
var t=get_tree().create_tween()
|
||||||
t.tween_property(map_now,"modulate:a",0,0.1)
|
t.tween_property(map_now,"modulate:a",0,0.1)
|
||||||
t.tween_callback(map_now.hide)
|
t.tween_callback(map_now.hide)
|
||||||
@ -29,7 +31,7 @@ var scale_rag:float=1:
|
|||||||
map_0.show()
|
map_0.show()
|
||||||
map_now=map_0
|
map_now=map_0
|
||||||
t2.tween_property(map_0,"modulate:a",1,0.1)
|
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<scale_index_2:
|
||||||
var t=get_tree().create_tween()
|
var t=get_tree().create_tween()
|
||||||
t.tween_property(map_now,"modulate:a",0,0.1)
|
t.tween_property(map_now,"modulate:a",0,0.1)
|
||||||
t.tween_callback(map_now.hide)
|
t.tween_callback(map_now.hide)
|
||||||
@ -41,7 +43,36 @@ var scale_rag:float=1:
|
|||||||
resize_map(scale_rag,val,get_global_mouse_position(),init_size)
|
resize_map(scale_rag,val,get_global_mouse_position(),init_size)
|
||||||
scale_rag=val
|
scale_rag=val
|
||||||
pass
|
pass
|
||||||
@export var scale_limit:Vector2=Vector2(1,2)
|
var scale_limit_min:float=1
|
||||||
|
var scale_limit_max:float=2
|
||||||
|
var scale_index_1:float=1.2
|
||||||
|
var scale_index_2:float=1.5
|
||||||
|
var map_data:Dictionary
|
||||||
|
func set_map(id:String):
|
||||||
|
map_data=Global.get_map_data(id)
|
||||||
|
var map_index:Array=map_data["index"]
|
||||||
|
for i in map_add_pos.get_children():
|
||||||
|
i.queue_free()
|
||||||
|
var tscn=[load(map_index[0]).instantiate(),load(map_index[1]).instantiate(),load(map_index[2]).instantiate()]
|
||||||
|
for i in tscn:
|
||||||
|
map_add_pos.add_child(i)
|
||||||
|
i.click.connect(click)
|
||||||
|
map_0=tscn[0]
|
||||||
|
map_1=tscn[1]
|
||||||
|
map_2=tscn[2]
|
||||||
|
map_1.hide()
|
||||||
|
map_2.hide()
|
||||||
|
map_now=map_0
|
||||||
|
var scale_index:Array=map_data["scale_index"]
|
||||||
|
var scale_limit:Array=map_data["scale_limit"]
|
||||||
|
scale_limit_min=scale_limit[0]
|
||||||
|
scale_limit_max=scale_limit[1]
|
||||||
|
scale_index_1=scale_index[0]
|
||||||
|
scale_index_2=scale_index[1]
|
||||||
|
var _init_size=map_data["init_size"]
|
||||||
|
init_size=Vector2(_init_size[0],_init_size[1])
|
||||||
|
pass
|
||||||
|
|
||||||
func resize_map(before_rag:float,rag:float,mouse_pos:Vector2,init:Vector2):
|
func resize_map(before_rag:float,rag:float,mouse_pos:Vector2,init:Vector2):
|
||||||
var l=rag/before_rag
|
var l=rag/before_rag
|
||||||
var now_pos=Vector2(scroll_container.scroll_horizontal,scroll_container.scroll_vertical)+mouse_pos
|
var now_pos=Vector2(scroll_container.scroll_horizontal,scroll_container.scroll_vertical)+mouse_pos
|
||||||
@ -53,11 +84,16 @@ func resize_map(before_rag:float,rag:float,mouse_pos:Vector2,init:Vector2):
|
|||||||
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
func click(scene_id:String):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
var init_size:Vector2=Vector2(1920,1080)
|
var init_size:Vector2=Vector2(1920,1080)
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
set_map("map_01")
|
||||||
h_box_container.custom_minimum_size=init_size
|
h_box_container.custom_minimum_size=init_size
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
@ -78,12 +114,12 @@ func _gui_input(event: InputEvent) -> void:
|
|||||||
else:
|
else:
|
||||||
keep_tween.stop()
|
keep_tween.stop()
|
||||||
keep_tween=create_tween()
|
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 Input.is_action_just_pressed("mouse_down"):
|
||||||
if keep_tween==null:
|
if keep_tween==null:
|
||||||
keep_tween=create_tween()
|
keep_tween=create_tween()
|
||||||
else:
|
else:
|
||||||
keep_tween.stop()
|
keep_tween.stop()
|
||||||
keep_tween=create_tween()
|
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)
|
||||||
|
|
||||||
|
@ -49,18 +49,18 @@ size_flags_horizontal = 0
|
|||||||
texture = ExtResource("2_slael")
|
texture = ExtResource("2_slael")
|
||||||
expand_mode = 3
|
expand_mode = 3
|
||||||
|
|
||||||
[node name="TabContainer" type="MarginContainer" parent="ScrollContainer/HBoxContainer"]
|
[node name="map_add_pos" type="MarginContainer" parent="ScrollContainer/HBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
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
|
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
|
visible = false
|
||||||
layout_mode = 2
|
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
|
visible = false
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ anchor_bottom = 1.0
|
|||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 6
|
||||||
texture = ExtResource("1_ihnyk")
|
texture = ExtResource("1_ihnyk")
|
||||||
expand_mode = 1
|
expand_mode = 5
|
||||||
script = ExtResource("1_iwfll")
|
script = ExtResource("1_iwfll")
|
||||||
|
@ -9,6 +9,6 @@ anchor_bottom = 1.0
|
|||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 6
|
||||||
texture = ExtResource("1_fj1ma")
|
texture = ExtResource("1_fj1ma")
|
||||||
expand_mode = 1
|
expand_mode = 5
|
||||||
|
@ -9,6 +9,6 @@ anchor_bottom = 1.0
|
|||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 6
|
||||||
texture = ExtResource("1_cnx2r")
|
texture = ExtResource("1_cnx2r")
|
||||||
expand_mode = 1
|
expand_mode = 5
|
||||||
|
Loading…
Reference in New Issue
Block a user