From 63bde9f37f902cb0cafdde10a9d2e155469a56a0 Mon Sep 17 00:00:00 2001 From: Anthony Foxclaw <35226681+tonytins@users.noreply.github.com> Date: Mon, 13 Apr 2020 00:05:52 -0400 Subject: [PATCH] Animanted office sprites --- project/assets/office.tscn | 36 ++++++++++++++++++++++++++++---- project/src/autoload/gamedata.gd | 2 ++ project/src/gpanel.gd | 8 +------ project/src/gui.gd | 4 ++++ project/src/gui.tscn | 4 +++- project/src/room.gd | 11 +++++++++- project/src/titlescreen.tscn | 1 + project/src/world.tscn | 11 +++++----- 8 files changed, 59 insertions(+), 18 deletions(-) create mode 100644 project/src/gui.gd diff --git a/project/assets/office.tscn b/project/assets/office.tscn index 121096d..ac69547 100644 --- a/project/assets/office.tscn +++ b/project/assets/office.tscn @@ -1,7 +1,32 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=16 format=2] [ext_resource path="res://src/room.gd" type="Script" id=1] -[ext_resource path="res://assets/Office/office_t0_6_1.png" type="Texture" id=2] +[ext_resource path="res://assets/Office/office_t0_1_3.png" type="Texture" id=2] +[ext_resource path="res://assets/Office/office_t1_2_3.png" type="Texture" id=3] +[ext_resource path="res://assets/Office/office_t0_1_5.png" type="Texture" id=4] +[ext_resource path="res://assets/Office/office_t0_1_4.png" type="Texture" id=5] +[ext_resource path="res://assets/Office/office_t0_1_6.png" type="Texture" id=6] +[ext_resource path="res://assets/Office/office_t0_1_2.png" type="Texture" id=7] +[ext_resource path="res://assets/Office/office_t0_1_1.png" type="Texture" id=8] +[ext_resource path="res://assets/Office/office_t0_1_0.png" type="Texture" id=9] +[ext_resource path="res://assets/Office/office_t1_2_1.png" type="Texture" id=10] +[ext_resource path="res://assets/Office/office_t1_2_4.png" type="Texture" id=11] +[ext_resource path="res://assets/Office/office_t1_2_2.png" type="Texture" id=12] +[ext_resource path="res://assets/Office/office_t1_2_0.png" type="Texture" id=13] +[ext_resource path="res://assets/Office/office_t1_2_5.png" type="Texture" id=14] + +[sub_resource type="SpriteFrames" id=1] +animations = [ { +"frames": [ ExtResource( 13 ), ExtResource( 10 ), ExtResource( 12 ), ExtResource( 3 ), ExtResource( 11 ), ExtResource( 14 ) ], +"loop": true, +"name": "v2", +"speed": 2.0 +}, { +"frames": [ ExtResource( 9 ), ExtResource( 8 ), ExtResource( 7 ), ExtResource( 2 ), ExtResource( 5 ), ExtResource( 4 ), ExtResource( 6 ) ], +"loop": true, +"name": "v1", +"speed": 2.0 +} ] [node name="Office" type="Node2D"] script = ExtResource( 1 ) @@ -11,5 +36,8 @@ room_expense = 350 room_capacity = 1 is_rentable = true -[node name="Sprite" type="Sprite" parent="."] -texture = ExtResource( 2 ) +[node name="AnimatedSprite" type="AnimatedSprite" parent="."] +frames = SubResource( 1 ) +animation = "v1" +frame = 5 +playing = true diff --git a/project/src/autoload/gamedata.gd b/project/src/autoload/gamedata.gd index 4b49df1..30a9940 100644 --- a/project/src/autoload/gamedata.gd +++ b/project/src/autoload/gamedata.gd @@ -6,6 +6,8 @@ var year: int = 1 var prev_quarter: int var quarter: int = 1 var population: int = 0 +var news: String + enum GameSpeed { SLOW, MEDIUM, FAST } signal quarter_income diff --git a/project/src/gpanel.gd b/project/src/gpanel.gd index ceede0a..5ced3b4 100644 --- a/project/src/gpanel.gd +++ b/project/src/gpanel.gd @@ -1,17 +1,11 @@ extends Panel -func _ready(): - $GameStatus/MoneyLbl.text = str(GameData.budget) - $GameStatus/YearNumLbl.text = str(GameData.year) - $GameStatus/QuaterNumLbl.text = str(GameData.quarter) - $GameStatus/PopNumLbl.text = str(GameData.population) - $GameMenus/NameBtn.text = GameData.tower_name - func _process(delta): $GameStatus/MoneyLbl.text = str(GameData.budget) $GameStatus/YearNumLbl.text = str(GameData.year) $GameStatus/PopNumLbl.text = str(GameData.population) $GameStatus/QuaterNumLbl.text = str(GameData.quarter) + $GameMenus/NameBtn.text = GameData.tower_name func _on_NameBtn_pressed(): pass # Replace with function body. diff --git a/project/src/gui.gd b/project/src/gui.gd new file mode 100644 index 0000000..11a9bf4 --- /dev/null +++ b/project/src/gui.gd @@ -0,0 +1,4 @@ +extends Control + +func _on_NameBtn_pressed(): + pass diff --git a/project/src/gui.tscn b/project/src/gui.tscn index db3c252..e99c08e 100644 --- a/project/src/gui.tscn +++ b/project/src/gui.tscn @@ -1,10 +1,12 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=3 format=2] [ext_resource path="res://src/gpanel.gd" type="Script" id=1] +[ext_resource path="res://src/gui.gd" type="Script" id=2] [node name="GUI" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 +script = ExtResource( 2 ) __meta__ = { "_edit_use_anchors_": false } diff --git a/project/src/room.gd b/project/src/room.gd index 14ad70f..403e076 100644 --- a/project/src/room.gd +++ b/project/src/room.gd @@ -1,6 +1,8 @@ +tool extends Node2D enum IncomeFrequency { ONE_TIME, QUARTERLY } +enum ChooseSprite { VERSION_1, VERSION_2 } export var room_cost: int = 10000 export var room_income: int @@ -8,6 +10,7 @@ export var room_expense: int export var room_capacity: int export var is_rentable: bool export(IncomeFrequency) var income_frequency = IncomeFrequency.QUARTERLY +export(ChooseSprite) var choose_sprite = ChooseSprite.VERSION_1 var is_vacant: bool var num_of_tenants: int @@ -22,7 +25,13 @@ func _ready(): GameData.budget -= room_cost func _process(delta): - + + match choose_sprite: + ChooseSprite.VERSION_1: + $AnimatedSprite.play("v1") + ChooseSprite.VERSION_2: + $AnimatedSprite.play("v2") + # If the office is no longer vacant, start rent timer if is_rentable == true: if num_of_tenants >= room_capacity: diff --git a/project/src/titlescreen.tscn b/project/src/titlescreen.tscn index 695c4fc..d35fb91 100644 --- a/project/src/titlescreen.tscn +++ b/project/src/titlescreen.tscn @@ -35,6 +35,7 @@ margin_right = 312.0 margin_bottom = 42.0 text = "Elecoms HQ" align = 1 +caret_blink = true __meta__ = { "_edit_use_anchors_": false } diff --git a/project/src/world.tscn b/project/src/world.tscn index 729429b..3fa8f38 100644 --- a/project/src/world.tscn +++ b/project/src/world.tscn @@ -7,15 +7,16 @@ [node name="World" type="Node"] script = ExtResource( 1 ) -[node name="GUI" parent="." instance=ExtResource( 2 )] - [node name="Quarters" type="Timer" parent="."] wait_time = 10.0 autostart = true [node name="Office" parent="." instance=ExtResource( 3 )] -position = Vector2( 427.577, 274.653 ) -income_frequency = 1 +position = Vector2( 481.153, 260.554 ) -[node name="Sprite" type="Sprite" parent="."] +[node name="Office2" parent="." instance=ExtResource( 3 )] +position = Vector2( 271.221, 296.175 ) +choose_sprite = 1 + +[node name="GUI" parent="." instance=ExtResource( 2 )] [connection signal="timeout" from="Quarters" to="." method="_on_Quarters_timeout"]