mirror of
https://github.com/tpawstdio/skyscraperrising.git
synced 2025-05-05 14:14:50 -04:00
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:
parent
8586220975
commit
dff1abaf49
3 changed files with 39 additions and 27 deletions
|
@ -1,9 +1,14 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://src/office.gd" type="Script" id=1]
|
||||
[ext_resource path="res://src/room.gd" type="Script" id=1]
|
||||
|
||||
[node name="Office" type="Node2D"]
|
||||
script = ExtResource( 1 )
|
||||
room_cost = 1000
|
||||
room_income = 500
|
||||
room_expense = 350
|
||||
room_capacity = 1
|
||||
is_rentable = true
|
||||
|
||||
[node name="Rent" type="Timer" parent="."]
|
||||
wait_time = 5.0
|
||||
|
|
|
@ -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
33
project/src/room.gd
Normal 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()
|
Loading…
Add table
Reference in a new issue