public MainViewModel() { var adjustmentFactory = new ResourceAdjustmentFactory(); _commandFactory = new DelegateCommandFactory(); _woodCache = new ObservableResourceCache(new ResourceCache(), () => { NotifyPropertyChanged(nameof(Wood)); NotifyPropertyChanged(nameof(Lumbermill)); }); Lumbermill = new Lumbermill(_woodCache, adjustmentFactory); Increment = _commandFactory.CreateFor( () => _woodCache.Apply(adjustmentFactory.CreateIncreaseEqualTo(1))); UpgradeLumbermill = _commandFactory.CreateFor(Lumbermill.Upgrade); _loop = new GameLoop(ticksPerSecond: 100); _loop.Tick += (tickDuration) => { Lumbermill.Generate(tickDuration); }; _loop.Start(); _woodCache.Apply(adjustmentFactory.CreateIncreaseEqualTo(20)); }
public static void Dispose() { if (runner != null) { runner.Kill(); runner = null; } }
public static void Initialize(string file) { if (File.Exists(file)) { File.Delete(file); } Pipe = new ConcurrentQueue <string>(); runner = new Lumbermill(new StreamWriter(file, true)); runner.Begin(); string year = DateTime.Now.ToString("yyyy"); string monthDay = DateTime.Now.ToString("MMdd"); Write(string.Format("Captain's log, USS Enterprise (NCC-{0}-D), {1}", year, monthDay)); }