mirror of
https://github.com/tpawstdio/skyscraperrising.git
synced 2025-06-25 17:44:43 -04:00
One time income and pay expense signals
Test income and expense with varies variables.
This commit is contained in:
parent
63bde9f37f
commit
d13622dd1b
5 changed files with 40 additions and 19 deletions
|
@ -11,3 +11,5 @@ var news: String
|
|||
enum GameSpeed { SLOW, MEDIUM, FAST }
|
||||
|
||||
signal quarter_income
|
||||
signal one_time_income
|
||||
signal pay_expense
|
||||
|
|
|
@ -9,16 +9,20 @@ 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.QUARTERLY
|
||||
export(ChooseSprite) var choose_sprite = ChooseSprite.VERSION_1
|
||||
|
||||
var is_vacant: bool
|
||||
var num_of_tenants: int
|
||||
var is_full: bool
|
||||
var is_paid: bool = false
|
||||
var is_vacant: bool = true
|
||||
var is_full: bool = false
|
||||
var num_of_tenants: int = 0
|
||||
|
||||
func _ready():
|
||||
|
||||
GameData.connect("quarter_income", self, "_get_quarter_income")
|
||||
GameData.connect("one_time_income", self, "_get_one_time_income")
|
||||
GameData.connect("pay_expense", self, "_get_expense")
|
||||
|
||||
# Once placed in-world, it'll substract from your budget
|
||||
if GameData.budget >= room_cost:
|
||||
|
@ -26,17 +30,25 @@ func _ready():
|
|||
|
||||
func _process(delta):
|
||||
|
||||
match choose_sprite:
|
||||
ChooseSprite.VERSION_1:
|
||||
$AnimatedSprite.play("v1")
|
||||
ChooseSprite.VERSION_2:
|
||||
$AnimatedSprite.play("v2")
|
||||
|
||||
# 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
|
||||
|
||||
match choose_sprite:
|
||||
ChooseSprite.VERSION_1:
|
||||
$RoomAnime.play("v1")
|
||||
ChooseSprite.VERSION_2:
|
||||
$RoomAnime.play("v2")
|
||||
|
||||
func _get_expense():
|
||||
GameData.budget -= room_expense
|
||||
|
||||
func _get_one_time_income():
|
||||
if is_paid == false:
|
||||
GameData.budget += room_income
|
||||
is_paid = true
|
||||
|
||||
func _get_quarter_income():
|
||||
GameData.budget += room_income
|
||||
|
|
|
@ -5,6 +5,8 @@ func _on_Quarters_timeout():
|
|||
if GameData.prev_quarter == 4:
|
||||
GameData.quarter = 1
|
||||
GameData.year += 1
|
||||
GameData.emit_signal("one_time_income")
|
||||
GameData.emit_signal("pay_expense")
|
||||
else:
|
||||
GameData.emit_signal("quarter_income")
|
||||
GameData.quarter += 1
|
||||
|
|
|
@ -13,9 +13,17 @@ autostart = true
|
|||
|
||||
[node name="Office" parent="." instance=ExtResource( 3 )]
|
||||
position = Vector2( 481.153, 260.554 )
|
||||
room_income = 700
|
||||
room_expense = 200
|
||||
room_capacity = 1
|
||||
is_rentable = true
|
||||
|
||||
[node name="Office2" parent="." instance=ExtResource( 3 )]
|
||||
position = Vector2( 271.221, 296.175 )
|
||||
room_income = 600
|
||||
room_expense = 300
|
||||
room_capacity = 1
|
||||
is_rentable = true
|
||||
choose_sprite = 1
|
||||
|
||||
[node name="GUI" parent="." instance=ExtResource( 2 )]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue