Exemple #1
0
        public void Read(string path)
        {
            Message = string.Format("Load level from file: {0}", new FileInfo(path).FullName);;
            try
            {
                var json = File.ReadAllText(path);
                SceneLevel = JsonUtility.FromJson <SceneLevel>(json);
            }
            catch (Exception e)
            {
                Message = e.Message;
            }

            GenerateGoMap();
        }
Exemple #2
0
        private IEnumerator Start()
        {
            Enum.GetNames(typeof(SceneLevel.StuffType)).ToList().ForEach(key =>
            {
                var value = transform.Find(key);
                if (value == null)
                {
                    Debug.LogError("Cannot find transform from key: " + key);
                }
                var layerInfo = value.GetComponent <SceneLayerInfo>();
                SceneLayerMap.Add(key, layerInfo);
            });

            if (SceneLoader != null)
            {
                yield return(SceneLoader.Load());
            }

            if (Data == null)
            {
                qy.config.QuestItem quest = qy.GameMainManager.Instance.playerData.GetQuest();
                var chapter = quest != null ? quest.chapter : 1;
                Data = Resources.Load <TextAsset>("Level_" + chapter);
            }

            if (AutoLoad)
            {
                SceneLevel = JsonUtility.FromJson <SceneLevel>(Data.text);
                GenerateGoMap();
            }

            if (SceneIsReady != null)
            {
                SceneIsReady(this, EventArgs.Empty);
            }
        }