diff --git a/project/project.godot b/project/project.godot index aa97ce9..7215fef 100644 --- a/project/project.godot +++ b/project/project.godot @@ -17,7 +17,7 @@ _global_script_class_icons={ config/name="Skyscraper Rising" run/main_scene="res://src/world.tscn" -config/icon="res://icon.png" +config/icon="res://start.png" [autoload] diff --git a/project/src/autoload/gamedata.gd b/project/src/autoload/gamedata.gd index 6c42437..4b49df1 100644 --- a/project/src/autoload/gamedata.gd +++ b/project/src/autoload/gamedata.gd @@ -7,3 +7,5 @@ var prev_quarter: int var quarter: int = 1 var population: int = 0 enum GameSpeed { SLOW, MEDIUM, FAST } + +signal quarter_income diff --git a/project/src/room.gd b/project/src/room.gd index eea4d1d..14ad70f 100644 --- a/project/src/room.gd +++ b/project/src/room.gd @@ -1,47 +1,33 @@ extends Node2D -enum IncomeFrequency { ONE_TIME, QUARTERLY, DAILY } +enum IncomeFrequency { ONE_TIME, QUARTERLY } export var room_cost: int = 10000 export var room_income: int export var room_expense: int export var room_capacity: int export var is_rentable: bool -export(IncomeFrequency) var income_frequency = IncomeFrequency.DAILY +export(IncomeFrequency) var income_frequency = IncomeFrequency.QUARTERLY -var rent: Timer var is_vacant: bool var num_of_tenants: int var is_full: bool func _ready(): - match income_frequency: - # TODO: how long should a day be? - IncomeFrequency.DAILY: - rent.wait_time = 1 - IncomeFrequency.QUARTERLY: - rent.wait_time = 5 + GameData.connect("quarter_income", self, "_get_quarter_income") # Once placed in-world, it'll substract from your budget if GameData.budget >= room_cost: - GameData.budget = -room_cost + GameData.budget -= room_cost func _process(delta): - + # If the office is no longer vacant, start rent timer if is_rentable == true: if num_of_tenants >= room_capacity: is_vacant = false num_of_tenants += 1 - rent.start() - else: - rent.stop() - - match income_frequency: - IncomeFrequency.DAILY: - # On timeout, pay the player and restart timer - GameData.budget = room_income - rent.start() - IncomeFrequency.ONE_TIME: - GameData.budget = room_income + +func _get_quarter_income(): + GameData.budget += room_income diff --git a/project/src/world.gd b/project/src/world.gd index b3becf0..4a0c45f 100644 --- a/project/src/world.gd +++ b/project/src/world.gd @@ -6,6 +6,7 @@ func _on_Quarters_timeout(): GameData.quarter = 1 GameData.year += 1 else: + GameData.emit_signal("quarter_income") GameData.quarter += 1 GameData.prev_quarter = GameData.quarter diff --git a/project/src/world.tscn b/project/src/world.tscn index b9a8d49..729429b 100644 --- a/project/src/world.tscn +++ b/project/src/world.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://src/world.gd" type="Script" id=1] [ext_resource path="res://src/gui.tscn" type="PackedScene" id=2] +[ext_resource path="res://assets/office.tscn" type="PackedScene" id=3] [node name="World" type="Node"] script = ExtResource( 1 ) @@ -9,6 +10,12 @@ script = ExtResource( 1 ) [node name="GUI" parent="." instance=ExtResource( 2 )] [node name="Quarters" type="Timer" parent="."] -wait_time = 5.0 +wait_time = 10.0 autostart = true + +[node name="Office" parent="." instance=ExtResource( 3 )] +position = Vector2( 427.577, 274.653 ) +income_frequency = 1 + +[node name="Sprite" type="Sprite" parent="."] [connection signal="timeout" from="Quarters" to="." method="_on_Quarters_timeout"] diff --git a/project/assets/start.png b/project/start.png similarity index 100% rename from project/assets/start.png rename to project/start.png diff --git a/project/start.png.import b/project/start.png.import new file mode 100644 index 0000000..3ff72ca --- /dev/null +++ b/project/start.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/start.png-e7f708061e705f5bb66856e98cf5d362.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://start.png" +dest_files=[ "res://.import/start.png-e7f708061e705f5bb66856e98cf5d362.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=true +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=true +svg/scale=1.0