mirror of
https://github.com/tpawstdio/skyscraperrising.git
synced 2025-05-05 22:24:50 -04:00
Added income frequency
- Added years and quarters to the interface - Created timer that increments the number of quarters in a year until it reaches four. After four, the quarter resets and the year increments. - Renamed TowerData to GameData
This commit is contained in:
parent
dff1abaf49
commit
3308bddc6c
12 changed files with 104 additions and 63 deletions
|
@ -9,7 +9,3 @@ room_income = 500
|
||||||
room_expense = 350
|
room_expense = 350
|
||||||
room_capacity = 1
|
room_capacity = 1
|
||||||
is_rentable = true
|
is_rentable = true
|
||||||
|
|
||||||
[node name="Rent" type="Timer" parent="."]
|
|
||||||
wait_time = 5.0
|
|
||||||
[connection signal="timeout" from="Rent" to="." method="_on_Rent_timeout"]
|
|
||||||
|
|
|
@ -21,11 +21,11 @@ config/icon="res://icon.png"
|
||||||
|
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
TowerData="*res://src/autoload/twrdata.gd"
|
GameData="*res://src/autoload/gamedata.gd"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
window/stretch/mode="viewport"
|
window/stretch/mode="2d"
|
||||||
window/stretch/aspect="keep"
|
window/stretch/aspect="keep"
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
8
project/src/autoload/gamedata.gd
Normal file
8
project/src/autoload/gamedata.gd
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
var tower_name: String
|
||||||
|
var budget: int = 2000000
|
||||||
|
var year: int = 1
|
||||||
|
var prev_quarter: int
|
||||||
|
var quarter: int = 1
|
||||||
|
enum GameSpeed { SLOW, MEDIUM, FAST }
|
|
@ -1,16 +0,0 @@
|
||||||
extends Node
|
|
||||||
|
|
||||||
var tower_name: String
|
|
||||||
|
|
||||||
var budget: int
|
|
||||||
var prev_budget: int
|
|
||||||
|
|
||||||
func starting_budget(lev: int):
|
|
||||||
|
|
||||||
if lev == 3:
|
|
||||||
budget = 5000
|
|
||||||
elif lev == 2:
|
|
||||||
budget = 10000
|
|
||||||
# Default to easy mode
|
|
||||||
else:
|
|
||||||
budget = 20000
|
|
|
@ -1,7 +0,0 @@
|
||||||
extends Panel
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
$TwrMenus/TwrNameLbl.text = TowerData.tower_name
|
|
||||||
|
|
||||||
func _process(delta):
|
|
||||||
$TwrMenus/MoneyLbl.text = str(TowerData.budget)
|
|
|
@ -2,12 +2,16 @@ extends Control
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
$GPanel/GameStatus/MoneyLbl.text = str(GameData.budget)
|
||||||
|
$GPanel/GameStatus/YearNumLbl.text = str(GameData.year)
|
||||||
|
$GPanel/GameStatus/QuaterNumLbl.text = str(GameData.quarter)
|
||||||
|
$GPanel/GameMenus/NameLbl.text = GameData.tower_name
|
||||||
$WelcomeDlg.show()
|
$WelcomeDlg.show()
|
||||||
$GPanel/GameMenus/NameLbl.text = TowerData.tower_name
|
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
# $GPanel/GameStatus/MoneyLbl.text = str(TowerData.budget)
|
$GPanel/GameStatus/MoneyLbl.text = str(GameData.budget)
|
||||||
pass
|
$GPanel/GameStatus/YearNumLbl.text = str(GameData.year)
|
||||||
|
$GPanel/GameStatus/QuaterNumLbl.text = str(GameData.quarter)
|
||||||
|
|
||||||
func _on_WelcomeDlg_confirmed():
|
func _on_WelcomeDlg_confirmed():
|
||||||
$WelcomeDlg.hide()
|
$WelcomeDlg.hide()
|
||||||
|
|
|
@ -30,20 +30,20 @@ __meta__ = {
|
||||||
|
|
||||||
[node name="NameLbl" type="Label" parent="GPanel/GameMenus"]
|
[node name="NameLbl" type="Label" parent="GPanel/GameMenus"]
|
||||||
margin_top = 3.0
|
margin_top = 3.0
|
||||||
margin_right = 80.0
|
margin_right = 9.0
|
||||||
margin_bottom = 17.0
|
margin_bottom = 17.0
|
||||||
text = "Tower Name"
|
text = "#"
|
||||||
|
|
||||||
[node name="GameSpeed" type="MenuButton" parent="GPanel/GameMenus"]
|
[node name="GameSpeed" type="MenuButton" parent="GPanel/GameMenus"]
|
||||||
margin_left = 84.0
|
margin_left = 13.0
|
||||||
margin_right = 177.0
|
margin_right = 106.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
text = "Game Speed"
|
text = "Game Speed"
|
||||||
items = [ "Slow", null, 0, false, false, 0, 0, null, "", false, "Medium", null, 0, false, false, 1, 0, null, "", false, "Fast", null, 0, false, false, 2, 0, null, "", false ]
|
items = [ "Slow", null, 0, false, false, 0, 0, null, "", false, "Medium", null, 0, false, false, 1, 0, null, "", false, "Fast", null, 0, false, false, 2, 0, null, "", false ]
|
||||||
|
|
||||||
[node name="Disasters" type="MenuButton" parent="GPanel/GameMenus"]
|
[node name="Disasters" type="MenuButton" parent="GPanel/GameMenus"]
|
||||||
margin_left = 181.0
|
margin_left = 110.0
|
||||||
margin_right = 253.0
|
margin_right = 182.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
text = "Disasters"
|
text = "Disasters"
|
||||||
|
|
||||||
|
@ -61,6 +61,39 @@ __meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="YearLbl" type="Label" parent="GPanel/GameStatus"]
|
||||||
|
margin_left = 193.0
|
||||||
|
margin_top = 3.0
|
||||||
|
margin_right = 200.0
|
||||||
|
margin_bottom = 17.0
|
||||||
|
text = "Y"
|
||||||
|
|
||||||
|
[node name="YearNumLbl" type="Label" parent="GPanel/GameStatus"]
|
||||||
|
margin_left = 204.0
|
||||||
|
margin_top = 3.0
|
||||||
|
margin_right = 212.0
|
||||||
|
margin_bottom = 17.0
|
||||||
|
text = "1"
|
||||||
|
|
||||||
|
[node name="QuaterLbl" type="Label" parent="GPanel/GameStatus"]
|
||||||
|
margin_left = 216.0
|
||||||
|
margin_top = 3.0
|
||||||
|
margin_right = 227.0
|
||||||
|
margin_bottom = 17.0
|
||||||
|
text = "Q"
|
||||||
|
|
||||||
|
[node name="QuaterNumLbl" type="Label" parent="GPanel/GameStatus"]
|
||||||
|
margin_left = 231.0
|
||||||
|
margin_top = 3.0
|
||||||
|
margin_right = 239.0
|
||||||
|
margin_bottom = 17.0
|
||||||
|
text = "1"
|
||||||
|
|
||||||
|
[node name="VSeparator" type="VSeparator" parent="GPanel/GameStatus"]
|
||||||
|
margin_left = 243.0
|
||||||
|
margin_right = 247.0
|
||||||
|
margin_bottom = 20.0
|
||||||
|
|
||||||
[node name="CurrencyLbl" type="Label" parent="GPanel/GameStatus"]
|
[node name="CurrencyLbl" type="Label" parent="GPanel/GameStatus"]
|
||||||
margin_left = 251.0
|
margin_left = 251.0
|
||||||
margin_top = 3.0
|
margin_top = 3.0
|
||||||
|
@ -84,6 +117,7 @@ margin_bottom = 583.202
|
||||||
text = "Debug"
|
text = "Debug"
|
||||||
|
|
||||||
[node name="WelcomeDlg" type="AcceptDialog" parent="."]
|
[node name="WelcomeDlg" type="AcceptDialog" parent="."]
|
||||||
|
pause_mode = 2
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
anchor_top = 0.5
|
anchor_top = 0.5
|
||||||
anchor_right = 0.5
|
anchor_right = 0.5
|
||||||
|
|
|
@ -2,6 +2,6 @@ extends Control
|
||||||
|
|
||||||
func _on_CreateBtn_pressed():
|
func _on_CreateBtn_pressed():
|
||||||
var tower_name = $TwrNameEdit.text
|
var tower_name = $TwrNameEdit.text
|
||||||
TowerData.tower_name = tower_name
|
GameData.tower_name = tower_name
|
||||||
|
|
||||||
get_tree().change_scene("res://src/world.tscn")
|
get_tree().change_scene("res://src/world.tscn")
|
||||||
|
|
|
@ -1,19 +1,31 @@
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
export var room_cost: int
|
enum IncomeFrequency { ONE_TIME, QUARTERLY, DAILY }
|
||||||
|
|
||||||
|
export var room_cost: int = 10000
|
||||||
export var room_income: int
|
export var room_income: int
|
||||||
export var room_expense: int
|
export var room_expense: int
|
||||||
export var room_capacity: int
|
export var room_capacity: int
|
||||||
export var is_rentable: bool
|
export var is_rentable: bool
|
||||||
|
export(IncomeFrequency) var income_frequency = IncomeFrequency.DAILY
|
||||||
|
|
||||||
|
var rent: Timer
|
||||||
var is_vacant: bool
|
var is_vacant: bool
|
||||||
var num_of_tenants: int
|
var num_of_tenants: int
|
||||||
var is_full: bool
|
var is_full: bool
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
|
||||||
|
match income_frequency:
|
||||||
|
# TODO: how long should a day be?
|
||||||
|
IncomeFrequency.DAILY:
|
||||||
|
rent.wait_time = 1
|
||||||
|
IncomeFrequency.QUARTERLY:
|
||||||
|
rent.wait_time = 5
|
||||||
|
|
||||||
# Once placed in-world, it'll substract from your budget
|
# Once placed in-world, it'll substract from your budget
|
||||||
if TowerData.budget >= room_cost:
|
if GameData.budget >= room_cost:
|
||||||
TowerData.budget = -room_cost
|
GameData.budget = -room_cost
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
|
|
||||||
|
@ -22,12 +34,14 @@ func _process(delta):
|
||||||
if num_of_tenants >= room_capacity:
|
if num_of_tenants >= room_capacity:
|
||||||
is_vacant = false
|
is_vacant = false
|
||||||
num_of_tenants += 1
|
num_of_tenants += 1
|
||||||
$Rent.start()
|
rent.start()
|
||||||
else:
|
else:
|
||||||
$Rent.stop()
|
rent.stop()
|
||||||
|
|
||||||
func _on_Rent_timeout():
|
match income_frequency:
|
||||||
# On timeout, pay the player and restart timer
|
IncomeFrequency.DAILY:
|
||||||
if room_income != 0:
|
# On timeout, pay the player and restart timer
|
||||||
TowerData.budget = room_income
|
GameData.budget = room_income
|
||||||
$Rent.start()
|
rent.start()
|
||||||
|
IncomeFrequency.ONE_TIME:
|
||||||
|
GameData.budget = room_income
|
||||||
|
|
|
@ -29,22 +29,11 @@ __meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="BudgetMenu" type="MenuButton" parent="."]
|
|
||||||
margin_left = 339.0
|
|
||||||
margin_top = 294.0
|
|
||||||
margin_right = 628.0
|
|
||||||
margin_bottom = 314.0
|
|
||||||
text = "Starting Budget"
|
|
||||||
items = [ "20000", null, 0, false, false, 0, 0, null, "", false, "10000", null, 0, false, false, 1, 0, null, "", false, "500", null, 0, false, false, 2, 0, null, "", false ]
|
|
||||||
__meta__ = {
|
|
||||||
"_edit_use_anchors_": false
|
|
||||||
}
|
|
||||||
|
|
||||||
[node name="CreateBtn" type="Button" parent="."]
|
[node name="CreateBtn" type="Button" parent="."]
|
||||||
margin_left = 339.0
|
margin_left = 339.0
|
||||||
margin_top = 319.0
|
margin_top = 291.0
|
||||||
margin_right = 628.0
|
margin_right = 628.0
|
||||||
margin_bottom = 339.0
|
margin_bottom = 311.0
|
||||||
text = "Create"
|
text = "Create"
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
|
|
12
project/src/world.gd
Normal file
12
project/src/world.gd
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
func _on_Quarters_timeout():
|
||||||
|
|
||||||
|
if GameData.prev_quarter == 4:
|
||||||
|
GameData.quarter = 1
|
||||||
|
GameData.year += 1
|
||||||
|
else:
|
||||||
|
GameData.quarter += 1
|
||||||
|
|
||||||
|
GameData.prev_quarter = GameData.quarter
|
||||||
|
$Quarters.start()
|
|
@ -1,7 +1,14 @@
|
||||||
[gd_scene load_steps=2 format=2]
|
[gd_scene load_steps=3 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://src/gui.tscn" type="PackedScene" id=2]
|
||||||
|
|
||||||
[node name="World" type="Node"]
|
[node name="World" type="Node"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="GUI" parent="." instance=ExtResource( 2 )]
|
[node name="GUI" parent="." instance=ExtResource( 2 )]
|
||||||
|
|
||||||
|
[node name="Quarters" type="Timer" parent="."]
|
||||||
|
wait_time = 5.0
|
||||||
|
autostart = true
|
||||||
|
[connection signal="timeout" from="Quarters" to="." method="_on_Quarters_timeout"]
|
||||||
|
|
Loading…
Add table
Reference in a new issue