mirror of
https://github.com/tonytins/citylimits.git
synced 2025-03-15 12:21:22 +00: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
|
@ -10,19 +10,20 @@ config_version=4
|
|||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_class_icons={
|
||||
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="City Limits"
|
||||
run/main_scene="res://scenes/titlescreen.tscn"
|
||||
run/main_scene="res://scenes/game.tscn"
|
||||
config/icon="res://icon.png"
|
||||
config/windows_native_icon="res://icon.ico"
|
||||
|
||||
[autoload]
|
||||
|
||||
CityData="*res://scripts/autoload/citydata.gd"
|
||||
CityData="*res://scripts/autoload/SimData.gd"
|
||||
SimData="*res://scripts/autoload/SimData.gd"
|
||||
SimEvents="*res://scripts/autoload/SimEvents.gd"
|
||||
|
||||
[display]
|
||||
|
||||
|
@ -30,6 +31,10 @@ window/size/resizable=false
|
|||
window/stretch/mode="2d"
|
||||
window/stretch/aspect="keep"
|
||||
|
||||
[editor_plugins]
|
||||
|
||||
enabled=PoolStringArray( )
|
||||
|
||||
[input]
|
||||
|
||||
ui_cheats={
|
||||
|
@ -43,5 +48,6 @@ ui_cheats={
|
|||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
quality/2d/use_pixel_snap=true
|
||||
2d/snapping/use_gpu_pixel_snap=true
|
||||
environment/default_environment="res://default_env.tres"
|
||||
quality/2d/use_pixel_snap=true
|
||||
|
|
44
scenes/Zone.tscn
Normal file
44
scenes/Zone.tscn
Normal file
|
@ -0,0 +1,44 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://scripts/Zone.gd" type="Script" id=1]
|
||||
[ext_resource path="res://sprites/res_zones.png" type="Texture" id=2]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 24.1295, 23.9406 )
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
resource_name = "Animante"
|
||||
length = 5.0
|
||||
step = 1.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 1, 2, 3, 4 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ 1, 2, 3, 4, 6 ]
|
||||
}
|
||||
|
||||
[node name="Zone" type="KinematicBody2D"]
|
||||
input_pickable = true
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Quarters" type="Timer" parent="."]
|
||||
wait_time = 10.0
|
||||
autostart = true
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 2 )
|
||||
vframes = 19
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/Animante = SubResource( 2 )
|
||||
|
||||
[connection signal="timeout" from="Quarters" to="." method="_on_Quarters_timeout"]
|
|
@ -1,10 +1,11 @@
|
|||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://sprites/water.tres" type="TileSet" id=1]
|
||||
[ext_resource path="res://scripts/gpanel.gd" type="Script" id=2]
|
||||
[ext_resource path="res://sprites/terrian.tres" type="TileSet" id=3]
|
||||
[ext_resource path="res://scripts/world.gd" type="Script" id=4]
|
||||
[ext_resource path="res://scripts/cameramovement.gd" type="Script" id=5]
|
||||
[ext_resource path="res://scenes/Zone.tscn" type="PackedScene" id=6]
|
||||
|
||||
[node name="game" type="Node"]
|
||||
|
||||
|
@ -29,6 +30,9 @@ position = Vector2( 512, 304 )
|
|||
current = true
|
||||
script = ExtResource( 5 )
|
||||
|
||||
[node name="Resdenital" parent="world" instance=ExtResource( 6 )]
|
||||
position = Vector2( 152.043, 336.414 )
|
||||
|
||||
[node name="ui" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="base" type="Control" parent="ui"]
|
||||
|
@ -86,11 +90,11 @@ __meta__ = {
|
|||
}
|
||||
|
||||
[node name="currencylbl" type="Label" parent="ui/base/gpanel/citystatus"]
|
||||
margin_left = 251.0
|
||||
margin_left = 252.0
|
||||
margin_top = 3.0
|
||||
margin_right = 259.0
|
||||
margin_bottom = 17.0
|
||||
text = "$"
|
||||
text = "§"
|
||||
|
||||
[node name="moneylbl" type="Label" parent="ui/base/gpanel/citystatus"]
|
||||
margin_left = 263.0
|
||||
|
|
|
@ -46,4 +46,5 @@ margin_top = 319.0
|
|||
margin_right = 601.0
|
||||
margin_bottom = 339.0
|
||||
text = "Create"
|
||||
|
||||
[connection signal="pressed" from="CreateBtn" to="." method="_on_CreateBtn_pressed"]
|
||||
|
|
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()
|
|
@ -1,6 +1,11 @@
|
|||
extends Node
|
||||
|
||||
var city_name: String
|
||||
var city_name: String = "Furtropolis"
|
||||
var year: int = 1
|
||||
var prev_quarter: int
|
||||
var quarter: int = 1
|
||||
var population: int = 0
|
||||
var news_ticker: String
|
||||
|
||||
var budget: int
|
||||
var prev_budget: int
|
5
scripts/autoload/SimEvents.gd
Normal file
5
scripts/autoload/SimEvents.gd
Normal file
|
@ -0,0 +1,5 @@
|
|||
extends Node
|
||||
|
||||
signal quarter_income
|
||||
signal one_time_income
|
||||
signal pay_expense
|
Loading…
Add table
Reference in a new issue