Budget script

New bank script that serves for handling the budget, taxes, and starting funds.
This commit is contained in:
Anthony Wilcox 2019-11-29 14:24:25 -05:00
parent 2c1a66e501
commit cabd5d8817
5 changed files with 92 additions and 5 deletions

37
src/gui.tscn Normal file
View file

@ -0,0 +1,37 @@
[gd_scene format=2]
[node name="GUI" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
[node name="GPanel" type="Panel" parent="."]
anchor_right = 1.0
margin_bottom = 23.0
[node name="HBox" type="HBoxContainer" parent="GPanel"]
anchor_right = 1.0
margin_top = 2.0
margin_bottom = 22.0
alignment = 2
[node name="CurrencyLbl" type="Label" parent="GPanel/HBox"]
margin_left = 1003.0
margin_top = 3.0
margin_right = 1011.0
margin_bottom = 17.0
text = "$"
[node name="MoneyLbl" type="Label" parent="GPanel/HBox"]
margin_left = 1015.0
margin_top = 3.0
margin_right = 1024.0
margin_bottom = 17.0
text = "#"
[node name="DebugBtn" type="Button" parent="GPanel"]
visible = false
margin_left = 932.754
margin_top = 563.202
margin_right = 985.754
margin_bottom = 583.202
text = "Debug"

View file

@ -19,11 +19,25 @@ config/name="City Limits"
run/main_scene="res://world.tscn"
config/icon="res://icon.png"
[autoload]
bank="*res://scripts/bank.gd"
[display]
window/stretch/mode="2d"
window/stretch/aspect="keep"
[input]
ui_cheats={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777238,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777237,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":67,"unicode":0,"echo":false,"script":null)
]
}
[rendering]
environment/default_environment="res://default_env.tres"

23
src/scripts/bank.gd Normal file
View file

@ -0,0 +1,23 @@
extends Node
var budget: int
var prev_budget: int
var res_tax: int
var comm_tax: int
var indust_tax: int
var fire_tax: int
var police_tax: int
var power_tax: int
func starting_budget(lev: int):
if lev == 1:
budget = 20000
elif lev == 2:
budget = 10000
elif lev == 3:
budget = 5000
else:
budget = NAN

View file

@ -1,10 +1,20 @@
extends Node2D
extends Node
var noise : OpenSimplexNoise
var noise: OpenSimplexNoise
var map_size = Vector2(80, 60)
var terrian_cap = 0.3
func _process(delta):
$GUI/GPanel/HBox/MoneyLbl.text = str(bank.budget)
func _input(event):
pass
func _ready():
bank.starting_budget(1)
randomize()
noise = OpenSimplexNoise.new()
noise.seed = randi()

View file

@ -1,10 +1,11 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=5 format=2]
[ext_resource path="res://world.gd" type="Script" id=1]
[ext_resource path="res://scripts/world.gd" type="Script" id=1]
[ext_resource path="res://graphics/water.tres" type="TileSet" id=2]
[ext_resource path="res://graphics/terrian.tres" type="TileSet" id=3]
[ext_resource path="res://gui.tscn" type="PackedScene" id=4]
[node name="Node2D" type="Node2D"]
[node name="Node2D" type="Node"]
script = ExtResource( 1 )
[node name="Water" type="TileMap" parent="."]
@ -16,3 +17,5 @@ format = 1
tile_set = ExtResource( 3 )
cell_size = Vector2( 16, 16 )
format = 1
[node name="GUI" parent="." instance=ExtResource( 4 )]