Skip to content

Instantly share code, notes, and snippets.

@Donnotron666
Last active May 24, 2017 15:26
Show Gist options
  • Save Donnotron666/0513a44d1592b39e3dd37491e47a0e3e to your computer and use it in GitHub Desktop.
Save Donnotron666/0513a44d1592b39e3dd37491e47a0e3e to your computer and use it in GitHub Desktop.
Quick demo on time slow down in BF'88
namespace Client.Game.Core {
public class Game
{
public static Game Instance { get; private set; }
public bool Paused;
public Actor PossessedActor;
public FSM States;
public GameMode Mode;
public Seed Seed {
get; private set;
}
public Game (GameManagerProxy proxy)
{
Mode = GameMode.Pending();
Settings.Settings.Apply();
MonoProxy = proxy;
Instance = this;
Init();
}
private float skipTime = 0f;
public void SkipTime (float duration, float atScale = 0f, bool allowReduction = true)
{
//if already skipping, lower additional skip amt
if (skipTime > 0f && allowReduction)
duration *= .2f;
skipTime += duration;
Time.timeScale = atScale;
}
private void Init() {
this.Seed = new Seed(Mode.SeedValue);
AudioMixer = Mixer.Get();
States.Start(this);
}
public void Update(float dt) {
if(!Paused) {
if(skipTime > 0f) {
skipTime-= Time.unscaledDeltaTime;
} else {
skipTime = 0f;
Time.timeScale = 1f;
}
}
States.Update(dt);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment