Esempio n. 1
0
        private IEnumerator Start()
        {
            AsyncOperationHandle <TextAsset> configHandle = Addressables.LoadAssetAsync <TextAsset>("config.txt");

            yield return(configHandle);

            Config config = JsonConvert.DeserializeObject <Config>(configHandle.Result.text,
                                                                   new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.Objects
            });

            if (config == null)
            {
                Debug.LogError($"Could not deserialize Config with contents: {configHandle.Result.text}");
                yield break;
            }

            config.Init();

            Assets assets = new Assets();

            yield return(assets.LoadSprites("items", "entities", "common"));

            yield return(assets.LoadPrefabs("system"));

            yield return(assets.LoadTilemaps(config.Get <MapSystemConfig>().tilemaps));

            ctx  = new Context(config, assets, new EventPump());
            Game = new Game(ctx);

            UnityUpdate.Add(this);
        }
Esempio n. 2
0
 public Timer(float startTime, Action timeoutCallback)
 {
     time       = startTime;
     maxTime    = startTime;
     onTimeout += timeoutCallback;
     UnityUpdate.Add(this);
 }