public void EnterSWBF2Map(string mapScript) { Debug.Assert(Env == null || Env.IsLoaded); ShowLoadscreen(); RemoveMenu(false); PhxPath envPath = StdLVLPC; if (RegisteredAddons.TryGetValue(mapScript, out string addonName)) { envPath = AddonPath / addonName / "data/_lvl_pc"; } if (UnitySceneName != null) { SceneManager.UnloadSceneAsync(UnitySceneName); UnitySceneName = null; } Env?.Delete(); Env = PhxRuntimeEnvironment.Create(envPath, StdLVLPC); Env.ScheduleLVLRel("load/common.lvl"); Env.OnLoadscreenLoaded += OnLoadscreenTextureLoaded; Env.OnLoaded += OnEnvLoaded; Env.OnExecuteMain += OnEnvExecutionMain; Env.Run(mapScript, "ScriptInit", "ScriptPostLoad"); }
// Update is called once per frame void Update() { PhxRuntimeEnvironment rt = PhxGameRuntime.GetEnvironment(); if (rt != null) { Percentage = Mathf.Lerp(Percentage, rt.GetLoadingProgress(), Time.deltaTime * PercentageSpeed); LoadIcon.material.SetFloat("_Percent", Percentage); } if (ImageSet) { if (FadeImagePlayback < FadeImageDuration) { FadeImagePlayback += Time.deltaTime; } LoadImage.color = Color.Lerp(Color.black, Color.white, FadeImagePlayback / FadeImageDuration); } if (State == LSState.FadeIn && FadeScreenPlayback < FadeScreenDuration) { FadeScreenPlayback += Time.deltaTime; } else if (State == LSState.FadeOut && FadeScreenPlayback > 0.0) { FadeScreenPlayback -= Time.deltaTime; } CVGroup.alpha = FadeScreenPlayback / FadeScreenDuration; }
public void EnterMainMenu(bool bInit = false) { Debug.Assert(Env == null || Env.IsLoaded); MapRotation.Clear(); MapRotationIdx = -1; bInitMainMenu = bInit; ShowLoadscreen(bInit); RemoveMenu(false); if (UnitySceneName != null) { SceneManager.UnloadSceneAsync(UnitySceneName); UnitySceneName = null; } Env?.Delete(); Env = PhxRuntimeEnvironment.Create(StdLVLPC); if (!bInit) { Env.ScheduleLVLRel("load/gal_con.lvl"); } RegisteredAddons.Clear(); ExploreAddons(); Env.OnExecuteMain += OnMainMenuExecution; Env.OnLoaded += OnMainMenuLoaded; Env.Run("missionlist"); }
void OnGUI() { PhxRuntimeEnvironment env = PhxGameRuntime.GetEnvironment(); if (!Application.isPlaying || PhxGameRuntime.Instance == null || env == null) { EditorGUILayout.LabelField("Game is not running"); return; } PhxPath gamePath = PhxGameRuntime.GamePath; EditorGUILayout.LabelField("Environment Path", env.Path - gamePath); EditorGUILayout.LabelField("Fallback Path", env.FallbackPath - gamePath); EditorGUILayout.Space(); EditorGUILayout.LabelField("Environment Stage", env.Stage.ToString()); EditorGUILayout.Space(); foreach (var lvl in env.LVLs) { EditorGUILayout.LabelField(lvl.RelativePath, "Loaded", lvl.bIsFallback ? FallbackLVLStyle : EnvLVLStyle); } foreach (var lvl in env.LoadingLVLs) { EditorGUILayout.LabelField(lvl.PathPartial, string.Format("{0:0.} %", env.GetProgress(lvl.Handle) * 100.0f), lvl.bIsFallback ? FallbackLVLStyle : EnvLVLStyle); } }
public static PhxRuntimeEnvironment Create(PhxPath envPath, PhxPath fallbackPath = null, bool initMatch = true) { if (!envPath.Exists()) { Debug.LogErrorFormat("Given environment path '{0}' doesn't exist!", envPath); return(null); } if (fallbackPath == null) { fallbackPath = envPath; } Debug.Assert(fallbackPath.Exists()); PhxAnimationLoader.ClearDB(); GameLuaEvents.Clear(); PhxRuntimeEnvironment rt = new PhxRuntimeEnvironment(envPath, fallbackPath); rt.ScheduleLVLRel("core.lvl"); rt.ScheduleLVLRel("shell.lvl"); rt.ScheduleLVLRel("common.lvl"); rt.ScheduleLVLRel("mission.lvl"); rt.ScheduleSoundBankRel("sound/common.bnk"); rt.RTScene = new PhxRuntimeScene(rt, rt.EnvCon); rt.Match = initMatch ? new PhxRuntimeMatch() : null; rt.Timers = new PhxTimerDB(); PhxAnimationLoader.Con = rt.EnvCon; return(rt); }
public void EnterUnityScene(string sceneName) { Debug.Assert(Env == null || Env.IsLoaded); ShowLoadscreen(); RemoveMenu(false); if (UnitySceneName != null) { SceneManager.UnloadSceneAsync(UnitySceneName); UnitySceneName = null; } SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive); UnitySceneName = sceneName; SceneManager.sceneLoaded += (Scene scene, LoadSceneMode mode) => { PhxUnityScene sceneInit = FindObjectOfType <PhxUnityScene>(); // for some reason, this event fires twice... // and only the second time, the script is found if (sceneInit == null) { return; } Env?.Delete(); Env = PhxRuntimeEnvironment.Create(StdLVLPC); Env.ScheduleLVLRel("load/common.lvl"); Env.ScheduleLVLRel("ingame.lvl"); if (sceneInit.ScheduleLVLs != null) { for (int i = 0; i < sceneInit.ScheduleLVLs.Length; ++i) { Env.ScheduleLVLRel(sceneInit.ScheduleLVLs[i]); } } Env.OnLoadscreenLoaded += OnLoadscreenTextureLoaded; Env.OnLoaded += OnEnvLoaded; Env.OnExecuteMain += OnEnvExecutionMain; Env.Run(null); }; }
public static PhxRuntimeMatch GetMatch() { PhxRuntimeEnvironment env = GetEnvironment(); return(env == null ? null : env.GetMatch()); }
public static PhxRuntimeScene GetScene() { PhxRuntimeEnvironment env = GetEnvironment(); return(env == null ? null : env.GetScene()); }
public static PhxTimerDB GetTimerDB() { PhxRuntimeEnvironment env = GetEnvironment(); return(env == null ? null : env.GetTimerDB()); }