Ejemplo n.º 1
0
 public static void BotInitializeAsync(IServiceProvider service)
 {
     using (var serviceScope = service.CreateScope())
     {
         var scopeServiceProvider = serviceScope.ServiceProvider;
         var botRepository        = scopeServiceProvider.GetService <IBotRepository>();
         BotsData.Initialize(botRepository);
     }
 }
        public void Save()
        {
            var botsData = new BotsData();

            botsData.animalsCount = ParameterManager.Instance.NeutralCharVal;
            botsData.enemyCount   = ParameterManager.Instance.HostileCharVal;

            var binaryFormatter = new BinaryFormatter();
            var path            = Application.persistentDataPath + _fileName;
            var fileStream      = new FileStream(path, FileMode.Create);

            binaryFormatter.Serialize(fileStream, botsData);
            fileStream.Close();
        }
        public void Load()
        {
            var path = Application.persistentDataPath + _fileName;

            if (!File.Exists(path))
            {
                return;
            }
            var binaryFormatter = new BinaryFormatter();
            var fileStream      = new FileStream(path, FileMode.Open);

            _botsData = binaryFormatter.Deserialize(fileStream) as BotsData;
            fileStream.Close();

            ParameterManager.Instance.NeutralCharVal = _botsData.animalsCount;
            ParameterManager.Instance.HostileCharVal = _botsData.enemyCount;
        }