Animanted office sprites

This commit is contained in:
Anthony Foxclaw 2020-04-13 00:05:52 -04:00
parent 8fd498367b
commit 63bde9f37f
8 changed files with 59 additions and 18 deletions

View file

@ -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

View file

@ -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

View file

@ -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.

4
project/src/gui.gd Normal file
View file

@ -0,0 +1,4 @@
extends Control
func _on_NameBtn_pressed():
pass

View file

@ -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
}

View file

@ -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:

View file

@ -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
}

View file

@ -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"]