mirror of
https://github.com/tonytins/citylimits
synced 2025-12-17 05:34:42 -05:00
Created first zone type
- Renamed CityData to SimData and added SimEvents for signals = Set starting screen to game screen for now
This commit is contained in:
parent
9d565de091
commit
71bdc3d971
7 changed files with 119 additions and 8 deletions
46
scripts/Zone.gd
Normal file
46
scripts/Zone.gd
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
export var cost: int = 10000
|
||||
export var income: int
|
||||
export var expense: int
|
||||
|
||||
onready var zone = $Sprite
|
||||
onready var quarters = $Quarters
|
||||
onready var player = $AnimationPlayer
|
||||
|
||||
var can_grab = false
|
||||
var grabbed_offset = Vector2()
|
||||
|
||||
func _ready():
|
||||
SimEvents.connect("pay_expense", self, "_get_expense")
|
||||
|
||||
# Once placed in-world, it'll substract from your budget
|
||||
if SimData.budget >= cost:
|
||||
SimData.budget -= cost
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventMouseButton:
|
||||
can_grab = event.pressed
|
||||
grabbed_offset = position - get_global_mouse_position()
|
||||
|
||||
func _process(delta):
|
||||
|
||||
player.play("Animante")
|
||||
|
||||
if SimData.budget >= expense:
|
||||
SimData.budget -= expense
|
||||
|
||||
if SimData.budget >= income:
|
||||
SimData.budget += income
|
||||
|
||||
if Input.is_mouse_button_pressed(BUTTON_LEFT) and can_grab:
|
||||
position = get_global_mouse_position() + grabbed_offset
|
||||
|
||||
func _on_Quarters_timeout():
|
||||
if SimData.prev_quarter == 4:
|
||||
SimData.year += 1
|
||||
SimData.emit_signal("one_time_zone")
|
||||
SimData.emit_signal("pay_expense")
|
||||
|
||||
SimData.prev_quarter = SimData.quarter
|
||||
quarters.start()
|
||||
Loading…
Add table
Add a link
Reference in a new issue