Animated the gold count label.
parent
c982ec783c
commit
22ad86319d
|
@ -17,7 +17,7 @@ public class Game : Spatial
|
||||||
private TextureRect _worldTextureRect;
|
private TextureRect _worldTextureRect;
|
||||||
private TextureRect _heightTextureRect;
|
private TextureRect _heightTextureRect;
|
||||||
private Button _generateWorldButton;
|
private Button _generateWorldButton;
|
||||||
private Control _gameUI;
|
private Control _gameUi;
|
||||||
private Label _goldCountLabel;
|
private Label _goldCountLabel;
|
||||||
|
|
||||||
// scene nodes
|
// scene nodes
|
||||||
|
@ -62,8 +62,8 @@ public class Game : Spatial
|
||||||
_worldTextureRect = worldGeneratorContainer.GetNode<TextureRect>("WorldTextureRect");
|
_worldTextureRect = worldGeneratorContainer.GetNode<TextureRect>("WorldTextureRect");
|
||||||
_heightTextureRect = worldGeneratorContainer.GetNode<TextureRect>("HeightTextureRect");
|
_heightTextureRect = worldGeneratorContainer.GetNode<TextureRect>("HeightTextureRect");
|
||||||
_generateWorldButton = worldGeneratorContainer.GetNode<Button>("WorldGenerateButton");
|
_generateWorldButton = worldGeneratorContainer.GetNode<Button>("WorldGenerateButton");
|
||||||
_gameUI = (Control)FindNode("GameUI");
|
_gameUi = (Control)FindNode("GameUI");
|
||||||
_goldCountLabel = _gameUI.GetNode<Label>("GoldCount");
|
_goldCountLabel = _gameUi.GetNode<Label>("GoldCount");
|
||||||
Debug.Assert(_goldCountLabel != null);
|
Debug.Assert(_goldCountLabel != null);
|
||||||
|
|
||||||
// scene nodes
|
// scene nodes
|
||||||
|
@ -291,6 +291,8 @@ public class Game : Spatial
|
||||||
_player.Navigation.PlanDirectPath(playerStartTransform.origin, playerStartTransform.origin,
|
_player.Navigation.PlanDirectPath(playerStartTransform.origin, playerStartTransform.origin,
|
||||||
playerStartTransform.basis.Quat());
|
playerStartTransform.basis.Quat());
|
||||||
|
|
||||||
|
_goldCountLabel.Text = "0";
|
||||||
|
|
||||||
foreach (Spatial entity in GetNode("Entities").GetChildren())
|
foreach (Spatial entity in GetNode("Entities").GetChildren())
|
||||||
{
|
{
|
||||||
Transform entityTransform = entity.Transform;
|
Transform entityTransform = entity.Transform;
|
||||||
|
@ -338,6 +340,10 @@ public class Game : Spatial
|
||||||
|
|
||||||
public void OnGoldCountChanged(int goldCount)
|
public void OnGoldCountChanged(int goldCount)
|
||||||
{
|
{
|
||||||
|
AnimationPlayer animationPlayer = _gameUi.GetNode<AnimationPlayer>("AnimationPlayer");
|
||||||
_goldCountLabel.Text = goldCount.ToString();
|
_goldCountLabel.Text = goldCount.ToString();
|
||||||
|
animationPlayer.CurrentAnimation = "FlashLabel";
|
||||||
|
animationPlayer.Seek(0);
|
||||||
|
animationPlayer.Play();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=21 format=2]
|
[gd_scene load_steps=22 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://scenes/StreamContainer.cs" type="Script" id=1]
|
[ext_resource path="res://scenes/StreamContainer.cs" type="Script" id=1]
|
||||||
[ext_resource path="res://components/NavigationComponent.cs" type="Script" id=2]
|
[ext_resource path="res://components/NavigationComponent.cs" type="Script" id=2]
|
||||||
|
@ -15,6 +15,22 @@
|
||||||
[ext_resource path="res://entities/Axe.tscn" type="PackedScene" id=14]
|
[ext_resource path="res://entities/Axe.tscn" type="PackedScene" id=14]
|
||||||
[ext_resource path="res://systems/InteractionSystem.cs" type="Script" id=15]
|
[ext_resource path="res://systems/InteractionSystem.cs" type="Script" id=15]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id=25]
|
||||||
|
resource_name = "FlashLabel"
|
||||||
|
length = 0.3
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/path = NodePath("GoldCount:rect_scale")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PoolRealArray( 0, 0.1, 0.3 ),
|
||||||
|
"transitions": PoolRealArray( 1, 0.170755, 1 ),
|
||||||
|
"update": 0,
|
||||||
|
"values": [ Vector2( 1, 1 ), Vector2( 2, 2 ), Vector2( 1, 1 ) ]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="CubeMesh" id=1]
|
[sub_resource type="CubeMesh" id=1]
|
||||||
size = Vector3( 1, 1, 1 )
|
size = Vector3( 1, 1, 1 )
|
||||||
|
|
||||||
|
@ -69,9 +85,13 @@ margin_top = 13.0
|
||||||
margin_right = 84.0
|
margin_right = 84.0
|
||||||
margin_bottom = 27.0
|
margin_bottom = 27.0
|
||||||
rect_min_size = Vector2( 50, 0 )
|
rect_min_size = Vector2( 50, 0 )
|
||||||
|
rect_pivot_offset = Vector2( 45, 8 )
|
||||||
text = "0"
|
text = "0"
|
||||||
align = 2
|
align = 2
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="GameUI"]
|
||||||
|
anims/FlashLabel = SubResource( 25 )
|
||||||
|
|
||||||
[node name="DebugContainer" type="PanelContainer" parent="."]
|
[node name="DebugContainer" type="PanelContainer" parent="."]
|
||||||
visible = false
|
visible = false
|
||||||
self_modulate = Color( 1, 1, 1, 0.443137 )
|
self_modulate = Color( 1, 1, 1, 0.443137 )
|
||||||
|
|
Loading…
Reference in New Issue