diff --git a/autoload/global/script/global.gd b/autoload/global/script/global.gd index 8d3cdf1..9188d95 100644 --- a/autoload/global/script/global.gd +++ b/autoload/global/script/global.gd @@ -36,15 +36,37 @@ var now_game_data:Dictionary={ "spirit":999, "map":"map_01", "move_ability":1, - "time_unix":999999 + "time_unix":0 } +func get_move_ability(): + return now_game_data["move_ability"] +func get_time_dictionary(): + var time_unix=int(now_game_data["time_unix"]) + return Time.get_datetime_dict_from_unix_time(time_unix) +#year、month、day、weekday、hour、minute 和 second +func flow_time(data:Dictionary): + var date=get_time_dictionary() + var change_unix:float=0 + if data.has("day"): + var day=data["year"] + change_unix+=day*86400 + if data.has("hour"): + var hour=data["hour"] + change_unix+=3600*hour + if data.has("minute"): + var minute=data["minute"] + change_unix+=minute*60 + now_game_data["time_unix"]+=change_unix + time_changed.emit() +signal time_changed 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, - + "end_event":func(data):now_game_flow.event_panel.hide(), + "flow_time":func (data):flow_time(data) } func call_triger(triger_type:String,data): if triger.has(triger_type): @@ -52,12 +74,19 @@ func call_triger(triger_type:String,data): else: return null func move_scene(scene_id:String,distance): - - - + if scene_id==get_now_scene(): + return false + flow_time({ + "minute":distance/get_move_ability() + }) + now_game_flow.change_scene(scene_id,distance) + set_now_scene(scene_id) + return true pass func get_now_scene(): return now_game_data["now_scene"] +func set_now_scene(scene_id:String): + now_game_data["now_scene"]=scene_id var now_game_flow:GameFlow func get_now_character_data(): return now_game_data["character_data"] diff --git a/json/event.json b/json/event.json index 422b496..f9b92e0 100644 --- a/json/event.json +++ b/json/event.json @@ -2,63 +2,63 @@ "event_01":{ "name":"测试事件1", "texture":"test_scene", - "text":"测试事件", + "text":"这是一个测试事件系统的事件", "choice":[ { - "name":"测试选项1", + "name":"度过两小时", "triger":[{ - "type":"change_scene", + "type":"flow_time", + "data":{ + "hour":2 + } + } + ] + }, + { + "name":"结束", + "triger":[{ + "type":"end_event", "data":"" }, - - { + ] + } + ] + }, + "event_02":{ + "name":"测试事件2", + "texture":"test_scene", + "text":"这是一个测试选项触发的事件", + "choice":[ + { + "name":"改变图片", + "triger":[{ "type":"change_texture", "data":"test_character" + } + ] }, - { - "type":"change_choice", - "data":[ - { - "name":"测试选项更改后", - "triger":[] - } + { + "name":"改变描述文本", + "triger":[{ + "type":"change_text", + "data":"描述文本已经改变" + } ] }, { - "type":"play_effects", - "data":"res://test/audio/attack_0.wav" - }, - { - "type":"BGM", - "data":"res://test/audio/attack_0.wav" - }, - { - "type":"fight", - "data":"" - - }, - { - "type":"identification", - "data":"" - }, - { - "type":"change_attribute", - "data":"" - }, - { - "type":"change_value", - "data":"" - }, - - ] - }, - { - "name":"测试选项2", - "triger":[ - { + "name":"转换事件", + "triger":[{ "type":"change_event", "data":"event_01" - }, + } + ] + }, + { + "name":"结束", + "triger":[{ + "type":"end_event", + "data":"" + }, ] } ] diff --git a/json/scene.json b/json/scene.json index b28b62c..a13fe2f 100644 --- a/json/scene.json +++ b/json/scene.json @@ -1,6 +1,7 @@ { "scene_01":{ "name":"测试场景1", + "map":"map_01", "texture":"test_scene", "quick_event":[ { @@ -21,6 +22,7 @@ }, "scene_02":{ "name":"测试场景1", + "map":"map_01", "texture":"test_character", "quick_event":[ { @@ -41,4 +43,27 @@ ] }, + "scene_tower":{ + "name":"测试场景_塔楼", + "texture":"tower", + "map":"map_01", + "quick_event":[ + { + "name":"时间测试", + "event":"event_01" + }, + { + "name":"测试场景事件", + "event":"event_02" + } + ], + "linked_scene":[ + { + "name":"测试场景1", + "id":"scene_01", + "distance":100 + } + ] + + }, } diff --git a/json/texture.json b/json/texture.json index 6bf3b92..cb4f2df 100644 --- a/json/texture.json +++ b/json/texture.json @@ -2,5 +2,6 @@ "texture_test":"res://test/texture/test_texture.png", "test_scene":"res://test/texture/test_scene.png", "test_character":"res://test/texture/test_character.png", - "test_character_tsubaki":"res://test/texture/tsubaki_1.png" + "test_character_tsubaki":"res://test/texture/tsubaki_1.png", + "tower":"res://test/texture/test_tower.jpg" } diff --git a/res/shader/change_scene.gdshader b/res/shader/change_scene.gdshader index f76121f..8997ed6 100644 --- a/res/shader/change_scene.gdshader +++ b/res/shader/change_scene.gdshader @@ -9,4 +9,3 @@ void fragment() float alpha =smoothstep(cutoff,cutoff,value); COLOR=vec4(COLOR.rgb,alpha); } - diff --git a/res/ui/ui_019_game_flow/tuceng10.png b/res/ui/ui_019_game_flow/tuceng10.png new file mode 100644 index 0000000..c27b32f Binary files /dev/null and b/res/ui/ui_019_game_flow/tuceng10.png differ diff --git a/res/ui/ui_019_game_flow/tuceng10.png.import b/res/ui/ui_019_game_flow/tuceng10.png.import new file mode 100644 index 0000000..587f7b8 --- /dev/null +++ b/res/ui/ui_019_game_flow/tuceng10.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cpito436o4akn" +path="res://.godot/imported/tuceng10.png-14b5497e2257fde6a8550b020169e709.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://res/ui/ui_019_game_flow/tuceng10.png" +dest_files=["res://.godot/imported/tuceng10.png-14b5497e2257fde6a8550b020169e709.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/res/ui/ui_019_game_flow/tuceng11.png b/res/ui/ui_019_game_flow/tuceng11.png new file mode 100644 index 0000000..00fcfff Binary files /dev/null and b/res/ui/ui_019_game_flow/tuceng11.png differ diff --git a/res/ui/ui_019_game_flow/tuceng11.png.import b/res/ui/ui_019_game_flow/tuceng11.png.import new file mode 100644 index 0000000..42f2bd4 --- /dev/null +++ b/res/ui/ui_019_game_flow/tuceng11.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://xjk24mq7dqjp" +path="res://.godot/imported/tuceng11.png-d1a83d8c3ca9285090a465619b2cd1a7.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://res/ui/ui_019_game_flow/tuceng11.png" +dest_files=["res://.godot/imported/tuceng11.png-d1a83d8c3ca9285090a465619b2cd1a7.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/res/ui/ui_019_game_flow/tuceng12.png b/res/ui/ui_019_game_flow/tuceng12.png new file mode 100644 index 0000000..8ad8e2c Binary files /dev/null and b/res/ui/ui_019_game_flow/tuceng12.png differ diff --git a/res/ui/ui_019_game_flow/tuceng12.png.import b/res/ui/ui_019_game_flow/tuceng12.png.import new file mode 100644 index 0000000..4040c64 --- /dev/null +++ b/res/ui/ui_019_game_flow/tuceng12.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://caxe5fymffqkk" +path="res://.godot/imported/tuceng12.png-b7d4401d8da92a4461deb914fd6a0897.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://res/ui/ui_019_game_flow/tuceng12.png" +dest_files=["res://.godot/imported/tuceng12.png-b7d4401d8da92a4461deb914fd6a0897.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/res/ui/ui_019_game_flow/tuceng13.png b/res/ui/ui_019_game_flow/tuceng13.png new file mode 100644 index 0000000..c063481 Binary files /dev/null and b/res/ui/ui_019_game_flow/tuceng13.png differ diff --git a/res/ui/ui_019_game_flow/tuceng13.png.import b/res/ui/ui_019_game_flow/tuceng13.png.import new file mode 100644 index 0000000..59019a3 --- /dev/null +++ b/res/ui/ui_019_game_flow/tuceng13.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bowl27hko0yx2" +path="res://.godot/imported/tuceng13.png-6296b4b77b969420c4c9d07743b5949f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://res/ui/ui_019_game_flow/tuceng13.png" +dest_files=["res://.godot/imported/tuceng13.png-6296b4b77b969420c4c9d07743b5949f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/res/ui/ui_019_game_flow/tuoyuan1.png b/res/ui/ui_019_game_flow/tuoyuan1.png new file mode 100644 index 0000000..d5bdbda Binary files /dev/null and b/res/ui/ui_019_game_flow/tuoyuan1.png differ diff --git a/res/ui/ui_019_game_flow/tuoyuan1.png.import b/res/ui/ui_019_game_flow/tuoyuan1.png.import new file mode 100644 index 0000000..49d09a2 --- /dev/null +++ b/res/ui/ui_019_game_flow/tuoyuan1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://824g8kb1h4o4" +path="res://.godot/imported/tuoyuan1.png-f86cec2492aa2d020add32d538eee231.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://res/ui/ui_019_game_flow/tuoyuan1.png" +dest_files=["res://.godot/imported/tuoyuan1.png-f86cec2492aa2d020add32d538eee231.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/res/ui/ui_019_game_flow/tuoyuan1_1.png b/res/ui/ui_019_game_flow/tuoyuan1_1.png new file mode 100644 index 0000000..407ef0b Binary files /dev/null and b/res/ui/ui_019_game_flow/tuoyuan1_1.png differ diff --git a/res/ui/ui_019_game_flow/tuoyuan1_1.png.import b/res/ui/ui_019_game_flow/tuoyuan1_1.png.import new file mode 100644 index 0000000..4269ac5 --- /dev/null +++ b/res/ui/ui_019_game_flow/tuoyuan1_1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://by162nwatffw2" +path="res://.godot/imported/tuoyuan1_1.png-515b6fa7702b85cd72d9244436b9a1b8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://res/ui/ui_019_game_flow/tuoyuan1_1.png" +dest_files=["res://.godot/imported/tuoyuan1_1.png-515b6fa7702b85cd72d9244436b9a1b8.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scene/game_flow.gd b/scene/game_flow.gd index be9a25f..c8a6ae9 100644 --- a/scene/game_flow.gd +++ b/scene/game_flow.gd @@ -8,12 +8,18 @@ class_name GameFlow @onready var character_texture: TextureRect = $hbox/TextureRect/TextureRect/character_texture @onready var event_panel: Control = $event_panel @onready var character_name: Label = $hbox/TextureRect2/vbox/HBoxContainer/character_name +@onready var map: Control = $map +@onready var date: Label = $hbox/TextureRect2/vbox/date + +const GAME_FLOW_TOUCH = preload("res://scene/game_flow_touch.tscn") const GAME_FLOW_EVENT = preload("res://scene/game_flow_event.tscn") const GAME_FLOW_PLACE = preload("res://scene/game_flow_place.tscn") var scene_data:Dictionary func _ready() -> void: set_scene("scene_01") + update_date() + Global.time_changed.connect(update_date) Global.now_game_flow=self var character_data=Global.get_now_character_data() character_texture.texture=Global.get_texture(character_data["character"]["skin"][character_data["character"]["skin_now_use"]]["card_face"]) @@ -38,11 +44,19 @@ func set_scene(id:String): pass pass +func update_date(): + var time_dic=Global.get_time_dictionary() + date.text=str(time_dic["year"])+"/"+str(time_dic["month"])+"/"+str(time_dic["day"]) + func place_pressed(data:Dictionary): + + Global.move_scene(data["id"],data["distance"]) +func change_scene(scene_id:String,distance:float): + animation_mask.show() animation_player.play("change") await animation_player.animation_finished - set_scene(data["id"]) + set_scene(scene_id) await get_tree().create_timer(0.2).timeout animation_player.play_backwards("change") await animation_player.animation_finished @@ -52,3 +66,13 @@ func show_event(event_id:String): event_panel.show() event_panel.set_event_data(event_id) pass + + +func _on_map_pressed() -> void: + map.set_map(scene_data["map"]) + map.modulate.a=0 + var t=get_tree().create_tween() + t.tween_property(map,"modulate:a",1,0.2) + map.show() + + pass # Replace with function body. diff --git a/scene/game_flow.tscn b/scene/game_flow.tscn index 3a48b1e..67c9b23 100644 --- a/scene/game_flow.tscn +++ b/scene/game_flow.tscn @@ -3,7 +3,6 @@ [ext_resource type="Texture2D" uid="uid://5vyvaedcfv38" path="res://res/ui/ui_019_game_flow/tuceng1.png" id="1_gjw3y"] [ext_resource type="Script" path="res://scene/game_flow.gd" id="1_w6afk"] [ext_resource type="Texture2D" uid="uid://bfxq2lfnecjue" path="res://res/ui/ui_019_game_flow/juxing505.png" id="2_w5ej7"] -[ext_resource type="PackedScene" uid="uid://clhtya30fwcwp" path="res://scene/game_flow_card.tscn" id="3_c6hhr"] [ext_resource type="PackedScene" uid="uid://bsegldhx3w3ws" path="res://scene/game_flow_event.tscn" id="3_h6xm4"] [ext_resource type="Texture2D" uid="uid://78rjb4sv4jrp" path="res://res/ui/ui_019_game_flow/juxing507.png" id="5_htscv"] [ext_resource type="Texture2D" uid="uid://bslh6vgaom0ds" path="res://res/ui/ui_019_game_flow/tuceng303.png" id="6_5kjvb"] @@ -18,6 +17,7 @@ [ext_resource type="PackedScene" uid="uid://dr7aeaevf1qun" path="res://scene/game_flow_place.tscn" id="15_2cypk"] [ext_resource type="PackedScene" uid="uid://b3hw4w5shpyu0" path="res://scene/event.tscn" id="17_xt42m"] [ext_resource type="Shader" path="res://res/shader/change_scene.gdshader" id="18_ubmfk"] +[ext_resource type="PackedScene" uid="uid://ccsaeb8hm5lsu" path="res://scene/map.tscn" id="19_fok85"] [sub_resource type="Gradient" id="Gradient_4wq1v"] @@ -112,18 +112,6 @@ size_flags_horizontal = 0 size_flags_vertical = 8 theme_override_constants/separation = 29 -[node name="game_flow_card" parent="bottom_container/card" instance=ExtResource("3_c6hhr")] -layout_mode = 2 - -[node name="game_flow_card2" parent="bottom_container/card" instance=ExtResource("3_c6hhr")] -layout_mode = 2 - -[node name="game_flow_card3" parent="bottom_container/card" instance=ExtResource("3_c6hhr")] -layout_mode = 2 - -[node name="game_flow_card4" parent="bottom_container/card" instance=ExtResource("3_c6hhr")] -layout_mode = 2 - [node name="event" type="HBoxContainer" parent="bottom_container"] layout_mode = 2 size_flags_horizontal = 10 @@ -194,7 +182,7 @@ grow_horizontal = 2 grow_vertical = 2 theme_override_constants/separation = 0 -[node name="Label" type="Label" parent="hbox/TextureRect2/vbox"] +[node name="date" type="Label" parent="hbox/TextureRect2/vbox"] layout_mode = 2 size_flags_vertical = 3 theme_override_colors/font_color = Color(0, 0, 0, 1) @@ -387,7 +375,7 @@ layout_mode = 2 size_flags_horizontal = 8 texture = ExtResource("14_5tsah") -[node name="ToolButton" parent="HBoxContainer/TextureRect3" instance=ExtResource("8_q6ple")] +[node name="map" parent="HBoxContainer/TextureRect3" instance=ExtResource("8_q6ple")] layout_mode = 1 [node name="place_add" type="VBoxContainer" parent="."] @@ -429,3 +417,9 @@ color = Color(0, 0, 0, 1) libraries = { "": SubResource("AnimationLibrary_ljrcq") } + +[node name="map" parent="." instance=ExtResource("19_fok85")] +visible = false +layout_mode = 1 + +[connection signal="pressed" from="HBoxContainer/TextureRect3/map" to="." method="_on_map_pressed"] diff --git a/scene/game_flow_touch.tscn b/scene/game_flow_touch.tscn new file mode 100644 index 0000000..1f50c73 --- /dev/null +++ b/scene/game_flow_touch.tscn @@ -0,0 +1,63 @@ +[gd_scene load_steps=8 format=3 uid="uid://bk0xuj6xb5n8n"] + +[ext_resource type="Texture2D" uid="uid://xjk24mq7dqjp" path="res://res/ui/ui_019_game_flow/tuceng11.png" id="1_rc7al"] +[ext_resource type="Texture2D" uid="uid://bowl27hko0yx2" path="res://res/ui/ui_019_game_flow/tuceng13.png" id="2_2pfym"] +[ext_resource type="Texture2D" uid="uid://824g8kb1h4o4" path="res://res/ui/ui_019_game_flow/tuoyuan1.png" id="3_garvq"] +[ext_resource type="Texture2D" uid="uid://by162nwatffw2" path="res://res/ui/ui_019_game_flow/tuoyuan1_1.png" id="4_es0wn"] +[ext_resource type="Texture2D" uid="uid://caxe5fymffqkk" path="res://res/ui/ui_019_game_flow/tuceng12.png" id="4_ha44b"] +[ext_resource type="Texture2D" uid="uid://cpito436o4akn" path="res://res/ui/ui_019_game_flow/tuceng10.png" id="5_oqc0n"] +[ext_resource type="PackedScene" uid="uid://bdlo2wn4qnygv" path="res://scene/tool/tool_button.tscn" id="7_xebjv"] + +[node name="HBoxContainer" type="MarginContainer"] +offset_right = 204.0 +offset_bottom = 204.0 + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +layout_mode = 2 + +[node name="TextureRect2" type="TextureRect" parent="HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 0 +size_flags_vertical = 4 +texture = ExtResource("1_rc7al") + +[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"] +layout_mode = 2 + +[node name="TextureRect" type="TextureRect" parent="HBoxContainer/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 0 +texture = ExtResource("2_2pfym") + +[node name="TextureRect2" type="TextureRect" parent="HBoxContainer/VBoxContainer"] +layout_mode = 2 +texture = ExtResource("3_garvq") + +[node name="CenterContainer" type="CenterContainer" parent="HBoxContainer/VBoxContainer/TextureRect2"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="TextureRect" type="TextureRect" parent="HBoxContainer/VBoxContainer/TextureRect2/CenterContainer"] +layout_mode = 2 +texture = ExtResource("4_es0wn") +stretch_mode = 5 + +[node name="TextureRect3" type="TextureRect" parent="HBoxContainer/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 8 +texture = ExtResource("4_ha44b") + +[node name="TextureRect" type="TextureRect" parent="HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 8 +size_flags_vertical = 4 +texture = ExtResource("5_oqc0n") + +[node name="ToolButton" parent="." instance=ExtResource("7_xebjv")] +layout_mode = 2 diff --git a/scene/map.gd b/scene/map.gd index c5e85d2..cd5450e 100644 --- a/scene/map.gd +++ b/scene/map.gd @@ -10,7 +10,11 @@ extends Control @onready var map_2 @onready var map_now @onready var map_add_pos: MarginContainer = $ScrollContainer/HBoxContainer/map_add_pos +@onready var pointer: Label = $ScrollContainer/HBoxContainer/map_add_pos/pointer_map/pointer + + +signal scene_change(scene_id:String) var scale_rag:float=1: set(val): if val>scale_index_1 and valscale_index_2): @@ -49,10 +53,12 @@ var scale_index_1:float=1.2 var scale_index_2:float=1.5 var map_data:Dictionary func set_map(id:String): + scale_rag=1 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() + if i is MapIndex: + 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) @@ -62,7 +68,9 @@ func set_map(id:String): map_2=tscn[2] map_1.hide() map_2.hide() + map_0.show() map_now=map_0 + update_pointer() var scale_index:Array=map_data["scale_index"] var scale_limit:Array=map_data["scale_limit"] scale_limit_min=scale_limit[0] @@ -72,7 +80,10 @@ func set_map(id:String): var _init_size=map_data["init_size"] init_size=Vector2(_init_size[0],_init_size[1]) pass - +func update_time(): + var time_dic:Dictionary=Global.get_time_dictionary() + date.text=str(time_dic["year"])+"/"+str(time_dic["month"])+"/"+str(time_dic["day"]) + time.text=str(time_dic["hour"])+":"+str(time_dic["minute"]) func resize_map(before_rag:float,rag:float,mouse_pos:Vector2,init:Vector2): var l=rag/before_rag var now_pos=Vector2(scroll_container.scroll_horizontal,scroll_container.scroll_vertical)+mouse_pos @@ -82,24 +93,33 @@ func resize_map(before_rag:float,rag:float,mouse_pos:Vector2,init:Vector2): scroll_container.set_deferred("scroll_horizontal", result.x) scroll_container.set_deferred("scroll_vertical", result.y) +func update_pointer(): - pass + var now_scene_id=Global.get_now_scene() + var pos=map_now.get_scene_global_pos(now_scene_id)-Vector2(pointer.size.x/2,pointer.size.y) + pointer.global_position=pos func click(scene_id:String): - - - - pass + print(scene_id) + if scene_id==Global.get_now_scene(): + return + scene_change.emit(scene_id) + var is_success:bool=Global.move_scene(scene_id,map_now.get_scene_distance(Global.get_now_scene(),scene_id)) + if is_success: + self.hide() var init_size:Vector2=Vector2(1920,1080) # Called when the node enters the scene tree for the first time. func _ready() -> void: set_map("map_01") + update_time() + Global.time_changed.connect(update_time) h_box_container.custom_minimum_size=init_size pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: + update_pointer() pass var keep_tween:Tween @@ -123,3 +143,8 @@ func _gui_input(event: InputEvent) -> void: keep_tween=create_tween() keep_tween.tween_property(self,"scale_rag",clamp(scale_rag-0.2,scale_limit_min,scale_limit_max),0.1) + + +func _on_back_pressed() -> void: + self.hide() + pass # Replace with function body. diff --git a/scene/map.tscn b/scene/map.tscn index 04c5944..c4e2ef6 100644 --- a/scene/map.tscn +++ b/scene/map.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=3 uid="uid://ccsaeb8hm5lsu"] +[gd_scene load_steps=11 format=3 uid="uid://ccsaeb8hm5lsu"] [ext_resource type="Texture2D" uid="uid://bx2layh7wm6ft" path="res://res/ui/ui_021_map/tuceng309.png" id="1_e45qx"] [ext_resource type="Script" path="res://scene/map.gd" id="1_ifxi0"] @@ -8,6 +8,8 @@ [ext_resource type="PackedScene" uid="uid://dtbfpnr54ifod" path="res://test/scene/map_example0.tscn" id="5_jn1dj"] [ext_resource type="PackedScene" uid="uid://cscvsnrim8xwk" path="res://test/scene/map_example1.tscn" id="6_a88yc"] [ext_resource type="PackedScene" uid="uid://db3m13gci7afs" path="res://test/scene/map_example2.tscn" id="7_bvfra"] +[ext_resource type="Texture2D" uid="uid://cfkrivnhdpg8l" path="res://res/ui/ui_019_game_flow/tuceng281.png" id="9_u7qpf"] +[ext_resource type="PackedScene" uid="uid://bdlo2wn4qnygv" path="res://scene/tool/tool_button.tscn" id="10_vgkwd"] [node name="map" type="Control"] layout_mode = 3 @@ -18,6 +20,15 @@ grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_ifxi0") +[node name="TextureRect2" type="ColorRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0.50605, 0.551841, 0.262283, 1) + [node name="ScrollContainer" type="ScrollContainer" parent="."] layout_mode = 1 anchors_preset = 15 @@ -64,15 +75,34 @@ layout_mode = 2 visible = false layout_mode = 2 +[node name="pointer_map" type="Control" parent="ScrollContainer/HBoxContainer/map_add_pos"] +layout_mode = 2 + +[node name="pointer" type="Label" parent="ScrollContainer/HBoxContainer/map_add_pos/pointer_map"] +z_index = 3 +layout_mode = 1 +anchors_preset = -1 +anchor_left = -0.027 +anchor_right = 1.031 +anchor_bottom = 1.0 +offset_left = 38.88 +offset_right = -1435.64 +offset_bottom = -956.0 +theme_override_font_sizes/font_size = 90 +text = "⬇" +horizontal_alignment = 1 +vertical_alignment = 1 + [node name="TextureRect4" type="TextureRect" parent="ScrollContainer/HBoxContainer"] layout_mode = 2 size_flags_horizontal = 8 texture = ExtResource("2_slael") expand_mode = 3 +flip_h = true [node name="TextureRect3" type="TextureRect" parent="ScrollContainer/HBoxContainer"] layout_mode = 2 -size_flags_horizontal = 0 +size_flags_horizontal = 4 texture = ExtResource("1_e45qx") expand_mode = 3 @@ -151,4 +181,18 @@ text = "(000,000)" vertical_alignment = 1 metadata/_edit_use_anchors_ = true +[node name="back" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -40.0 +offset_bottom = 40.0 +grow_horizontal = 0 +texture = ExtResource("9_u7qpf") + +[node name="back" parent="back" instance=ExtResource("10_vgkwd")] +layout_mode = 1 + [connection signal="gui_input" from="ScrollContainer" to="." method="_on_scroll_container_gui_input"] +[connection signal="pressed" from="back/back" to="." method="_on_back_pressed"] diff --git a/test/scene/map_example0.tscn b/test/scene/map_example0.tscn index 2eb790c..d0fb943 100644 --- a/test/scene/map_example0.tscn +++ b/test/scene/map_example0.tscn @@ -1,7 +1,9 @@ -[gd_scene load_steps=3 format=3 uid="uid://dtbfpnr54ifod"] +[gd_scene load_steps=5 format=3 uid="uid://dtbfpnr54ifod"] [ext_resource type="Texture2D" uid="uid://c43yesnuqsk21" path="res://test/map/map_01.png" id="1_ihnyk"] -[ext_resource type="Script" path="res://class/map/map_class.gd" id="1_iwfll"] +[ext_resource type="Script" path="res://test/scene/map_example_0.gd" id="2_oe52u"] +[ext_resource type="Texture2D" uid="uid://lp6ekqrqjywt" path="res://test/texture/room.png" id="3_4ivo3"] +[ext_resource type="PackedScene" uid="uid://bdlo2wn4qnygv" path="res://scene/tool/tool_button.tscn" id="4_d7xih"] [node name="map_example" type="TextureRect"] anchors_preset = 15 @@ -13,4 +15,19 @@ size_flags_horizontal = 3 size_flags_vertical = 6 texture = ExtResource("1_ihnyk") expand_mode = 5 -script = ExtResource("1_iwfll") +script = ExtResource("2_oe52u") + +[node name="TextureRect" type="TextureRect" parent="."] +visible = false +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.441146 +anchor_top = 0.351852 +anchor_right = 0.470313 +anchor_bottom = 0.403704 +texture = ExtResource("3_4ivo3") +expand_mode = 1 +metadata/_edit_use_anchors_ = true + +[node name="ToolButton" parent="TextureRect" instance=ExtResource("4_d7xih")] +layout_mode = 1 diff --git a/test/scene/map_example1.tscn b/test/scene/map_example1.tscn index b7296c7..8162e35 100644 --- a/test/scene/map_example1.tscn +++ b/test/scene/map_example1.tscn @@ -1,6 +1,9 @@ -[gd_scene load_steps=2 format=3 uid="uid://cscvsnrim8xwk"] +[gd_scene load_steps=5 format=3 uid="uid://cscvsnrim8xwk"] [ext_resource type="Texture2D" uid="uid://dojjaa08033rm" path="res://test/map/map_02.png" id="1_fj1ma"] +[ext_resource type="Script" path="res://test/scene/map_example_1.gd" id="2_p0odq"] +[ext_resource type="Texture2D" uid="uid://lp6ekqrqjywt" path="res://test/texture/room.png" id="3_rdri5"] +[ext_resource type="PackedScene" uid="uid://bdlo2wn4qnygv" path="res://scene/tool/tool_button.tscn" id="4_wygvp"] [node name="TextureRect" type="TextureRect"] anchors_preset = 15 @@ -12,3 +15,19 @@ size_flags_horizontal = 3 size_flags_vertical = 6 texture = ExtResource("1_fj1ma") expand_mode = 5 +script = ExtResource("2_p0odq") + +[node name="TextureRect" type="TextureRect" parent="."] +visible = false +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.441146 +anchor_top = 0.351852 +anchor_right = 0.470313 +anchor_bottom = 0.403704 +texture = ExtResource("3_rdri5") +expand_mode = 1 +metadata/_edit_use_anchors_ = true + +[node name="ToolButton" parent="TextureRect" instance=ExtResource("4_wygvp")] +layout_mode = 1 diff --git a/test/scene/map_example2.tscn b/test/scene/map_example2.tscn index 1a8bc02..18b2c61 100644 --- a/test/scene/map_example2.tscn +++ b/test/scene/map_example2.tscn @@ -1,6 +1,9 @@ -[gd_scene load_steps=2 format=3 uid="uid://db3m13gci7afs"] +[gd_scene load_steps=5 format=3 uid="uid://db3m13gci7afs"] [ext_resource type="Texture2D" uid="uid://0rvcuxn1ybid" path="res://test/map/map_03.png" id="1_cnx2r"] +[ext_resource type="Script" path="res://test/scene/map_example_2.gd" id="2_i3hd2"] +[ext_resource type="Texture2D" uid="uid://lp6ekqrqjywt" path="res://test/texture/room.png" id="2_t0dr1"] +[ext_resource type="PackedScene" uid="uid://bdlo2wn4qnygv" path="res://scene/tool/tool_button.tscn" id="3_cuhw3"] [node name="TextureRect" type="TextureRect"] anchors_preset = 15 @@ -12,3 +15,34 @@ size_flags_horizontal = 3 size_flags_vertical = 6 texture = ExtResource("1_cnx2r") expand_mode = 5 +script = ExtResource("2_i3hd2") + +[node name="TextureRect" type="TextureRect" parent="."] +layout_mode = 0 +anchor_left = 0.441146 +anchor_top = 0.351852 +anchor_right = 0.470313 +anchor_bottom = 0.403704 +texture = ExtResource("2_t0dr1") +expand_mode = 1 +metadata/_edit_use_anchors_ = true + +[node name="ToolButton" parent="TextureRect" instance=ExtResource("3_cuhw3")] +layout_mode = 1 + +[node name="TextureRect2" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.614583 +anchor_top = 0.456481 +anchor_right = 0.64375 +anchor_bottom = 0.508333 +texture = ExtResource("2_t0dr1") +expand_mode = 1 +metadata/_edit_use_anchors_ = true + +[node name="ToolButton" parent="TextureRect2" instance=ExtResource("3_cuhw3")] +layout_mode = 1 + +[connection signal="pressed" from="TextureRect/ToolButton" to="." method="_on_tool_button_pressed"] +[connection signal="pressed" from="TextureRect2/ToolButton" to="." method="_on_tool_button2_pressed"] diff --git a/test/scene/map_example_0.gd b/test/scene/map_example_0.gd new file mode 100644 index 0000000..d51dec6 --- /dev/null +++ b/test/scene/map_example_0.gd @@ -0,0 +1,15 @@ +extends MapIndex + + + + +func _on_tool_button_pressed() -> void: + click_scene("scene_tower") + pass # Replace with function body. +func get_scene_global_pos(scene_id:String): + match scene_id: + "scene_tower": + return $TextureRect/ToolButton.global_position + _:return Vector2(0,0) + + pass diff --git a/test/scene/map_example_1.gd b/test/scene/map_example_1.gd new file mode 100644 index 0000000..d51dec6 --- /dev/null +++ b/test/scene/map_example_1.gd @@ -0,0 +1,15 @@ +extends MapIndex + + + + +func _on_tool_button_pressed() -> void: + click_scene("scene_tower") + pass # Replace with function body. +func get_scene_global_pos(scene_id:String): + match scene_id: + "scene_tower": + return $TextureRect/ToolButton.global_position + _:return Vector2(0,0) + + pass diff --git a/test/scene/map_example_2.gd b/test/scene/map_example_2.gd new file mode 100644 index 0000000..d2a2189 --- /dev/null +++ b/test/scene/map_example_2.gd @@ -0,0 +1,20 @@ +extends MapIndex + + + + +func _on_tool_button_pressed() -> void: + click_scene("scene_tower") + pass # Replace with function body. +func get_scene_global_pos(scene_id:String): + match scene_id: + "scene_tower": + return $TextureRect/ToolButton.global_position + _:return Vector2(0,0) + + pass + + +func _on_tool_button2_pressed() -> void: + click_scene("scene_01") + pass # Replace with function body. diff --git a/test/texture/room.png b/test/texture/room.png new file mode 100644 index 0000000..736407e Binary files /dev/null and b/test/texture/room.png differ diff --git a/test/texture/room.png.import b/test/texture/room.png.import new file mode 100644 index 0000000..74d825c --- /dev/null +++ b/test/texture/room.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://lp6ekqrqjywt" +path="res://.godot/imported/room.png-c83cfd68d036fb5eb909c16669601a48.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://test/texture/room.png" +dest_files=["res://.godot/imported/room.png-c83cfd68d036fb5eb909c16669601a48.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/test/texture/test_tower.jpg b/test/texture/test_tower.jpg new file mode 100644 index 0000000..cc62570 Binary files /dev/null and b/test/texture/test_tower.jpg differ diff --git a/test/texture/test_tower.jpg.import b/test/texture/test_tower.jpg.import new file mode 100644 index 0000000..922960f --- /dev/null +++ b/test/texture/test_tower.jpg.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dltavh71w452u" +path="res://.godot/imported/test_tower.jpg-350d7cac82e18c1a8580abf86962538a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://test/texture/test_tower.jpg" +dest_files=["res://.godot/imported/test_tower.jpg-350d7cac82e18c1a8580abf86962538a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1