Room prices are no longer hardcoded

Office node now uses a generic room script with exported variables that control the price, income, ect...
This commit is contained in:
Anthony Foxclaw 2020-04-12 17:33:56 -04:00
parent 8586220975
commit dff1abaf49
3 changed files with 39 additions and 27 deletions

View file

@ -1,26 +0,0 @@
extends Node2D
const OFFICE_PRICE = 1000
const OFFICE_INCOME = 500
const MAINTANCE_COST = 350
export var is_vacant: bool = true
func _ready():
# Once placed in-world, it'll substract from your budget
if TowerData.budget >= OFFICE_PRICE:
TowerData.budget = -OFFICE_PRICE
func _process(delta):
# If the office is no longer vacant, start rent timer
if is_vacant == false:
$Rent.start()
else:
$Rent.stop()
func _on_Rent_timeout():
# On timeout, pay the player and restart timer
TowerData.budget = OFFICE_INCOME
$Rent.start()

33
project/src/room.gd Normal file
View file

@ -0,0 +1,33 @@
extends Node2D
export var room_cost: int
export var room_income: int
export var room_expense: int
export var room_capacity: int
export var is_rentable: bool
var is_vacant: bool
var num_of_tenants: int
var is_full: bool
func _ready():
# Once placed in-world, it'll substract from your budget
if TowerData.budget >= room_cost:
TowerData.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()
func _on_Rent_timeout():
# On timeout, pay the player and restart timer
if room_income != 0:
TowerData.budget = room_income
$Rent.start()