feat: aetherbind, first source generator
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using Godot;
|
||||
using GodotHostTest.AetherBind;
|
||||
using GodotHostTest.Helpers;
|
||||
using GodotHostTest.Interfaces;
|
||||
using OwofGames.AetherBind;
|
||||
using R3;
|
||||
|
||||
namespace GodotHostTest.Game.Score;
|
||||
|
||||
[Injected]
|
||||
public partial class Score : Control, IScore
|
||||
{
|
||||
[Export] private AnimationPlayer _animationPlayer = null!;
|
||||
[Export] private Label _label = null!;
|
||||
|
||||
private int _score;
|
||||
[Inject] private IValueGetter<ITargetSpawner> _targetSpawner = null!;
|
||||
|
||||
int IScore.Score => _score;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_targetSpawner.Value.TargetSpawned.Subscribe(OnTargetSpawned).AddTo(this);
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
private void OnTargetSpawned(ITarget target)
|
||||
{
|
||||
_animationPlayer.Play("wiggle");
|
||||
target.Hit.Select(_ => 20).Merge(target.TimedOut.Select(_ => -5)).SubscribeOnce(delta =>
|
||||
{
|
||||
_score += delta;
|
||||
UpdateScore();
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
||||
private void UpdateScore()
|
||||
{
|
||||
_label.Text = $"Score: {_score}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user