初步实现楼层飞行器弹窗

This commit is contained in:
freewu32 2020-09-08 11:16:14 +08:00
parent 998f28ead2
commit ca62f104e8
13 changed files with 278 additions and 35 deletions

View File

@ -23,6 +23,7 @@ func connect_button():
$"/root/Main/HUD/BottomBackground/VBoxContainer/SaveButton".connect("pressed",self,"on_save_button_clicked")
$"/root/Main/HUD/BottomBackground/VBoxContainer/LoadButton".connect("pressed",self,"on_load_button_clicked")
$"/root/Main/HUD/BottomBackground/VBoxContainer/BookButton".connect("pressed",self,"on_book_button_clicked")
$"/root/Main/HUD/BottomBackground/VBoxContainer/FlyButton".connect("pressed",self,"on_fly_button_clicked")
get_hud().get_close_book_button_view().connect("pressed",self,"on_close_book_clicked")
func connect_level_update():
@ -61,7 +62,9 @@ func on_prop_added(name):
match name:
"book":
get_hud().get_book_button_view().visible = true
"flying_staff":
get_hud().get_fly_button_view().visible = true
func on_save_button_clicked():
get_level_manager().save_persistent(0)
@ -74,6 +77,9 @@ func on_book_button_clicked():
func on_close_book_clicked():
get_hud().get_book_dialog_view().visible = false
func on_fly_button_clicked():
get_hud().get_fly_dialog_view().show()
func get_hud() -> Hud:
return $HUD as Hud

146
Main.tscn
View File

@ -1,11 +1,14 @@
[gd_scene load_steps=29 format=2]
[gd_scene load_steps=41 format=2]
[ext_resource path="res://src/levels/Level1.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/utils/TouchScrollContainer.gd" type="Script" id=2]
[ext_resource path="res://assets/fonts/Droid Sans Fallback.ttf" type="DynamicFontData" id=3]
[ext_resource path="res://assets/images/winskin.png" type="Texture" id=4]
[ext_resource path="res://assets/sounds/bgm.ogg" type="AudioStream" id=5]
[ext_resource path="res://assets/images/ground.png" type="Texture" id=6]
[ext_resource path="res://assets/images/icons_old.png" type="Texture" id=7]
[ext_resource path="res://assets/fonts/Droid Sans Fallback.tres" type="DynamicFont" id=8]
[ext_resource path="res://src/hud/FlyDialog.gd" type="Script" id=9]
[ext_resource path="res://src/level/LevelsManager.gd" type="Script" id=10]
[ext_resource path="res://src/hud/HUD.gd" type="Script" id=11]
[ext_resource path="res://Main.gd" type="Script" id=12]
@ -75,6 +78,31 @@ region = Rect2( 0, 544, 32, 32 )
[sub_resource type="StyleBoxEmpty" id=19]
[sub_resource type="DynamicFont" id=20]
size = 32
font_data = ExtResource( 3 )
[sub_resource type="StreamTexture" id=21]
load_path = "res://.import/winskin.png-148a2ef6406d211f02ea143438de6aef.stex"
[sub_resource type="AtlasTexture" id=22]
atlas = SubResource( 21 )
region = Rect2( 152, 16, 16, 8 )
[sub_resource type="AtlasTexture" id=23]
atlas = ExtResource( 4 )
region = Rect2( 152, 40, 16, 8 )
[sub_resource type="StyleBoxEmpty" id=24]
[sub_resource type="StyleBoxEmpty" id=25]
[sub_resource type="StyleBoxEmpty" id=26]
[sub_resource type="StyleBoxEmpty" id=27]
[sub_resource type="StyleBoxEmpty" id=28]
[node name="Main" type="Node2D"]
script = ExtResource( 12 )
@ -311,30 +339,30 @@ margin_bottom = 32.0
size_flags_horizontal = 3
texture_normal = SubResource( 7 )
[node name="TextureButton2" type="TextureButton" parent="HUD/BottomBackground/VBoxContainer"]
[node name="FlyButton" type="TextureButton" parent="HUD/BottomBackground/VBoxContainer"]
visible = false
margin_right = 40.0
margin_right = 36.0
margin_bottom = 32.0
size_flags_horizontal = 3
texture_normal = SubResource( 8 )
[node name="TextureButton3" type="TextureButton" parent="HUD/BottomBackground/VBoxContainer"]
visible = false
margin_right = 40.0
margin_right = 36.0
margin_bottom = 32.0
size_flags_horizontal = 3
texture_normal = SubResource( 9 )
[node name="TextureButton4" type="TextureButton" parent="HUD/BottomBackground/VBoxContainer"]
visible = false
margin_right = 40.0
margin_right = 36.0
margin_bottom = 32.0
size_flags_horizontal = 3
texture_normal = SubResource( 10 )
[node name="TextureButton5" type="TextureButton" parent="HUD/BottomBackground/VBoxContainer"]
visible = false
margin_right = 40.0
margin_right = 36.0
margin_bottom = 32.0
size_flags_horizontal = 3
texture_normal = SubResource( 11 )
@ -381,7 +409,6 @@ margin_right = 414.0
margin_bottom = 224.0
popup_exclusive = true
__meta__ = {
"_edit_group_": true,
"_edit_use_anchors_": false
}
@ -472,6 +499,110 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="FlyDialog" type="PopupDialog" parent="HUD"]
visible = true
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -176.0
margin_top = -144.0
margin_right = 176.0
margin_bottom = 240.0
script = ExtResource( 9 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Title" type="Label" parent="HUD/FlyDialog"]
anchor_left = 0.5
anchor_right = 0.5
margin_left = -64.0
margin_top = 43.0
margin_right = 64.0
margin_bottom = 86.0
custom_fonts/font = SubResource( 20 )
text = "楼层跳跃"
[node name="Screenshot" type="TextureRect" parent="HUD/FlyDialog"]
anchor_top = 0.5
anchor_bottom = 0.5
margin_left = 32.0
margin_top = -88.0
margin_right = 225.0
margin_bottom = 128.0
expand = true
stretch_mode = 6
__meta__ = {
"_edit_use_anchors_": false
}
[node name="CurrentLevel" type="Label" parent="HUD/FlyDialog"]
anchor_left = 1.0
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
margin_left = -128.0
margin_top = -12.0
margin_right = -8.0
margin_bottom = 13.0
custom_fonts/font = ExtResource( 8 )
text = "魔塔 第01F"
align = 1
valign = 1
clip_text = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="AddLevel" type="TextureButton" parent="HUD/FlyDialog"]
anchor_left = 1.0
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
margin_left = -72.0
margin_top = -40.0
margin_right = -56.0
margin_bottom = -32.0
texture_normal = SubResource( 22 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="SubLevel" type="TextureButton" parent="HUD/FlyDialog"]
anchor_left = 1.0
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
margin_left = -72.0
margin_top = 33.0
margin_right = -56.0
margin_bottom = 41.0
texture_normal = SubResource( 23 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Close" type="Button" parent="HUD/FlyDialog"]
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
margin_left = -32.0
margin_top = -45.0
margin_right = 32.0
margin_bottom = -8.0
custom_styles/hover = SubResource( 24 )
custom_styles/pressed = SubResource( 25 )
custom_styles/focus = SubResource( 26 )
custom_styles/disabled = SubResource( 27 )
custom_styles/normal = SubResource( 28 )
custom_fonts/font = ExtResource( 8 )
text = "返回游戏"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Level" type="Node2D" parent="."]
script = ExtResource( 10 )
@ -481,3 +612,4 @@ script = ExtResource( 10 )
stream = ExtResource( 5 )
volume_db = -10.0
[connection signal="popup_hide" from="HUD/BookDialog" to="HUD/BookDialog/ScrollContainer" method="_on_BookDialog_popup_hide"]
[connection signal="pressed" from="HUD/FlyDialog/Close" to="HUD/FlyDialog" method="_on_Close_pressed"]

BIN
assets/images/winskin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/winskin.png-148a2ef6406d211f02ea143438de6aef.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/images/winskin.png"
dest_files=[ "res://.import/winskin.png-148a2ef6406d211f02ea143438de6aef.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

20
src/hud/FlyDialog.gd Normal file
View File

@ -0,0 +1,20 @@
extends PopupDialog
onready var level_manager : LevelsManager = $"/root/Main/Level"
onready var level_label : Label = $"CurrentLevel"
onready var level_screenshot : TextureRect = $"Screenshot"
func show():
var current_level = level_manager.level
level_label.text = "魔塔 第%0*dF" % [2,current_level]
var image = get_viewport().get_texture().get_data()
image.flip_y()
var texture = ImageTexture.new()
texture.create_from_image(image,image.get_format())
level_screenshot.texture = texture
visible = true
func _on_Close_pressed():
visible = false

View File

@ -35,8 +35,14 @@ func get_load_button_view() -> TextureButton:
func get_book_button_view() -> TextureButton:
return $"BottomBackground/VBoxContainer/BookButton" as TextureButton
func get_fly_button_view() -> TextureButton:
return $"BottomBackground/VBoxContainer/FlyButton" as TextureButton
func get_book_dialog_view() -> PopupDialog:
return $"BookDialog" as PopupDialog
func get_close_book_button_view() -> Button:
return $"BookDialog/CloseBook" as Button
func get_fly_dialog_view() -> PopupDialog:
return $"FlyDialog" as PopupDialog

View File

@ -31,6 +31,23 @@ func set_level(next_level:int):
save_instance_to_local()
save_data_to_local()
load_data(next_level)
save_go_to_level(next_level)
# 保存去过的楼层
func save_go_to_level(level:int):
if not self.global.has("player_levels"):
self.global.player_levels = {1:-1}
self.global.player_levels[level] = -1
# 获取去过的楼层
func get_go_to_levels() -> Array:
if not self.global.has("player_levels"):
return [1]
return self.global.player_levels.keys()
# 获取屏幕截图路径
func get_screenshot_image_path(now_level:int) -> String:
return "%s%s.png" % [tmp_level_scene_path,now_level]
func load_data(next_level:int):
#加载数据
@ -46,7 +63,7 @@ func load_data(next_level:int):
func save_screenshot():
var image = get_viewport().get_texture().get_data()
image.flip_y()
var save_error = image.save_png("%s%s.png" % [tmp_level_scene_path,level])
var save_error = image.save_png(get_screenshot_image_path(self.level))
if save_error != OK:
print("保存截图失败:"+save_error)

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=13 format=2]
[gd_scene load_steps=14 format=2]
[ext_resource path="res://src/player/Player.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/level/LevelInstance.gd" type="Script" id=2]
@ -12,6 +12,7 @@
[ext_resource path="res://src/props/RedDrug.tscn" type="PackedScene" id=10]
[ext_resource path="res://src/props/BlueGemstone.tscn" type="PackedScene" id=11]
[ext_resource path="res://src/props/BlueDrug.tscn" type="PackedScene" id=12]
[ext_resource path="res://src/props/FlyingStaff.tscn" type="PackedScene" id=13]
[node name="Level1" type="Node2D"]
script = ExtResource( 2 )
@ -88,50 +89,47 @@ position = Vector2( 114.1, 432 )
[node name="Monster" parent="Items" instance=ExtResource( 6 )]
position = Vector2( 112, 144 )
frame = 0
[node name="Monster2" parent="Items" instance=ExtResource( 6 )]
position = Vector2( 144, 144 )
animation = "redSlime"
frame = 0
[node name="Monster4" parent="Items" instance=ExtResource( 6 )]
position = Vector2( 336, 432 )
animation = "bat"
frame = 0
[node name="Monster9" parent="Items" instance=ExtResource( 6 )]
position = Vector2( 240, 304 )
animation = "bat"
frame = 0
[node name="Monster10" parent="Items" instance=ExtResource( 6 )]
position = Vector2( 272, 304 )
animation = "bluePriest"
frame = 0
[node name="Monster11" parent="Items" instance=ExtResource( 6 )]
position = Vector2( 304, 304 )
animation = "bat"
frame = 0
[node name="Monster7" parent="Items" instance=ExtResource( 6 )]
position = Vector2( 80, 240 )
animation = "skeleton"
frame = 0
[node name="Monster8" parent="Items" instance=ExtResource( 6 )]
position = Vector2( 80, 336 )
animation = "skeletonSoilder"
frame = 0
[node name="Monster5" parent="Items" instance=ExtResource( 6 )]
position = Vector2( 304, 464 )
frame = 0
[node name="Monster6" parent="Items" instance=ExtResource( 6 )]
position = Vector2( 368, 464 )
frame = 0
[node name="Monster3" parent="Items" instance=ExtResource( 6 )]
position = Vector2( 176, 144 )
frame = 0
[node name="Stairs" parent="Items" instance=ExtResource( 3 )]
position = Vector2( 48, 144 )
@ -139,7 +137,9 @@ position = Vector2( 48, 144 )
[node name="BlueGemstone" parent="Items" instance=ExtResource( 11 )]
position = Vector2( 240, 208 )
[node name="FlyingStaff" parent="Items" instance=ExtResource( 13 )]
[node name="Player" parent="." instance=ExtResource( 1 )]
position = Vector2( 207, 464 )
position = Vector2( 80, 400 )
atk = 100
def = 100

View File

@ -69,18 +69,22 @@ position = Vector2( 176, 272 )
[node name="MonsterSprite" parent="Items" instance=ExtResource( 9 )]
position = Vector2( 304, 272 )
animation = "skeleton"
frame = 0
[node name="MonsterSprite3" parent="Items" instance=ExtResource( 9 )]
position = Vector2( 176, 208 )
animation = "redSlime"
frame = 0
[node name="MonsterSprite10" parent="Items" instance=ExtResource( 9 )]
position = Vector2( 80, 464 )
animation = "redSlime"
frame = 0
[node name="MonsterSprite15" parent="Items" instance=ExtResource( 9 )]
position = Vector2( 368, 176 )
animation = "redSlime"
frame = 0
[node name="MonsterSprite11" parent="Items" instance=ExtResource( 9 )]
position = Vector2( 112, 432 )
@ -97,34 +101,42 @@ position = Vector2( 48, 432 )
[node name="MonsterSprite5" parent="Items" instance=ExtResource( 9 )]
position = Vector2( 176, 400 )
animation = "bat"
frame = 0
[node name="MonsterSprite13" parent="Items" instance=ExtResource( 9 )]
position = Vector2( 112, 208 )
animation = "bat"
frame = 0
[node name="MonsterSprite6" parent="Items" instance=ExtResource( 9 )]
position = Vector2( 240, 400 )
animation = "redSlime"
frame = 0
[node name="MonsterSprite7" parent="Items" instance=ExtResource( 9 )]
position = Vector2( 240, 432 )
animation = "bluePriest"
frame = 0
[node name="MonsterSprite8" parent="Items" instance=ExtResource( 9 )]
position = Vector2( 144, 304 )
animation = "bluePriest"
frame = 0
[node name="MonsterSprite2" parent="Items" instance=ExtResource( 9 )]
position = Vector2( 304, 336 )
animation = "skeletonSoilder"
frame = 0
[node name="MonsterSprite9" parent="Items" instance=ExtResource( 9 )]
position = Vector2( 80, 304 )
animation = "skeletonSoilder"
frame = 0
[node name="MonsterSprite4" parent="Items" instance=ExtResource( 9 )]
position = Vector2( 240, 208 )
animation = "skeletonSoilder"
frame = 0
[node name="YellowKey" parent="Items" instance=ExtResource( 10 )]
position = Vector2( 176, 464 )

View File

@ -125,7 +125,6 @@ position = Vector2( 368, 208 )
[node name="MonsterSprite" parent="Items" instance=ExtResource( 16 )]
position = Vector2( 240, 176 )
frame = 0
[node name="MonsterSprite2" parent="Items" instance=ExtResource( 16 )]
position = Vector2( 304, 272 )
@ -161,11 +160,9 @@ animation = "redSlime"
[node name="MonsterSprite9" parent="Items" instance=ExtResource( 16 )]
position = Vector2( 112, 304 )
frame = 0
[node name="MonsterSprite11" parent="Items" instance=ExtResource( 16 )]
position = Vector2( 48, 432 )
frame = 0
[node name="MonsterSprite6" parent="Items" instance=ExtResource( 16 )]
position = Vector2( 208, 368 )

View File

@ -73,6 +73,7 @@ position = Vector2( 208, 208 )
[node name="HiddenDoor" parent="Items" instance=ExtResource( 8 )]
position = Vector2( 336, 272 )
enabled = true
[node name="BlueDoor2" parent="Items" instance=ExtResource( 6 )]
position = Vector2( 112, 464 )
@ -119,32 +120,26 @@ position = Vector2( 48, 336 )
[node name="MonsterSprite" parent="Items" instance=ExtResource( 13 )]
position = Vector2( 112, 144 )
animation = "skeleton"
frame = 1
[node name="MonsterSprite8" parent="Items" instance=ExtResource( 13 )]
position = Vector2( 336, 432 )
animation = "skeleton"
frame = 1
[node name="MonsterSprite9" parent="Items" instance=ExtResource( 13 )]
position = Vector2( 176, 432 )
animation = "skeleton"
frame = 1
[node name="MonsterSprite10" parent="Items" instance=ExtResource( 13 )]
position = Vector2( 144, 336 )
animation = "skeletonSoilder"
frame = 1
[node name="MonsterSprite12" parent="Items" instance=ExtResource( 13 )]
position = Vector2( 240, 304 )
animation = "redSlime"
frame = 1
[node name="MonsterSprite13" parent="Items" instance=ExtResource( 13 )]
position = Vector2( 240, 432 )
animation = "bat"
frame = 1
[node name="IronShield" parent="Items" instance=ExtResource( 14 )]
position = Vector2( 304, 336 )
@ -152,40 +147,32 @@ position = Vector2( 304, 336 )
[node name="MonsterSprite14" parent="Items" instance=ExtResource( 13 )]
position = Vector2( 112, 272 )
animation = "bat"
frame = 1
[node name="MonsterSprite11" parent="Items" instance=ExtResource( 13 )]
position = Vector2( 48, 368 )
animation = "skeletonSoilder"
frame = 1
[node name="MonsterSprite3" parent="Items" instance=ExtResource( 13 )]
position = Vector2( 304, 144 )
frame = 1
[node name="MonsterSprite4" parent="Items" instance=ExtResource( 13 )]
position = Vector2( 336, 176 )
frame = 1
[node name="MonsterSprite2" parent="Items" instance=ExtResource( 13 )]
position = Vector2( 48, 208 )
animation = "skeletonSoilder"
frame = 1
[node name="MonsterSprite5" parent="Items" instance=ExtResource( 13 )]
position = Vector2( 368, 304 )
animation = "skeletonSoilder"
frame = 1
[node name="MonsterSprite6" parent="Items" instance=ExtResource( 13 )]
position = Vector2( 368, 400 )
animation = "bluePriest"
frame = 1
[node name="MonsterSprite7" parent="Items" instance=ExtResource( 13 )]
position = Vector2( 304, 464 )
animation = "bluePriest"
frame = 1
[node name="Player" parent="." instance=ExtResource( 15 )]
position = Vector2( 208, 176 )

View File

@ -0,0 +1,22 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://src/props/PlayerPropsAppend.gd" type="Script" id=1]
[ext_resource path="res://assets/images/items.png" type="Texture" id=2]
[sub_resource type="RectangleShape2D" id=1]
[node name="FlyingStaff" type="Position2D"]
position = Vector2( 80, 464 )
script = ExtResource( 1 )
prop_name = "flying_staff"
[node name="Area2D" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 1 )
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 2 )
region_enabled = true
region_rect = Rect2( 0, 320, 32, 32 )
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]

View File

@ -0,0 +1,10 @@
extends Position2D
# 道具名称
export var prop_name : String
func _on_Area2D_body_entered(body):
var levels_manager = $"/root/Main/Level" as LevelsManager
var player = levels_manager.get_current_level_instance().get_player()
player.add_prop(prop_name)
queue_free()