Esempio n. 1
0
        protected override void Awake()
        {
            base.Awake();
            try
            {
                FizzleSettings.RedirectException();
                AssetBundle assetBundle = AssetBundle.LoadFromFile(CommonTools.ConvertPath("~/Resources/official-levels.fizzle"));
                commonScript = assetBundle.LoadAsset <TextAsset>("common.py").text;
                customScript = assetBundle.LoadAsset <TextAsset>("custom.py").text;
                Subtitle     = PythonGenerator.LoadYaml("~/Text/subtitle.yml");
                @static      = Spawn(transform, "static").transform;
                FizzleView   = Spawn(m_FizzleDefination.m_FizzleView, @static);

                Python = PythonGenerator.Python;
                List <string> stringList;
                if (FizzleSettings.CommandArgs.ContainsKey("userlevel") && (stringList = FizzleSettings.CommandArgs["userlevel"]).Count > 0)
                {
                    string levelId;
                    Python.Execute(customScript);
                    sceneInfos = FizzleSettings.LoadSceneInfo(stringList[0], out levelId);
                    LevelId    = levelId;
                }
                else
                {
                    SceneInfo[] osi = new SceneInfo[7];
                    for (int i = 0; i < osi.Length; i++)
                    {
                        osi[i] = new SceneInfo
                        {
                            m_ConfigText  = assetBundle.LoadAsset <TextAsset>("config" + (i + 1)),
                            m_ObjectsText = assetBundle.LoadAsset <TextAsset>("layout" + (i + 1))
                        };
                    }

                    sceneInfos = new List <KeyValuePair <string, string> >(osi.Select(item => new KeyValuePair <string, string>(item.m_ConfigText.text, item.m_ObjectsText.text)));
                    LevelId    = "official";
                }

                LevelCount      = sceneInfos.Count;
                index           = Python.GetVariable("get_max_level_index")(LevelId);
                LoadLevel(index = (index + 1) % LevelCount);
                TimeCtrl.timeControllerEnabled    = true;
                FirstPersonCtrl.controllerEnabled = true;
                Ready = true;
            }
            catch (Exception)
            {
                Ready = false;
                throw;
            }
        }