protected override void mapBindings() { var startBinding = commandBinder.Bind <StartSignal>(); if (this == Context.firstContext) { // Load the Global context before issuing the start command if it hasn't been loaded. startBinding.To <RootStartCommand>().To <StartCommand>().InSequence(); var gameConfigText = Resources.Load("Configuration/game_configuration") as TextAsset; var stopwatch = System.Diagnostics.Stopwatch.StartNew(); if (gameConfigText != null) { var gameJson = JObject.Parse(gameConfigText.text); var game = Game.CreateFromJson(gameJson); stopwatch.Stop(); Debug.LogFormat("Deserializing Game object took {0}ms", stopwatch.ElapsedMilliseconds); injectionBinder.Bind <Game>().ToValue(game).CrossContext(); injectionBinder.Bind <IMapConfigRepository>().To(new ExternalMapConfigurationRepository(game.Maps)); } else { throw new Exception("Could not find game configuration file."); } injectionBinder.Bind <ICutsceneLoader>().To <CutsceneLoader>().ToSingleton().CrossContext(); injectionBinder.Bind <Storyboard>().ToSingleton().CrossContext(); injectionBinder.Bind <ApplicationState>().ToValue(new ApplicationState()).CrossContext(); injectionBinder.Bind <IRoutineRunner>().To <RoutineRunner>().CrossContext(); var saveRepository = new DiskSaveGameRepository(UnityEngine.Application.persistentDataPath, MaxSaves); injectionBinder.Bind <ISaveGameRepository>().ToValue(saveRepository).CrossContext(); injectionBinder.Bind <ISaveGameService>().To <SaveGameService>().ToSingleton().CrossContext(); injectionBinder.Bind <CharacterDatabase>().To <BaseCharacterDatabase>().ToSingleton().CrossContext(); injectionBinder.Bind <IBattleConfigRepository>().To <BattleConfigRepository>().ToSingleton().CrossContext(); injectionBinder.Bind <AddSceneSignal>().ToSingleton().CrossContext(); injectionBinder.Bind <QuitGameSignal>().ToSingleton().CrossContext(); commandBinder.Bind <AddSceneSignal>().To <AddSceneCommand>(); commandBinder.Bind <QuitGameSignal>().To <QuitGameCommand>(); } else { startBinding.To <KillAudioListenerCommand>().To <StartCommand>().InSequence(); } }
public void TestSaving() { var path = TestContext.CurrentContext.TestDirectory; var repository = new DiskSaveGameRepository(path); var liat = new CharacterBuilder() .Id("liat") .Name("Liat") .Stats(new StatsBuilder().Leadership().Build()) .Special(SkillType.Advance) .Growths(new GrowthsBuilder() .Health(15) .Skill(12) .Defense(2) .Special(0) .Speed(13) .Strength(7) .Build()) .Attributes(new AttributesBuilder() .Health(1) .Skill(1) .Defense(1) .Special(1) .Speed(1) .Strength(1) .Build()) .Weapons("Shortsword") .Build(); var characters = new List <ICharacter> { liat }; var save = new DefaultSaveGame(characters) { Path = Path.Combine(path, "test_save.json") }; repository.Persist(save); var saves = repository.GetAllSaves(); Assert.AreEqual(1, saves.Count); }