Exemplo 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;
            }
        }
Exemplo n.º 2
0
 protected override void Start()
 {
     try
     {
         sceneSetting.Apply(transform, m_FizzleDefination.m_LightSettings[Config.GetOrDefault("light", 0) % m_FizzleDefination.m_LightSettings.Count], new List <string>(Config["audio"].Select(item => item.ToString())));
         generate.Generate(item, wall);
         FirstPersonCtrl.transform.position = JsonArrayToVector3(Config["player-spawn-position"]);
         string faceAt = Config.GetOrDefault("player-face-at", "forward");
         FirstPersonCtrl.transform.eulerAngles += 90.0F * (faceAt == "left" ? 1.0F : (faceAt == "back" ? 2.0F : (faceAt == "right" ? 3.0F : 0.0F))) * Vector3.up;
         forkExchange           = Spawn <ForkExchange>(transform);
         forkExchange.Activator = Config.GetOrDefault <string>("fork-activator", null);
         levelEnd = Spawn(m_FizzleDefination.m_LevelEnd, transform);
         levelEnd.transform.position = JsonArrayToVector3(Config["level-end-position"]);
         Python.Execute(commonScript);
         Ready = true;
     }
     catch (Exception)
     {
         Ready = false;
         throw;
     }
 }