1
Fork 0
mirror of https://github.com/Steffo99/swear-jar.git synced 2024-11-21 23:34:18 +00:00
This commit is contained in:
Matteo Balugani 2023-10-02 15:25:27 +02:00
commit a17d7ce705
29 changed files with 639 additions and 94 deletions

View file

@ -1,8 +0,0 @@
extends Node2D
func _on_roller_failure():
print("failure")
func _on_roller_success():
print("success")

View file

@ -23,11 +23,8 @@ func _on_sleeping_state_changed():
was_sleeping = true
func _on_body_entered(body):
print("touch")
if not was_sleeping:
if touched==false and $Timer.is_stopped():
print(str(self)+" hits "+str(body))
#$sound_touch.play()
$Timer.start()
var other_node=body

BIN
entity/gem/diamond_white.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bgq5afrrpc4a3"
path="res://.godot/imported/diamond_white.png-ea17eba66708a2de5eae13c889056729.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entity/gem/diamond_white.png"
dest_files=["res://.godot/imported/diamond_white.png-ea17eba66708a2de5eae13c889056729.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

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://chc8wqc1pclbk"
path="res://.godot/imported/gold_converter_back.png-542530d6d643b64e20755f9b54d1da49.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entity/gold_converter_back.png"
dest_files=["res://.godot/imported/gold_converter_back.png-542530d6d643b64e20755f9b54d1da49.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

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dgw5ip5qf5k7a"
path="res://.godot/imported/gold_converter_front_1.png-20d40342907ebeaf5453b3fbc06f6b04.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entity/gold_converter_front_1.png"
dest_files=["res://.godot/imported/gold_converter_front_1.png-20d40342907ebeaf5453b3fbc06f6b04.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

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://h7hu4paxjq84"
path="res://.godot/imported/gold_converter_front_2.png-6b48a8121d01d35430dedd6a7ebaaed7.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entity/gold_converter_front_2.png"
dest_files=["res://.godot/imported/gold_converter_front_2.png-6b48a8121d01d35430dedd6a7ebaaed7.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

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dlog0f5nk4b3c"
path="res://.godot/imported/gold_converter_front_3.png-4b8a07d186c945c584be92c7bbbf79b8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entity/gold_converter_front_3.png"
dest_files=["res://.godot/imported/gold_converter_front_3.png-4b8a07d186c945c584be92c7bbbf79b8.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

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cj5m5k0hr3wmw"
path="res://.godot/imported/gold_converter_front_4.png-1dd90efaf325965268d803bbed7fda3b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entity/gold_converter_front_4.png"
dest_files=["res://.godot/imported/gold_converter_front_4.png-1dd90efaf325965268d803bbed7fda3b.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

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b5uershakuq20"
path="res://.godot/imported/gold_converter_front_5.png-a825d75eb13b041b1a6213049c3d7637.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entity/gold_converter_front_5.png"
dest_files=["res://.godot/imported/gold_converter_front_5.png-a825d75eb13b041b1a6213049c3d7637.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

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://wpen8vmuyvqv"
path="res://.godot/imported/item_chalice.png-7c6bf5aba6af81724e4a9b47b0fa9097.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entity/item_chalice.png"
dest_files=["res://.godot/imported/item_chalice.png-7c6bf5aba6af81724e4a9b47b0fa9097.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

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dvthocklcjh15"
path="res://.godot/imported/item_chalice_gems.png-182c84a35d2925a897cade98742ac714.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entity/item_chalice_gems.png"
dest_files=["res://.godot/imported/item_chalice_gems.png-182c84a35d2925a897cade98742ac714.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

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://brlo5pqo0x86l"
path="res://.godot/imported/item_crown.png-b1fdb9663d17347d4fbd39044017f645.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entity/item_crown.png"
dest_files=["res://.godot/imported/item_crown.png-b1fdb9663d17347d4fbd39044017f645.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

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://l7kr24oe0fc8"
path="res://.godot/imported/item_crown_gems.png-57e99547b8bc3470cb75cd17193c0abd.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entity/item_crown_gems.png"
dest_files=["res://.godot/imported/item_crown_gems.png-57e99547b8bc3470cb75cd17193c0abd.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

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dcw3cq3ni253t"
path="res://.godot/imported/item_ring.png-a4f5983b41259568642782622b1a92ac.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entity/item_ring.png"
dest_files=["res://.godot/imported/item_ring.png-a4f5983b41259568642782622b1a92ac.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

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dnfkvj0usdb6n"
path="res://.godot/imported/item_ring_gems.png-15fb2caf015b721a6fe6cd5c86878289.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entity/item_ring_gems.png"
dest_files=["res://.godot/imported/item_ring_gems.png-15fb2caf015b721a6fe6cd5c86878289.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

View file

@ -55,7 +55,6 @@ func _on_purchase_success(what: PurchasableItem):
store_collector_panel.hide()
func _on_store_collector_collected(_body: RigidBody2D):
print("collected")
update_counter_text()
func update_counter_text():
@ -76,4 +75,3 @@ func update_counter_icon():
store_collector_texturerect.texture = upgrade_gold_texture
else:
store_collector_texturerect.texture = null

View file

@ -11,11 +11,12 @@
[ext_resource type="PackedScene" uid="uid://du3005kwybbrh" path="res://entity/coin_gold/coin_gold.tscn" id="7_hh80i"]
[ext_resource type="PackedScene" uid="uid://ratkps4plkhl" path="res://converters/copper_to_silver/copper_converter.tscn" id="7_ipeok"]
[ext_resource type="PackedScene" uid="uid://but1bdslxp5jl" path="res://converters/silver_to_gold/silver_converter.tscn" id="8_0bbpi"]
[ext_resource type="PackedScene" path="res://entity/gem/gem.tscn" id="8_a3sk0"]
[ext_resource type="PackedScene" uid="uid://c2rlx7egl7xiv" path="res://collector/universal_collector.tscn" id="9_7op48"]
[ext_resource type="PackedScene" uid="uid://c5w3b55aiui6c" path="res://collector/collector.tscn" id="9_evdhb"]
[ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="10_sayqn"]
[ext_resource type="Texture2D" uid="uid://c8pvjgtr2ufjl" path="res://interface/upgrade_copper.png" id="11_lt33g"]
[ext_resource type="PackedScene" uid="uid://c4ew8x4gch275" path="res://converters/gold_to_gem/gem_converter.tscn" id="16_e62br"]
[ext_resource type="PackedScene" uid="uid://qtk4tm6l367w" path="res://interface/ghost.tscn" id="16_8vhx6"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_4uksi"]
size = Vector2(80, 80)
@ -39,11 +40,16 @@ upgrade_copper_texture = ExtResource("11_lt33g")
upgrade_silver_texture = ExtResource("3_8wvr1")
upgrade_gold_texture = ExtResource("4_i557v")
[node name="Ghost" parent="." instance=ExtResource("16_8vhx6")]
position = Vector2(90, 306)
collision_layer = 8
collision_mask = 6
[node name="Bottle" parent="." instance=ExtResource("1_y7o2l")]
[node name="TimeSpawner" parent="." node_paths=PackedStringArray("target") instance=ExtResource("3_qwsty")]
position = Vector2(136, 0)
scene = ExtResource("7_hh80i")
scene = ExtResource("8_a3sk0")
target = NodePath("..")
buffer_cap = 1
spawn_rect = Rect2(-20, 0, 40, 0)
@ -81,7 +87,7 @@ shape = SubResource("RectangleShape2D_rh35r")
debug_color = Color(0, 0.6, 0.701961, 0)
[node name="CopperConverter" parent="." instance=ExtResource("7_ipeok")]
position = Vector2(53, 156)
position = Vector2(62, 176)
metadata/_edit_group_ = true
[node name="Spawner" parent="CopperConverter" index="6" node_paths=PackedStringArray("target")]
@ -91,12 +97,8 @@ target = NodePath("../..")
position = Vector2(0, 4.08333)
[node name="SilverConverter" parent="." instance=ExtResource("8_0bbpi")]
position = Vector2(53, 273)
rotation = -6.28319
metadata/_edit_group_ = true
[node name="CollectShape" parent="SilverConverter/Collector" index="1"]
metadata/_edit_group_ = true
position = Vector2(205, 337)
rotation = -3.14159
[node name="Spawner" parent="SilverConverter" index="6" node_paths=PackedStringArray("target")]
target = NodePath("../..")
@ -178,10 +180,6 @@ position = Vector2(405, 540)
shape = SubResource("RectangleShape2D_jed57")
debug_color = Color(0, 0, 0, 0.419608)
[node name="GemConverter" parent="." instance=ExtResource("16_e62br")]
position = Vector2(144, 184)
metadata/_edit_group_ = true
[connection signal="timeout" from="TimeSpawner/Timer" to="TimeSpawner" method="spawn"]
[connection signal="changed" from="Evaluator" to="." method="_on_score_changed"]
[connection signal="collected" from="StoreCollector" to="." method="_on_store_collector_collected"]

20
game_camera.gd Normal file
View file

@ -0,0 +1,20 @@
extends Camera2D
class_name GameCamera
func set_camera_position(scaling_factor: float):
var cutouts: Array[Rect2] = DisplayServer.get_display_cutouts()
var bottom
if len(cutouts) == 0:
bottom = 8
else:
var screen: Vector2i = DisplayServer.screen_get_size()
var rect: Rect2i = DisplayServer.get_display_safe_area()
bottom = max(8, screen.y - rect.end.y)
print("[GameCamera] Bottom margin is: ", bottom)
var size = get_window().size.y / scaling_factor
position.y = 480 - (size / 2)

View file

@ -5,6 +5,10 @@ class_name CustomUI
@onready var window: Window = get_window()
@onready var viewport: Viewport = window.get_viewport()
@onready var game_safe_ui: MarginContainer = $GameSafeUI
@onready var shop_safe_ui: MarginContainer = $ShopSafeUI
@onready var game_camera: GameCamera = $GameViewport/Viewport/GameCamera
func _ready():
viewport.size_changed.connect(_on_viewport_size_changed)
@ -21,4 +25,6 @@ func _on_viewport_size_changed():
scaling_factor = window_size.y / 480
print("[View] Scaling factor is: ", scaling_factor)
get_window().set_content_scale_factor(scaling_factor)
$SafeUI.set_safe_margins(scaling_factor)
game_safe_ui.set_safe_margins(scaling_factor)
shop_safe_ui.set_safe_margins(scaling_factor)
game_camera.set_camera_position(scaling_factor)

View file

@ -5,12 +5,11 @@
[ext_resource type="PackedScene" uid="uid://bey5lilvteg32" path="res://interface/score_button.tscn" id="3_vobar"]
[node name="GameUI" type="Control" node_paths=PackedStringArray("score_button")]
custom_minimum_size = Vector2(0, 54)
layout_mode = 3
anchors_preset = 15
anchors_preset = 10
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_ppf8y")
script = ExtResource("2_33nqa")
score_button = NodePath("ScoreButton")
@ -18,7 +17,6 @@ score_button = NodePath("ScoreButton")
[node name="ScoreButton" parent="." instance=ExtResource("3_vobar")]
custom_minimum_size = Vector2(88, 0)
layout_mode = 0
text = "$0.00"
[node name="SpawnButton" type="Button" parent="."]
custom_minimum_size = Vector2(88, 0)

25
interface/ghost.gd Normal file
View file

@ -0,0 +1,25 @@
extends Area2D
class_name Ghost
var is_dragging: bool
var previous_position: Vector2
func _input(event: InputEvent):
if event is InputEventMouseButton:
is_dragging = event.pressed
previous_position = event.position
elif event is InputEventScreenTouch:
is_dragging = event.pressed
previous_position = event.position
if is_dragging:
if event is InputEventMouseMotion:
var delta = event.position - previous_position
print(delta)
position += delta
previous_position = event.position
elif event is InputEventScreenDrag:
var delta = event.position - previous_position
print(delta)
position += delta
previous_position = event.position

20
interface/ghost.tscn Normal file
View file

@ -0,0 +1,20 @@
[gd_scene load_steps=4 format=3 uid="uid://qtk4tm6l367w"]
[ext_resource type="Script" path="res://interface/ghost.gd" id="1_gvls7"]
[ext_resource type="Texture2D" uid="uid://pj3ip6vlatms" path="res://converters/copper_to_silver/copper_converter.png" id="1_lo8gj"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_hmopu"]
size = Vector2(34, 34)
[node name="Ghost" type="Area2D"]
scale = Vector2(3, 3)
input_pickable = false
script = ExtResource("1_gvls7")
[node name="Sprite" type="Sprite2D" parent="."]
modulate = Color(1, 1, 1, 0.470588)
z_index = 10
texture = ExtResource("1_lo8gj")
[node name="Shape" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_hmopu")

View file

@ -2,6 +2,12 @@ extends MarginContainer
class_name SafeUI
@export var apply_margin_left: bool
@export var apply_margin_right: bool
@export var apply_margin_top: bool
@export var apply_margin_bottom: bool
func set_safe_margins(scaling_factor: float):
var cutouts: Array[Rect2] = DisplayServer.get_display_cutouts()
@ -18,16 +24,21 @@ func set_safe_margins(scaling_factor: float):
else:
var screen: Vector2i = DisplayServer.screen_get_size()
var rect: Rect2i = DisplayServer.get_display_safe_area()
left = rect.position.x
right = screen.x - rect.end.x
top = rect.position.y
bottom = screen.y - rect.end.y
left = max(8, rect.position.x)
right = max(8, screen.x - rect.end.x)
top = max(8, rect.position.y)
bottom = max(8, screen.y - rect.end.y)
print("[SafeUI] Left margin is: ", left)
print("[SafeUI] Right margin is: ", right)
print("[SafeUI] Top margin is: ", top)
print("[SafeUI] Bottom margin is: ", bottom)
add_theme_constant_override("margin_left", left / scaling_factor)
add_theme_constant_override("margin_right", right / scaling_factor)
add_theme_constant_override("margin_top", top / scaling_factor)
add_theme_constant_override("margin_bottom", bottom / scaling_factor)
if apply_margin_left:
add_theme_constant_override("margin_left", left / scaling_factor)
if apply_margin_right:
add_theme_constant_override("margin_right", right / scaling_factor)
if apply_margin_top:
add_theme_constant_override("margin_top", top / scaling_factor)
if apply_margin_bottom:
add_theme_constant_override("margin_bottom", bottom / scaling_factor)

11
interface/safe_ui.tscn Normal file
View file

@ -0,0 +1,11 @@
[gd_scene load_steps=2 format=3 uid="uid://e4be5wkya7g0"]
[ext_resource type="Script" path="res://interface/safe_ui.gd" id="1_ceq6m"]
[node name="SafeUI" type="MarginContainer"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_ceq6m")

16
main.gd
View file

@ -3,8 +3,10 @@ class_name Main
@onready var tree: SceneTree = get_tree()
@onready var game_ui: GameUI = $CustomUI/SafeUI/GameUI
@onready var shop_ui: ShopUI = $CustomUI/SafeUI/ShopUI
@onready var game_safe_ui: MarginContainer = $CustomUI/GameSafeUI
@onready var game_ui: GameUI = $CustomUI/GameSafeUI/GameUI
@onready var shop_safe_ui: MarginContainer = $CustomUI/ShopSafeUI
@onready var shop_ui: ShopUI = $CustomUI/ShopSafeUI/ShopUI
enum UIState {
@ -20,12 +22,14 @@ enum UIState {
match value:
UIState.GAME:
tree.paused = false
game_ui.show()
shop_ui.hide()
game_safe_ui.show()
shop_safe_ui.hide()
shop_safe_ui.process_mode = Node.PROCESS_MODE_DISABLED
UIState.SHOP:
tree.paused = true
game_ui.hide()
shop_ui.show()
game_safe_ui.hide()
shop_safe_ui.show()
shop_safe_ui.process_mode = Node.PROCESS_MODE_ALWAYS
UIState.SCORE:
pass

106
main.tscn
View file

@ -1,12 +1,17 @@
[gd_scene load_steps=8 format=3 uid="uid://dqm0h5h0baqcg"]
[gd_scene load_steps=10 format=3 uid="uid://dqm0h5h0baqcg"]
[ext_resource type="Script" path="res://main.gd" id="1_fqt34"]
[ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="1_je7w1"]
[ext_resource type="PackedScene" uid="uid://c3rxmcwa5nqng" path="res://game/game.tscn" id="2_32lou"]
[ext_resource type="PackedScene" uid="uid://cklkdygv61bny" path="res://interface/shop_ui.tscn" id="2_qj86l"]
[ext_resource type="Script" path="res://interface/custom_ui.gd" id="3_xav0n"]
[ext_resource type="Script" path="res://interface/safe_ui.gd" id="4_nel0n"]
[ext_resource type="PackedScene" uid="uid://bo5unrhqpoyim" path="res://interface/game_ui.tscn" id="4_siim3"]
[ext_resource type="PackedScene" uid="uid://bpvx3nkkbluip" path="res://safe_ui.tscn" id="5_2uxda"]
[ext_resource type="Script" path="res://game_camera.gd" id="5_xxjtg"]
[sub_resource type="GDScript" id="GDScript_kyj65"]
script/source = "extends SubViewport
"
[node name="Main" type="Node"]
script = ExtResource("1_fqt34")
@ -20,65 +25,68 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_vertical = 8
mouse_filter = 1
theme = ExtResource("1_je7w1")
script = ExtResource("3_xav0n")
[node name="GameWorld" type="CenterContainer" parent="CustomUI"]
custom_minimum_size = Vector2(270, 480)
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -135.0
offset_top = -480.0
offset_right = 135.0
grow_horizontal = 2
grow_vertical = 0
[node name="GameViewport" type="SubViewportContainer" parent="CustomUI/GameWorld"]
layout_mode = 2
[node name="Viewport" type="SubViewport" parent="CustomUI/GameWorld/GameViewport"]
disable_3d = true
handle_input_locally = false
size = Vector2i(270, 480)
render_target_update_mode = 4
[node name="Game" parent="CustomUI/GameWorld/GameViewport/Viewport" instance=ExtResource("2_32lou")]
[node name="Camera" type="Camera2D" parent="CustomUI/GameWorld/GameViewport/Viewport"]
anchor_mode = 0
[node name="SafeUI" type="MarginContainer" parent="CustomUI"]
[node name="GameViewport" type="SubViewportContainer" parent="CustomUI"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("4_nel0n")
mouse_default_cursor_shape = 5
stretch = true
[node name="GameUI" parent="CustomUI/SafeUI" instance=ExtResource("4_siim3")]
[node name="Viewport" type="SubViewport" parent="CustomUI/GameViewport"]
disable_3d = true
handle_input_locally = false
physics_object_picking = true
size = Vector2i(270, 480)
render_target_update_mode = 4
script = SubResource("GDScript_kyj65")
[node name="Game" parent="CustomUI/GameViewport/Viewport" instance=ExtResource("2_32lou")]
[node name="GameCamera" type="Camera2D" parent="CustomUI/GameViewport/Viewport"]
position = Vector2(135, 480)
script = ExtResource("5_xxjtg")
[node name="GameSafeUI" parent="CustomUI" instance=ExtResource("5_2uxda")]
layout_mode = 1
anchors_preset = 10
anchor_bottom = 0.0
grow_vertical = 1
apply_margin_left = true
apply_margin_right = true
apply_margin_top = true
[node name="GameUI" parent="CustomUI/GameSafeUI" instance=ExtResource("4_siim3")]
layout_mode = 2
[node name="ShopUI" parent="CustomUI/SafeUI" instance=ExtResource("2_qj86l")]
process_mode = 3
[node name="ShopSafeUI" parent="CustomUI" instance=ExtResource("5_2uxda")]
process_mode = 4
visible = false
layout_mode = 1
apply_margin_left = true
apply_margin_right = true
apply_margin_top = true
apply_margin_bottom = true
[node name="ShopUI" parent="CustomUI/ShopSafeUI" instance=ExtResource("2_qj86l")]
layout_mode = 2
[connection signal="score_changed" from="CustomUI/GameWorld/GameViewport/Viewport/Game" to="CustomUI/SafeUI/GameUI" method="_on_game_score_changed"]
[connection signal="score_changed" from="CustomUI/GameWorld/GameViewport/Viewport/Game" to="CustomUI/SafeUI/ShopUI" method="_on_game_score_changed"]
[connection signal="score_button_pressed" from="CustomUI/SafeUI/GameUI" to="." method="_on_game_ui_score_button_pressed"]
[connection signal="shop_button_pressed" from="CustomUI/SafeUI/GameUI" to="." method="_on_game_ui_shop_button_pressed"]
[connection signal="spawn_button_pressed" from="CustomUI/SafeUI/GameUI" to="CustomUI/GameWorld/GameViewport/Viewport/Game" method="trigger_spawn"]
[connection signal="back_button_pressed" from="CustomUI/SafeUI/ShopUI" to="." method="_on_shop_ui_back_button_pressed"]
[connection signal="delete_button_pressed" from="CustomUI/SafeUI/ShopUI" to="." method="_on_shop_ui_delete_button_pressed"]
[connection signal="purchase_begin" from="CustomUI/SafeUI/ShopUI" to="." method="_on_shop_ui_purchase_begin"]
[connection signal="purchase_begin" from="CustomUI/SafeUI/ShopUI" to="CustomUI/GameWorld/GameViewport/Viewport/Game" method="_on_purchase_begin"]
[connection signal="purchase_cancel" from="CustomUI/SafeUI/ShopUI" to="CustomUI/GameWorld/GameViewport/Viewport/Game" method="_on_purchase_cancel"]
[connection signal="purchase_success" from="CustomUI/SafeUI/ShopUI" to="CustomUI/GameWorld/GameViewport/Viewport/Game" method="_on_purchase_success"]
[connection signal="score_button_pressed" from="CustomUI/SafeUI/ShopUI" to="." method="_on_shop_ui_score_button_pressed"]
[connection signal="upgraded_auto_spawn" from="CustomUI/SafeUI/ShopUI" to="CustomUI/GameWorld/GameViewport/Viewport/Game" method="_on_upgraded_auto_spawn"]
[connection signal="upgraded_manual_spawn" from="CustomUI/SafeUI/ShopUI" to="CustomUI/GameWorld/GameViewport/Viewport/Game" method="_on_upgraded_manual_spawn"]
[connection signal="score_changed" from="CustomUI/GameViewport/Viewport/Game" to="CustomUI/GameSafeUI/GameUI" method="_on_game_score_changed"]
[connection signal="score_button_pressed" from="CustomUI/GameSafeUI/GameUI" to="." method="_on_game_ui_score_button_pressed"]
[connection signal="shop_button_pressed" from="CustomUI/GameSafeUI/GameUI" to="." method="_on_game_ui_shop_button_pressed"]
[connection signal="spawn_button_pressed" from="CustomUI/GameSafeUI/GameUI" to="CustomUI/GameViewport/Viewport/Game" method="trigger_spawn"]
[connection signal="back_button_pressed" from="CustomUI/ShopSafeUI/ShopUI" to="." method="_on_shop_ui_back_button_pressed"]
[connection signal="delete_button_pressed" from="CustomUI/ShopSafeUI/ShopUI" to="." method="_on_shop_ui_delete_button_pressed"]
[connection signal="purchase_begin" from="CustomUI/ShopSafeUI/ShopUI" to="." method="_on_shop_ui_purchase_begin"]
[connection signal="purchase_begin" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameViewport/Viewport/Game" method="_on_purchase_begin"]
[connection signal="purchase_cancel" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameViewport/Viewport/Game" method="_on_purchase_cancel"]
[connection signal="purchase_success" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameViewport/Viewport/Game" method="_on_purchase_success"]
[connection signal="score_button_pressed" from="CustomUI/ShopSafeUI/ShopUI" to="." method="_on_shop_ui_score_button_pressed"]
[connection signal="upgraded_auto_spawn" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameViewport/Viewport/Game" method="_on_upgraded_auto_spawn"]
[connection signal="upgraded_manual_spawn" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameViewport/Viewport/Game" method="_on_upgraded_manual_spawn"]

View file

@ -30,6 +30,7 @@ window/handheld/orientation=1
2d_physics/layer_1="Default"
2d_physics/layer_2="Bottle"
2d_physics/layer_3="Entities"
2d_physics/layer_4="Ghost"
[physics]

11
safe_ui.tscn Normal file
View file

@ -0,0 +1,11 @@
[gd_scene load_steps=2 format=3 uid="uid://bpvx3nkkbluip"]
[ext_resource type="Script" path="res://interface/safe_ui.gd" id="1_y2ofp"]
[node name="SafeUI" type="MarginContainer"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_y2ofp")