riversong code showcase
This commit is contained in:
12
Source/Riversong/Game/Demo/DemoCompletedSignal.cs
Normal file
12
Source/Riversong/Game/Demo/DemoCompletedSignal.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace DanieleMarotta.RiversongCodeShowcase
|
||||
{
|
||||
public struct DemoCompletedSignal
|
||||
{
|
||||
public float GameTime;
|
||||
|
||||
public DemoCompletedSignal(float gameTime)
|
||||
{
|
||||
GameTime = gameTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
41
Source/Riversong/Game/Demo/DemoSystem.cs
Normal file
41
Source/Riversong/Game/Demo/DemoSystem.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace DanieleMarotta.RiversongCodeShowcase
|
||||
{
|
||||
[RequiresWorldReadyForUpdate]
|
||||
public class DemoSystem : GameSystem, IUpdatable
|
||||
{
|
||||
[InjectService]
|
||||
private ISignalBus _signalBus;
|
||||
|
||||
[InjectService]
|
||||
private GameConfig _config;
|
||||
|
||||
[InjectService]
|
||||
private World _world;
|
||||
|
||||
private bool _demoCompleted;
|
||||
|
||||
private float _gameTime;
|
||||
|
||||
public DemoSystem(IServiceLocator serviceLocator) : base(serviceLocator)
|
||||
{
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (_demoCompleted) return;
|
||||
|
||||
_gameTime += Time.unscaledDeltaTime;
|
||||
|
||||
var populationState = _world.PopulationState;
|
||||
var generalSettings = _config.GeneralSettings;
|
||||
|
||||
if (populationState.Population < generalSettings.PopulationGoal || populationState.Happiness < generalSettings.HappinessGoal) return;
|
||||
|
||||
_demoCompleted = true;
|
||||
|
||||
_signalBus.Raise(new DemoCompletedSignal(_gameTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user