refactor to use mediator pattern with EventBus
This commit is contained in:
parent
a4136c937f
commit
0cf64a4bc9
15 changed files with 212 additions and 225 deletions
7
scenes/Camera.tscn
Normal file
7
scenes/Camera.tscn
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://bwki262totuo4"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/Camera.gd" id="1_ttsl2"]
|
||||||
|
|
||||||
|
[node name="Camera" type="Camera2D"]
|
||||||
|
position = Vector2(1288, 720)
|
||||||
|
script = ExtResource("1_ttsl2")
|
|
@ -1,6 +0,0 @@
|
||||||
[gd_scene load_steps=2 format=3 uid="uid://2we3txfr812u"]
|
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/CameraZoom2D.gd" id="1_ttsl2"]
|
|
||||||
|
|
||||||
[node name="CameraZoom2D" type="Camera2D"]
|
|
||||||
script = ExtResource("1_ttsl2")
|
|
|
@ -1,61 +1,63 @@
|
||||||
[gd_scene load_steps=12 format=3 uid="uid://b1bahdquscsym"]
|
[gd_scene load_steps=14 format=3 uid="uid://c5deq5s55q0ii"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/Main.gd" id="1_ysxum"]
|
[ext_resource type="Script" path="res://scripts/Main.gd" id="1_ysxum"]
|
||||||
[ext_resource type="Script" path="res://scripts/EventBus.gd" id="2_0j1ud"]
|
[ext_resource type="Script" path="res://scripts/EventBus.gd" id="2_0j1ud"]
|
||||||
[ext_resource type="Script" path="res://scripts/ChunkHandler.gd" id="2_6cequ"]
|
[ext_resource type="Script" path="res://scripts/ChunkHandler.gd" id="2_6cequ"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dq7jmiqon170p" path="res://scenes/MainMenu.tscn" id="2_wfpe2"]
|
[ext_resource type="PackedScene" uid="uid://dq7jmiqon170p" path="res://scenes/MainMenu.tscn" id="2_wfpe2"]
|
||||||
[ext_resource type="Script" path="res://scripts/Control.gd" id="3_1t1c8"]
|
[ext_resource type="Script" path="res://scripts/Control.gd" id="3_1t1c8"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/Camera.gd" id="3_15x8g"]
|
||||||
[ext_resource type="Script" path="res://scripts/Game.gd" id="4_4tr6y"]
|
[ext_resource type="Script" path="res://scripts/Game.gd" id="4_4tr6y"]
|
||||||
[ext_resource type="PackedScene" uid="uid://2we3txfr812u" path="res://scenes/Camera_zoom_2d.tscn" id="4_rx82t"]
|
[ext_resource type="Script" path="res://scripts/Simulation.gd" id="5_0dxab"]
|
||||||
[ext_resource type="Script" path="res://scripts/EntityPlacer.gd" id="5_8jju5"]
|
[ext_resource type="Script" path="res://scripts/EntityPlacer.gd" id="5_8jju5"]
|
||||||
[ext_resource type="Script" path="res://scripts/Minimap.gd" id="5_rg28x"]
|
[ext_resource type="Script" path="res://scripts/Minimap.gd" id="5_rg28x"]
|
||||||
[ext_resource type="Script" path="res://scripts/CameraMarker.gd" id="7_6krn1"]
|
[ext_resource type="Script" path="res://scripts/CameraMarker.gd" id="7_6krn1"]
|
||||||
[ext_resource type="Script" path="res://scripts/MapBackground.gd" id="8_ron2j"]
|
[ext_resource type="Script" path="res://scripts/MapBackground.gd" id="8_ron2j"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/UILayer.gd" id="9_ebec0"]
|
||||||
|
|
||||||
[node name="Main" type="Node2D"]
|
[node name="Main" type="Node"]
|
||||||
script = ExtResource("1_ysxum")
|
script = ExtResource("1_ysxum")
|
||||||
|
|
||||||
[node name="EventBus" type="Node" parent="."]
|
[node name="EventBus" type="Node" parent="."]
|
||||||
|
process_mode = 3
|
||||||
script = ExtResource("2_0j1ud")
|
script = ExtResource("2_0j1ud")
|
||||||
|
|
||||||
[node name="MainMenu" parent="EventBus" instance=ExtResource("2_wfpe2")]
|
[node name="Camera" type="Camera2D" parent="EventBus"]
|
||||||
process_mode = 2
|
process_mode = 1
|
||||||
|
position = Vector2(1280, 720)
|
||||||
|
ignore_rotation = false
|
||||||
|
script = ExtResource("3_15x8g")
|
||||||
|
|
||||||
[node name="Game" type="Node2D" parent="EventBus"]
|
[node name="Game" type="Node2D" parent="EventBus"]
|
||||||
process_mode = 1
|
process_mode = 1
|
||||||
visible = false
|
visible = false
|
||||||
script = ExtResource("4_4tr6y")
|
script = ExtResource("4_4tr6y")
|
||||||
|
|
||||||
|
[node name="Simulation" type="Node" parent="EventBus/Game"]
|
||||||
|
script = ExtResource("5_0dxab")
|
||||||
|
|
||||||
[node name="ChunkHandler" type="Node2D" parent="EventBus/Game"]
|
[node name="ChunkHandler" type="Node2D" parent="EventBus/Game"]
|
||||||
script = ExtResource("2_6cequ")
|
script = ExtResource("2_6cequ")
|
||||||
|
|
||||||
[node name="CameraZoom2D" parent="EventBus/Game" instance=ExtResource("4_rx82t")]
|
|
||||||
position = Vector2(1272, 720)
|
|
||||||
ignore_rotation = false
|
|
||||||
limit_left = 0
|
|
||||||
limit_top = 0
|
|
||||||
limit_right = 65536
|
|
||||||
limit_bottom = 65536
|
|
||||||
limit_smoothed = true
|
|
||||||
rotation_smoothing_enabled = true
|
|
||||||
editor_draw_limits = true
|
|
||||||
|
|
||||||
[node name="MapBackground" type="Sprite2D" parent="EventBus/Game"]
|
[node name="MapBackground" type="Sprite2D" parent="EventBus/Game"]
|
||||||
z_index = -1
|
z_index = -1
|
||||||
centered = false
|
centered = false
|
||||||
script = ExtResource("8_ron2j")
|
script = ExtResource("8_ron2j")
|
||||||
|
|
||||||
[node name="UILayer" type="CanvasLayer" parent="EventBus/Game"]
|
[node name="MainMenu" parent="EventBus" instance=ExtResource("2_wfpe2")]
|
||||||
visible = false
|
|
||||||
|
|
||||||
[node name="EntityPlacer" type="Control" parent="EventBus/Game/UILayer"]
|
[node name="UILayer" type="CanvasLayer" parent="EventBus"]
|
||||||
|
process_mode = 1
|
||||||
|
visible = false
|
||||||
|
script = ExtResource("9_ebec0")
|
||||||
|
|
||||||
|
[node name="EntityPlacer" type="Control" parent="EventBus/UILayer"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 0
|
anchors_preset = 0
|
||||||
offset_right = 40.0
|
offset_right = 40.0
|
||||||
offset_bottom = 40.0
|
offset_bottom = 40.0
|
||||||
script = ExtResource("5_8jju5")
|
script = ExtResource("5_8jju5")
|
||||||
|
|
||||||
[node name="Control" type="Control" parent="EventBus/Game/UILayer"]
|
[node name="Control" type="Control" parent="EventBus/UILayer"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
@ -66,7 +68,7 @@ mouse_filter = 1
|
||||||
script = ExtResource("3_1t1c8")
|
script = ExtResource("3_1t1c8")
|
||||||
metadata/_edit_use_anchors_ = true
|
metadata/_edit_use_anchors_ = true
|
||||||
|
|
||||||
[node name="ConstructionPanel" type="Panel" parent="EventBus/Game/UILayer/Control"]
|
[node name="ConstructionPanel" type="Panel" parent="EventBus/UILayer/Control"]
|
||||||
custom_minimum_size = Vector2(500, 100)
|
custom_minimum_size = Vector2(500, 100)
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 5
|
anchors_preset = 5
|
||||||
|
@ -77,42 +79,42 @@ offset_right = 250.0
|
||||||
offset_bottom = 100.0
|
offset_bottom = 100.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
|
|
||||||
[node name="button_residental" type="Button" parent="EventBus/Game/UILayer/Control/ConstructionPanel"]
|
[node name="button_residental" type="Button" parent="EventBus/UILayer/Control/ConstructionPanel"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 8.0
|
offset_right = 8.0
|
||||||
offset_bottom = 8.0
|
offset_bottom = 8.0
|
||||||
|
|
||||||
[node name="button_commercial" type="Button" parent="EventBus/Game/UILayer/Control/ConstructionPanel"]
|
[node name="button_commercial" type="Button" parent="EventBus/UILayer/Control/ConstructionPanel"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 8.0
|
offset_right = 8.0
|
||||||
offset_bottom = 8.0
|
offset_bottom = 8.0
|
||||||
|
|
||||||
[node name="button_industrial" type="Button" parent="EventBus/Game/UILayer/Control/ConstructionPanel"]
|
[node name="button_industrial" type="Button" parent="EventBus/UILayer/Control/ConstructionPanel"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 8.0
|
offset_right = 8.0
|
||||||
offset_bottom = 8.0
|
offset_bottom = 8.0
|
||||||
|
|
||||||
[node name="button_roads" type="Button" parent="EventBus/Game/UILayer/Control/ConstructionPanel"]
|
[node name="button_roads" type="Button" parent="EventBus/UILayer/Control/ConstructionPanel"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 8.0
|
offset_right = 8.0
|
||||||
offset_bottom = 8.0
|
offset_bottom = 8.0
|
||||||
|
|
||||||
[node name="button_demolish" type="Button" parent="EventBus/Game/UILayer/Control/ConstructionPanel"]
|
[node name="button_demolish" type="Button" parent="EventBus/UILayer/Control/ConstructionPanel"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 8.0
|
offset_right = 8.0
|
||||||
offset_bottom = 8.0
|
offset_bottom = 8.0
|
||||||
|
|
||||||
[node name="button_services" type="Button" parent="EventBus/Game/UILayer/Control/ConstructionPanel"]
|
[node name="button_services" type="Button" parent="EventBus/UILayer/Control/ConstructionPanel"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 8.0
|
offset_right = 8.0
|
||||||
offset_bottom = 8.0
|
offset_bottom = 8.0
|
||||||
|
|
||||||
[node name="button_social" type="Button" parent="EventBus/Game/UILayer/Control/ConstructionPanel"]
|
[node name="button_social" type="Button" parent="EventBus/UILayer/Control/ConstructionPanel"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 8.0
|
offset_right = 8.0
|
||||||
offset_bottom = 8.0
|
offset_bottom = 8.0
|
||||||
|
|
||||||
[node name="DebugContainer" type="GridContainer" parent="EventBus/Game/UILayer/Control"]
|
[node name="DebugContainer" type="GridContainer" parent="EventBus/UILayer/Control"]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 1
|
anchors_preset = 1
|
||||||
anchor_left = 1.0
|
anchor_left = 1.0
|
||||||
|
@ -122,10 +124,10 @@ offset_top = 24.0
|
||||||
offset_bottom = 424.0
|
offset_bottom = 424.0
|
||||||
grow_horizontal = 0
|
grow_horizontal = 0
|
||||||
|
|
||||||
[node name="DebugInfo" type="Label" parent="EventBus/Game/UILayer/Control/DebugContainer"]
|
[node name="DebugInfo" type="Label" parent="EventBus/UILayer/Control/DebugContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="Minimap" type="Panel" parent="EventBus/Game/UILayer/Control"]
|
[node name="Minimap" type="Panel" parent="EventBus/UILayer/Control"]
|
||||||
clip_contents = true
|
clip_contents = true
|
||||||
custom_minimum_size = Vector2(512, 512)
|
custom_minimum_size = Vector2(512, 512)
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
@ -141,27 +143,25 @@ grow_vertical = 0
|
||||||
mouse_filter = 1
|
mouse_filter = 1
|
||||||
script = ExtResource("5_rg28x")
|
script = ExtResource("5_rg28x")
|
||||||
|
|
||||||
[node name="CameraMarker" type="Sprite2D" parent="EventBus/Game/UILayer/Control/Minimap"]
|
[node name="CameraMarker" type="Sprite2D" parent="EventBus/UILayer/Control/Minimap"]
|
||||||
z_index = 10
|
z_index = 10
|
||||||
position = Vector2(-32, 0)
|
position = Vector2(-32, 0)
|
||||||
centered = false
|
centered = false
|
||||||
script = ExtResource("7_6krn1")
|
script = ExtResource("7_6krn1")
|
||||||
|
|
||||||
[node name="MinimapSprite" type="Sprite2D" parent="EventBus/Game/UILayer/Control/Minimap"]
|
[node name="MinimapSprite" type="Sprite2D" parent="EventBus/UILayer/Control/Minimap"]
|
||||||
texture_repeat = 1
|
texture_repeat = 1
|
||||||
centered = false
|
centered = false
|
||||||
|
|
||||||
[connection signal="chunk_stats" from="EventBus/Game/ChunkHandler" to="EventBus/Game/UILayer/Control" method="_on_chunk_handler_chunk_stats"]
|
[connection signal="chunk_stats" from="EventBus/Game/ChunkHandler" to="EventBus/UILayer/Control" method="_on_chunk_handler_chunk_stats"]
|
||||||
[connection signal="camera_rotation_changed" from="EventBus/Game/CameraZoom2D" to="EventBus/Game/UILayer/Control/Minimap/CameraMarker" method="_on_camera_zoom_2d_camera_rotation_changed"]
|
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_residental" to="EventBus/UILayer/Control" method="_on_button_residental_pressed"]
|
||||||
[connection signal="camera_zoom_changed" from="EventBus/Game/CameraZoom2D" to="EventBus/Game/UILayer/Control/Minimap/CameraMarker" method="_on_camera_zoom_2d_camera_zoom_changed"]
|
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_commercial" to="EventBus/UILayer/Control" method="_on_button_commercial_pressed"]
|
||||||
[connection signal="pressed" from="EventBus/Game/UILayer/Control/ConstructionPanel/button_residental" to="EventBus/Game/UILayer/Control" method="_on_button_residental_pressed"]
|
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_industrial" to="EventBus/UILayer/Control" method="_on_button_industrial_pressed"]
|
||||||
[connection signal="pressed" from="EventBus/Game/UILayer/Control/ConstructionPanel/button_commercial" to="EventBus/Game/UILayer/Control" method="_on_button_commercial_pressed"]
|
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_roads" to="EventBus/UILayer/Control" method="_on_button_roads_pressed"]
|
||||||
[connection signal="pressed" from="EventBus/Game/UILayer/Control/ConstructionPanel/button_industrial" to="EventBus/Game/UILayer/Control" method="_on_button_industrial_pressed"]
|
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_demolish" to="EventBus/UILayer/Control" method="_on_button_demolish_pressed"]
|
||||||
[connection signal="pressed" from="EventBus/Game/UILayer/Control/ConstructionPanel/button_roads" to="EventBus/Game/UILayer/Control" method="_on_button_roads_pressed"]
|
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_services" to="EventBus/UILayer/Control" method="_on_button_services_pressed"]
|
||||||
[connection signal="pressed" from="EventBus/Game/UILayer/Control/ConstructionPanel/button_demolish" to="EventBus/Game/UILayer/Control" method="_on_button_demolish_pressed"]
|
[connection signal="pressed" from="EventBus/UILayer/Control/ConstructionPanel/button_social" to="EventBus/UILayer/Control" method="_on_button_social_pressed"]
|
||||||
[connection signal="pressed" from="EventBus/Game/UILayer/Control/ConstructionPanel/button_services" to="EventBus/Game/UILayer/Control" method="_on_button_services_pressed"]
|
[connection signal="mouse_entered" from="EventBus/UILayer/Control/Minimap" to="EventBus/UILayer/Control/Minimap" method="_on_mouse_entered"]
|
||||||
[connection signal="pressed" from="EventBus/Game/UILayer/Control/ConstructionPanel/button_social" to="EventBus/Game/UILayer/Control" method="_on_button_social_pressed"]
|
[connection signal="mouse_exited" from="EventBus/UILayer/Control/Minimap" to="EventBus/UILayer/Control/Minimap" method="_on_mouse_exited"]
|
||||||
[connection signal="mouse_entered" from="EventBus/Game/UILayer/Control/Minimap" to="EventBus/Game/UILayer/Control/Minimap" method="_on_mouse_entered"]
|
[connection signal="set_camera_position" from="EventBus/UILayer/Control/Minimap" to="EventBus" method="set_camera_position"]
|
||||||
[connection signal="mouse_exited" from="EventBus/Game/UILayer/Control/Minimap" to="EventBus/Game/UILayer/Control/Minimap" method="_on_mouse_exited"]
|
[connection signal="set_map_background_texture" from="EventBus/UILayer/Control/Minimap" to="EventBus/Game" method="_on_minimap_set_map_background_texture"]
|
||||||
[connection signal="set_camera_position" from="EventBus/Game/UILayer/Control/Minimap" to="EventBus" method="set_camera_position"]
|
|
||||||
[connection signal="set_map_background_texture" from="EventBus/Game/UILayer/Control/Minimap" to="EventBus/Game" method="_on_minimap_set_map_background_texture"]
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ offset_bottom = 1155.0
|
||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
size_flags_vertical = 4
|
size_flags_vertical = 4
|
||||||
theme_override_constants/v_separation = 32
|
theme_override_constants/v_separation = 32
|
||||||
metadata/_edit_use_anchors_ = true
|
|
||||||
|
|
||||||
[node name="Menu_NewGame" type="Button" parent="MainMenuBar"]
|
[node name="Menu_NewGame" type="Button" parent="MainMenuBar"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
@ -65,8 +64,9 @@ alignment = 0
|
||||||
|
|
||||||
[node name="MenuBackground" type="Sprite2D" parent="."]
|
[node name="MenuBackground" type="Sprite2D" parent="."]
|
||||||
z_index = -1
|
z_index = -1
|
||||||
position = Vector2(1320, 736)
|
scale = Vector2(0.67, 0.667)
|
||||||
texture = ExtResource("2_7rmv5")
|
texture = ExtResource("2_7rmv5")
|
||||||
|
centered = false
|
||||||
|
|
||||||
[node name="MenuLogo" type="Sprite2D" parent="."]
|
[node name="MenuLogo" type="Sprite2D" parent="."]
|
||||||
position = Vector2(856, 592)
|
position = Vector2(856, 592)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Class handles the camera zoom and movement in the game
|
# Class handles the camera zoom and movement in the game
|
||||||
class_name CameraZoom2D
|
class_name Camera
|
||||||
extends Camera2D
|
extends Camera2D
|
||||||
|
|
||||||
signal camera_rotation_changed(new_rotation)
|
signal camera_rotation_changed(new_rotation)
|
||||||
|
@ -8,30 +8,47 @@ signal camera_zoom_changed(new_zoom_factor)
|
||||||
var is_panning_camera:bool = false
|
var is_panning_camera:bool = false
|
||||||
var tween:Tween
|
var tween:Tween
|
||||||
|
|
||||||
var chunk_in_px:Vector2i = Vector2i(Globals.CHUNK_SIZE.x*Globals.TILE_SIZE_X, Globals.CHUNK_SIZE.y*Globals.TILE_SIZE_Y)
|
var chunk_in_px:Vector2i = Vector2i(
|
||||||
|
Globals.CHUNK_SIZE.x * Globals.TILE_SIZE_X,
|
||||||
|
Globals.CHUNK_SIZE.y * Globals.TILE_SIZE_Y)
|
||||||
var game_res:Vector2i = DisplayServer.window_get_size(0)
|
var game_res:Vector2i = DisplayServer.window_get_size(0)
|
||||||
var x_min_limit:int = self.game_res.x/2 - chunk_in_px.x
|
var x_min_limit:int = self.game_res.x/2 - chunk_in_px.x
|
||||||
|
|
||||||
#@onready var captured_image = $CapturedImage
|
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
func _process(_delta) -> void:
|
func _process(_delta) -> void:
|
||||||
Globals.CAMERA_POSITION = self.get_camera_position()
|
Globals.CAMERA_POSITION = self.get_camera_position()
|
||||||
|
|
||||||
|
|
||||||
func set_ready() -> void:
|
func get_camera_position():
|
||||||
|
return self.position
|
||||||
|
|
||||||
|
|
||||||
|
func get_camera_panning() -> bool:
|
||||||
|
return self.is_panning_camera
|
||||||
|
|
||||||
|
|
||||||
|
func get_camera_rotation():
|
||||||
|
return self.rotation
|
||||||
|
|
||||||
|
|
||||||
|
func set_camera_panning(value:bool) -> void:
|
||||||
|
self.is_panning_camera = value
|
||||||
|
|
||||||
|
|
||||||
|
func set_camera_position(pos: Vector2) -> void:
|
||||||
|
self.position = pos
|
||||||
|
print("camera pos set:", self.position)
|
||||||
|
|
||||||
|
|
||||||
|
func set_camera_limits() -> void:
|
||||||
# set camera bounds to map size, with chunk_in_px room to go over
|
# set camera bounds to map size, with chunk_in_px room to go over
|
||||||
self.set_limit(SIDE_LEFT, -chunk_in_px.x)
|
self.set_limit(SIDE_LEFT, -chunk_in_px.x)
|
||||||
self.set_limit(SIDE_RIGHT, Globals.map_size*Globals.TILE_SIZE_X + chunk_in_px.x)
|
self.set_limit(SIDE_RIGHT, Globals.map_size*Globals.TILE_SIZE_X + chunk_in_px.x)
|
||||||
self.set_limit(SIDE_TOP, -chunk_in_px.y)
|
self.set_limit(SIDE_TOP, -chunk_in_px.y)
|
||||||
self.set_limit(SIDE_BOTTOM, Globals.map_size*Globals.TILE_SIZE_Y + chunk_in_px.y)
|
self.set_limit(SIDE_BOTTOM, Globals.map_size*Globals.TILE_SIZE_Y + chunk_in_px.y)
|
||||||
|
|
||||||
|
|
||||||
func _set_camera_zoom_level(value: float) -> void:
|
func set_camera_zoom_level(value: float) -> void:
|
||||||
# keep zoom level in bounds, return if zoom level was at min or max zoom
|
# keep zoom level in bounds, return if zoom level was at min or max zoom
|
||||||
var new_zoom_level = clamp(value, Globals.CAMERA_MIN_ZOOM_LEVEL, Globals.CAMERA_MAX_ZOOM_LEVEL)
|
var new_zoom_level = clamp(value, Globals.CAMERA_MIN_ZOOM_LEVEL, Globals.CAMERA_MAX_ZOOM_LEVEL)
|
||||||
if new_zoom_level == Globals.CAMERA_ZOOM_LEVEL:
|
if new_zoom_level == Globals.CAMERA_ZOOM_LEVEL:
|
||||||
|
@ -51,27 +68,7 @@ func _set_camera_zoom_level(value: float) -> void:
|
||||||
emit_signal("camera_zoom_changed", new_zoom_level)
|
emit_signal("camera_zoom_changed", new_zoom_level)
|
||||||
|
|
||||||
|
|
||||||
func get_camera_position():
|
func clamp_camera_position() -> void:
|
||||||
return self.position
|
|
||||||
|
|
||||||
|
|
||||||
func get_camera_panning() -> bool:
|
|
||||||
return self.is_panning_camera
|
|
||||||
|
|
||||||
|
|
||||||
func get_camera_rotation():
|
|
||||||
return self.rotation
|
|
||||||
|
|
||||||
|
|
||||||
func set_camera_panning(value:bool) -> void:
|
|
||||||
self.is_panning_camera = value
|
|
||||||
|
|
||||||
|
|
||||||
func set_camera_position(pos: Vector2) -> void:
|
|
||||||
self.position = pos
|
|
||||||
|
|
||||||
|
|
||||||
func clamp_camera_position() -> void:
|
|
||||||
self.position.x = clamp(
|
self.position.x = clamp(
|
||||||
self.position.x,
|
self.position.x,
|
||||||
x_min_limit,
|
x_min_limit,
|
||||||
|
@ -84,16 +81,16 @@ func clamp_camera_position() -> void:
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
func camera_pan_position(value) -> void:
|
func camera_pan_position(value) -> void:
|
||||||
self.position -= value
|
self.position -= value
|
||||||
|
|
||||||
|
|
||||||
func camera_zoom_in() -> void:
|
func camera_zoom_in() -> void:
|
||||||
_set_camera_zoom_level(Globals.CAMERA_ZOOM_LEVEL - Globals.CAMERA_ZOOM_FACTOR)
|
set_camera_zoom_level(Globals.CAMERA_ZOOM_LEVEL - Globals.CAMERA_ZOOM_FACTOR)
|
||||||
|
|
||||||
|
|
||||||
func camera_zoom_out() -> void:
|
func camera_zoom_out() -> void:
|
||||||
_set_camera_zoom_level(Globals.CAMERA_ZOOM_LEVEL + Globals.CAMERA_ZOOM_DURATION)
|
set_camera_zoom_level(Globals.CAMERA_ZOOM_LEVEL + Globals.CAMERA_ZOOM_DURATION)
|
||||||
|
|
||||||
|
|
||||||
func camera_reset_rotation() -> void:
|
func camera_reset_rotation() -> void:
|
|
@ -25,10 +25,10 @@ func _on_camera_zoom_2d_camera_zoom_changed(new_zoom_factor):
|
||||||
|
|
||||||
# Sets the initial size of the camera box, after game is loaded
|
# Sets the initial size of the camera box, after game is loaded
|
||||||
func set_camera_marker() -> void:
|
func set_camera_marker() -> void:
|
||||||
print("setting marker rdy")
|
|
||||||
size_multiplier = Globals.map_size / 32
|
size_multiplier = Globals.map_size / 32
|
||||||
w_s = DisplayServer.window_get_size(0) / size_multiplier
|
w_s = DisplayServer.window_get_size(0) / size_multiplier
|
||||||
|
|
||||||
|
|
||||||
func set_camera_marker_position(pos:Vector2) -> void:
|
func set_camera_marker_position(pos:Vector2) -> void:
|
||||||
print("marker pos: ", pos)
|
#print("marker pos: ", pos)
|
||||||
|
self.position = pos
|
||||||
|
|
|
@ -26,12 +26,14 @@ var exit_thread:bool = false
|
||||||
|
|
||||||
|
|
||||||
func _exit_tree():
|
func _exit_tree():
|
||||||
|
if !thread:
|
||||||
|
return
|
||||||
mutex.lock()
|
mutex.lock()
|
||||||
exit_thread = true
|
exit_thread = true
|
||||||
mutex.unlock()
|
mutex.unlock()
|
||||||
|
|
||||||
semaphore.post()
|
semaphore.post()
|
||||||
thread.wait_to_finish()
|
thread.wait_to_finish()
|
||||||
|
|
||||||
|
|
||||||
func _init() -> void:
|
func _init() -> void:
|
||||||
|
|
|
@ -34,9 +34,8 @@ func _ready():
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
#func _process(_delta):
|
func _process(_delta):
|
||||||
# if update_debug_info:
|
update_debug_info_func()
|
||||||
# update_debug_info_func()
|
|
||||||
|
|
||||||
|
|
||||||
# sends signals which View catches and places selected type of buildings
|
# sends signals which View catches and places selected type of buildings
|
||||||
|
@ -91,13 +90,18 @@ func create_buttons():
|
||||||
|
|
||||||
func update_debug_info_func():
|
func update_debug_info_func():
|
||||||
debug_info.set_text(
|
debug_info.set_text(
|
||||||
str(get_viewport().get_mouse_position()) +"\n" +
|
"Camera pos: " + str(Globals.CAMERA_POSITION) + "\n" +
|
||||||
"FPS " + str(Engine.get_frames_per_second()) + "\n" +
|
|
||||||
"Zoom lvl: " + str(Globals.CAMERA_ZOOM_LEVEL) + "\n" +
|
|
||||||
"Camera pos: " + str(Globals.CAMERA_POSITION) + "\n" +
|
|
||||||
"Camera pos: " + str(Globals.camera_marker.position) + "\n" +
|
|
||||||
"Chunks: " + str(self.amount_of_chunks) + "\n" +
|
"Chunks: " + str(self.amount_of_chunks) + "\n" +
|
||||||
"Chunk del: " + str(self.size_of_chunk_removal_queue),
|
"Chunk del: " + str(self.size_of_chunk_removal_queue)
|
||||||
)
|
)
|
||||||
|
# debug_info.set_text(
|
||||||
|
# #str(get_viewport().get_mouse_position()) +"\n" +
|
||||||
|
# "FPS " + str(Engine.get_frames_per_second()) + "\n" +
|
||||||
|
# "Zoom lvl: " + str(Globals.CAMERA_ZOOM_LEVEL) + "\n" +
|
||||||
|
# "Camera pos: " + str(Globals.CAMERA_POSITION) + "\n" +
|
||||||
|
# "Camera pos: " + str(Globals.camera_marker.position) + "\n" +
|
||||||
|
# "Chunks: " + str(self.amount_of_chunks) + "\n" +
|
||||||
|
# "Chunk del: " + str(self.size_of_chunk_removal_queue),
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
class_name EventBus
|
class_name EventBus
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
@onready var node_main = get_parent()
|
@onready var node_main:Main
|
||||||
@onready var node_mainmenu = find_child("MainMenu")
|
@onready var node_mainmenu:MainMenu
|
||||||
@onready var node_game = find_child("Game")
|
@onready var node_game:Game
|
||||||
|
@onready var node_camera:Camera
|
||||||
|
@onready var node_uilayer:UILayer
|
||||||
|
|
||||||
|
|
||||||
# The idea is for the user to be able to choose the map from GUI later
|
# The idea is for the user to be able to choose the map from GUI later
|
||||||
|
@ -20,18 +22,28 @@ var _world_generator:WorldGenerator
|
||||||
|
|
||||||
func _process(_delta) -> void:
|
func _process(_delta) -> void:
|
||||||
while Input.is_action_pressed("camera_rotate_left_stepless"):
|
while Input.is_action_pressed("camera_rotate_left_stepless"):
|
||||||
node_game.camera_rotate(-0.1)
|
node_camera.camera_rotate(-0.1)
|
||||||
await get_tree().create_timer(0.2).timeout
|
await get_tree().create_timer(0.2).timeout
|
||||||
while Input.is_action_pressed("camera_rotate_right_stepless"):
|
while Input.is_action_pressed("camera_rotate_right_stepless"):
|
||||||
node_game.camera_rotate(0.1)
|
node_camera.camera_rotate(0.1)
|
||||||
await get_tree().create_timer(0.2).timeout
|
await get_tree().create_timer(0.2).timeout
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
node_main = get_parent()
|
||||||
|
node_mainmenu = find_child("MainMenu")
|
||||||
|
node_game = find_child("Game")
|
||||||
|
node_camera = find_child("Camera")
|
||||||
|
node_uilayer = find_child("UILayer")
|
||||||
|
|
||||||
|
|
||||||
|
func set_ready():
|
||||||
node_mainmenu.set_ready()
|
node_mainmenu.set_ready()
|
||||||
|
|
||||||
|
|
||||||
func _unhandled_input(event) -> void:
|
func _unhandled_input(event) -> void:
|
||||||
|
if !node_camera:
|
||||||
|
return
|
||||||
###################################
|
###################################
|
||||||
# MAIN MENU #
|
# MAIN MENU #
|
||||||
###################################
|
###################################
|
||||||
|
@ -41,61 +53,57 @@ func _unhandled_input(event) -> void:
|
||||||
var mainmenu_pos = Globals.CAMERA_POSITION
|
var mainmenu_pos = Globals.CAMERA_POSITION
|
||||||
mainmenu_pos.x -= DisplayServer.window_get_size(0).x/2
|
mainmenu_pos.x -= DisplayServer.window_get_size(0).x/2
|
||||||
mainmenu_pos.y -= DisplayServer.window_get_size(0).y/2
|
mainmenu_pos.y -= DisplayServer.window_get_size(0).y/2
|
||||||
self.find_child("MainMenu").position = mainmenu_pos
|
node_mainmenu.set_position(mainmenu_pos, false)
|
||||||
|
|
||||||
# show the menu
|
# show the menu
|
||||||
toggle_main_menu_visibility()
|
node_mainmenu.set_visible(true)
|
||||||
#await get_tree().create_timer(0.2).timeout
|
node_game.set_visible(false)
|
||||||
self.find_child("Game").process_mode = PROCESS_MODE_DISABLED
|
node_uilayer.set_visible(false)
|
||||||
|
node_main.pause_game()
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
# GAME CAMERA #
|
# GAME CAMERA #
|
||||||
###################################
|
###################################
|
||||||
|
|
||||||
if event.is_action_pressed("camera_zoom_in"):
|
if event.is_action_pressed("camera_zoom_in"):
|
||||||
node_game.camera_zoom_in()
|
node_camera.camera_zoom_in()
|
||||||
if event.is_action_pressed("camera_zoom_out"):
|
if event.is_action_pressed("camera_zoom_out"):
|
||||||
node_game.camera_zoom_out()
|
node_camera.camera_zoom_out()
|
||||||
|
|
||||||
if event.is_action_pressed("camera_rotate_left_fixed_step"):
|
if event.is_action_pressed("camera_rotate_left_fixed_step"):
|
||||||
node_game.camera_rotate(-45)
|
node_camera.camera_rotate(-45)
|
||||||
if event.is_action_pressed("camera_rotate_right_fixed_step"):
|
if event.is_action_pressed("camera_rotate_right_fixed_step"):
|
||||||
node_game.camera_rotate(45)
|
node_camera.camera_rotate(45)
|
||||||
if event.is_action_pressed("camera_reset_rotation"):
|
if event.is_action_pressed("camera_reset_rotation"):
|
||||||
node_game.camera_reset_rotation()
|
node_camera.camera_reset_rotation()
|
||||||
|
|
||||||
if event.is_action_pressed("take_screenshot"):
|
if event.is_action_pressed("take_screenshot"):
|
||||||
node_game.take_screenshot()
|
node_camera.take_screenshot()
|
||||||
|
|
||||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
|
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
|
||||||
if !node_game.camera_get_panning() and event.pressed:
|
if !node_camera.get_camera_panning() and event.pressed:
|
||||||
node_game.camera_set_panning(true)
|
node_camera.set_camera_panning(true)
|
||||||
if node_game.camera_get_panning() and !event.pressed:
|
if node_camera.get_camera_panning() and !event.pressed:
|
||||||
node_game.camera_set_panning(false)
|
node_camera.set_camera_panning(false)
|
||||||
|
|
||||||
if event is InputEventMouseMotion and node_game.camera_get_panning():
|
if event is InputEventMouseMotion and node_camera.get_camera_panning():
|
||||||
# rotate event.relative vector with camera rotation so camera moves to "correct" direction
|
# rotate event.relative vector with camera rotation so camera moves to "correct" direction
|
||||||
node_game.camera_pan_position(event.relative.rotated(node_game.camera_get_rotation()) * Globals.CAMERA_PAN_MULTI)
|
node_camera.camera_pan_position(event.relative.rotated(node_camera.get_camera_rotation()) * Globals.CAMERA_PAN_MULTI)
|
||||||
|
|
||||||
# prevent camera from going overboard
|
# prevent camera from going overboard
|
||||||
node_game.camera_clamp_position()
|
node_camera.clamp_camera_position()
|
||||||
|
|
||||||
|
|
||||||
func _on_mainmenu_button_pressed(button:int):
|
func _on_mainmenu_button_pressed(button:int):
|
||||||
match button:
|
match button:
|
||||||
Globals.MAINMENU_NEW_GAME:
|
Globals.MAINMENU_NEW_GAME:
|
||||||
start_new_game()
|
start_new_game()
|
||||||
node_mainmenu.find_child("Menu_NewGame").disabled = true
|
|
||||||
node_mainmenu.find_child("Menu_ResumeGame").disabled = false
|
|
||||||
toggle_main_menu_visibility()
|
|
||||||
|
|
||||||
Globals.MAINMENU_LOAD_GAME:
|
Globals.MAINMENU_LOAD_GAME:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
Globals.MAINMENU_RESUME_GAME:
|
Globals.MAINMENU_RESUME_GAME:
|
||||||
# TODO save camera position before opening menu, restore camera position when closing menu
|
resume_game()
|
||||||
node_game.process_mode = PROCESS_MODE_INHERIT
|
|
||||||
toggle_main_menu_visibility()
|
|
||||||
|
|
||||||
Globals.MAINMENU_OPTIONS:
|
Globals.MAINMENU_OPTIONS:
|
||||||
pass
|
pass
|
||||||
|
@ -104,11 +112,23 @@ func _on_mainmenu_button_pressed(button:int):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
Globals.MAINMENU_QUIT_GAME:
|
Globals.MAINMENU_QUIT_GAME:
|
||||||
node_mainmenu.quit_game()
|
node_main.quit_game()
|
||||||
|
|
||||||
_:
|
_:
|
||||||
push_error("Error: Main: unknown signal at _on_mainmenu_button_pressed: ", button)
|
push_error("Error: Main: unknown signal at _on_mainmenu_button_pressed: ", button)
|
||||||
|
|
||||||
|
|
||||||
|
func resume_game() -> void:
|
||||||
|
# TODO save camera position before opening menu, restore camera position when closing menu
|
||||||
|
node_main.unpause_game()
|
||||||
|
node_mainmenu.set_visible(false)
|
||||||
|
node_game.set_visible(true)
|
||||||
|
node_uilayer.set_visible(true)
|
||||||
|
|
||||||
|
|
||||||
|
func set_camera_position(pos:Vector2):
|
||||||
|
node_camera.set_camera_position(pos)
|
||||||
|
|
||||||
|
|
||||||
func start_new_game():
|
func start_new_game():
|
||||||
# create a new world with worldgenerator
|
# create a new world with worldgenerator
|
||||||
|
@ -116,25 +136,32 @@ func start_new_game():
|
||||||
if !_world_generator.generate_world(map_filename):
|
if !_world_generator.generate_world(map_filename):
|
||||||
push_error("World generation failed :-(")
|
push_error("World generation failed :-(")
|
||||||
node_main.quit_game()
|
node_main.quit_game()
|
||||||
|
|
||||||
|
# after generating the world we know what limits we should set to camera
|
||||||
|
node_camera.set_camera_limits()
|
||||||
|
|
||||||
|
node_mainmenu.find_child("Menu_NewGame").disabled = true
|
||||||
|
node_mainmenu.find_child("Menu_ResumeGame").disabled = false
|
||||||
|
|
||||||
|
# unpause game and setup it
|
||||||
node_main.unpause_game()
|
node_main.unpause_game()
|
||||||
node_game.set_ready()
|
node_game.set_ready()
|
||||||
self.set_camera_position(
|
node_uilayer.set_ready()
|
||||||
|
|
||||||
|
# hide menu, display game & ui
|
||||||
|
node_mainmenu.set_visible(false)
|
||||||
|
node_game.set_visible(true)
|
||||||
|
node_uilayer.set_visible(true)
|
||||||
|
|
||||||
|
# set camera to center of the map
|
||||||
|
node_camera.camera_reset_rotation()
|
||||||
|
node_camera.set_camera_position(
|
||||||
Vector2(Globals.map_size / 2.0 * Globals.TILE_SIZE_X,
|
Vector2(Globals.map_size / 2.0 * Globals.TILE_SIZE_X,
|
||||||
Globals.map_size / 2.0 * Globals.TILE_SIZE_Y)
|
Globals.map_size / 2.0 * Globals.TILE_SIZE_Y)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func toggle_main_menu_visibility():
|
|
||||||
node_game.toggle_visibility()
|
|
||||||
|
|
||||||
if node_mainmenu.visible:
|
|
||||||
node_mainmenu.hide()
|
|
||||||
else:
|
|
||||||
node_mainmenu.show()
|
|
||||||
|
|
||||||
func set_camera_position(pos:Vector2):
|
|
||||||
node_game.camera_set_position(pos)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,13 @@
|
||||||
class_name Game
|
class_name Game
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
@onready var node_camera:CameraZoom2D
|
|
||||||
@onready var node_chunkhandler:ChunkHandler
|
@onready var node_chunkhandler:ChunkHandler
|
||||||
@onready var node_minimap:Minimap
|
|
||||||
@onready var node_mapbackground:MapBackground
|
@onready var node_mapbackground:MapBackground
|
||||||
@onready var node_uilayer
|
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
node_camera = find_child("CameraZoom2D")
|
|
||||||
node_chunkhandler = find_child("ChunkHandler")
|
node_chunkhandler = find_child("ChunkHandler")
|
||||||
node_minimap = find_child("Minimap")
|
|
||||||
node_mapbackground = find_child("MapBackground")
|
node_mapbackground = find_child("MapBackground")
|
||||||
node_uilayer = find_child("UILayer")
|
|
||||||
|
|
||||||
|
|
||||||
# sets the minimap texture as map background to avoid jarring transitions
|
# sets the minimap texture as map background to avoid jarring transitions
|
||||||
|
@ -22,66 +16,8 @@ func _on_minimap_set_map_background_texture(sprite, scaling:Vector2) -> void:
|
||||||
|
|
||||||
|
|
||||||
func set_ready() -> void:
|
func set_ready() -> void:
|
||||||
node_camera.set_ready()
|
|
||||||
node_chunkhandler.set_ready()
|
node_chunkhandler.set_ready()
|
||||||
node_minimap.set_ready()
|
|
||||||
|
|
||||||
|
|
||||||
func set_map_background_texture(sprite, scaling:Vector2) -> void:
|
func set_map_background_texture(sprite, scaling:Vector2) -> void:
|
||||||
node_mapbackground.set_map_background_texture(sprite, scaling)
|
node_mapbackground.set_map_background_texture(sprite, scaling)
|
||||||
|
|
||||||
|
|
||||||
func camera_clamp_position() -> void:
|
|
||||||
node_camera.clamp_camera_position()
|
|
||||||
|
|
||||||
|
|
||||||
func camera_pan_position(value):
|
|
||||||
node_camera.camera_pan_position(value)
|
|
||||||
|
|
||||||
|
|
||||||
func camera_zoom_out() -> void:
|
|
||||||
node_camera.camera_zoom_out()
|
|
||||||
|
|
||||||
|
|
||||||
func camera_zoom_in() -> void:
|
|
||||||
node_camera.camera_zoom_in()
|
|
||||||
|
|
||||||
|
|
||||||
func camera_rotate(value) -> void:
|
|
||||||
node_camera.camera_rotate(value)
|
|
||||||
|
|
||||||
|
|
||||||
func camera_reset_rotation() -> void:
|
|
||||||
node_camera.camera_reset_rotation()
|
|
||||||
|
|
||||||
|
|
||||||
func camera_get_panning() -> bool:
|
|
||||||
return node_camera.get_camera_panning()
|
|
||||||
|
|
||||||
|
|
||||||
func camera_get_rotation():
|
|
||||||
return node_camera.get_camera_rotation()
|
|
||||||
|
|
||||||
|
|
||||||
func camera_set_panning(value:bool) -> void:
|
|
||||||
node_camera.set_camera_panning(value)
|
|
||||||
|
|
||||||
|
|
||||||
func camera_set_position(pos:Vector2) -> void:
|
|
||||||
node_camera.set_camera_position(pos)
|
|
||||||
|
|
||||||
|
|
||||||
func camera_take_screenshot() -> void:
|
|
||||||
node_camera.camera_take_screenshot()
|
|
||||||
|
|
||||||
|
|
||||||
func toggle_visibility() -> void:
|
|
||||||
if self.visible:
|
|
||||||
self.hide()
|
|
||||||
else:
|
|
||||||
self.show()
|
|
||||||
|
|
||||||
if node_uilayer.visible:
|
|
||||||
node_uilayer.hide()
|
|
||||||
else:
|
|
||||||
node_uilayer.show()
|
|
||||||
|
|
|
@ -1,24 +1,15 @@
|
||||||
# https://github.com/dfloer/SC2k-docs
|
# https://github.com/dfloer/SC2k-docs
|
||||||
|
|
||||||
class_name Main
|
class_name Main
|
||||||
extends Node2D
|
extends Node
|
||||||
|
|
||||||
|
|
||||||
var bus:EventBus
|
var bus:EventBus
|
||||||
|
|
||||||
|
|
||||||
func _init() -> void:
|
|
||||||
# DisplayServer.window_set_size(
|
|
||||||
# #Vector2i(Globals.DEFAULT_X_RES, Globals.DEFAULT_Y_RES)
|
|
||||||
# Vector2i(3800,2000)
|
|
||||||
# )
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
pause_game()
|
pause_game()
|
||||||
bus = find_child("EventBus")
|
bus = find_child("EventBus")
|
||||||
bus.set_camera_position(Vector2(16*256/2, 16*256/2))
|
bus.set_ready()
|
||||||
|
|
||||||
|
|
||||||
func pause_game() -> void:
|
func pause_game() -> void:
|
||||||
|
|
|
@ -5,9 +5,14 @@ signal button_pressed(button_name)
|
||||||
|
|
||||||
# Connect main menu to Main game
|
# Connect main menu to Main game
|
||||||
|
|
||||||
|
#func _process(delta):
|
||||||
|
# print("aaa")
|
||||||
|
|
||||||
|
|
||||||
func set_ready():
|
func set_ready():
|
||||||
self.connect("button_pressed", self.get_parent()._on_mainmenu_button_pressed, CONNECT_PERSIST)
|
self.connect("button_pressed", self.get_parent()._on_mainmenu_button_pressed, CONNECT_PERSIST)
|
||||||
self.find_child("Menu_ResumeGame").disabled = true
|
self.find_child("Menu_ResumeGame").disabled = true
|
||||||
|
|
||||||
|
|
||||||
func _on_menu_new_game_pressed():
|
func _on_menu_new_game_pressed():
|
||||||
emit_signal("button_pressed", Globals.MAINMENU_NEW_GAME)
|
emit_signal("button_pressed", Globals.MAINMENU_NEW_GAME)
|
||||||
|
@ -31,4 +36,5 @@ func _on_menu_credits_pressed():
|
||||||
|
|
||||||
func _on_menu_exit_game_pressed():
|
func _on_menu_exit_game_pressed():
|
||||||
emit_signal("button_pressed", Globals.MAINMENU_QUIT_GAME)
|
emit_signal("button_pressed", Globals.MAINMENU_QUIT_GAME)
|
||||||
|
|
||||||
|
|
||||||
|
|
12
scripts/Simulation.gd
Normal file
12
scripts/Simulation.gd
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
class_name Simulation
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(_delta):
|
||||||
|
pass
|
10
scripts/UILayer.gd
Normal file
10
scripts/UILayer.gd
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
class_name UILayer
|
||||||
|
extends CanvasLayer
|
||||||
|
|
||||||
|
@onready var node_minimap:Minimap
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
node_minimap = find_child("Minimap")
|
||||||
|
|
||||||
|
func set_ready() -> void:
|
||||||
|
node_minimap.set_ready()
|
|
@ -96,7 +96,8 @@ func generate_biomes() -> void:
|
||||||
|
|
||||||
func generate_parcels() -> void:
|
func generate_parcels() -> void:
|
||||||
# divide the land area Cadastres / Parcels
|
# divide the land area Cadastres / Parcels
|
||||||
print("generating parcels")
|
#print("generating parcels")
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
func generate_world(filename) -> bool:
|
func generate_world(filename) -> bool:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue