diff options
Diffstat (limited to 'WorldlineKeepers/Assets/Scripts/Phase')
14 files changed, 349 insertions, 0 deletions
diff --git a/WorldlineKeepers/Assets/Scripts/Phase/GameStageBase.cs b/WorldlineKeepers/Assets/Scripts/Phase/GameStageBase.cs new file mode 100644 index 0000000..a285d68 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Phase/GameStageBase.cs @@ -0,0 +1,35 @@ +using Microsoft.Unity.VisualStudio.Editor; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +namespace WK +{ + + public class GamePhaseBase : AsyncStatemachine.State + { + protected GamePhaseManager owner = GamePhaseManager.Instance; + + public override IEnumerator<float> OnStart() + { + yield break; + } + + public override IEnumerator<float> OnEnd() + { + yield break; + } + + public override void OnUpdate(float deltaTime) + { + } + + protected void GotoStage(EGamePhase target) + { + owner.AsyncLoadStage(target); + } + + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Phase/GameStageBase.cs.meta b/WorldlineKeepers/Assets/Scripts/Phase/GameStageBase.cs.meta new file mode 100644 index 0000000..15a5c56 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Phase/GameStageBase.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 432eadb305e58da4897534478987c4da +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Phase/GameStageManager.cs b/WorldlineKeepers/Assets/Scripts/Phase/GameStageManager.cs new file mode 100644 index 0000000..d2edf01 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Phase/GameStageManager.cs @@ -0,0 +1,95 @@ +using System.Collections; +using System.Collections.Generic; +using Unity.VisualScripting; +using UnityEditorInternal; +using UnityEngine; +using WK.Tools; + +namespace WK +{ + + /// <summary> + /// 游戏最上层的状态机 + /// </summary> + public sealed class GamePhaseManager : Singleton<GamePhaseManager>, ISubsystem + { + private AsyncStatemachine m_Statemachine; + private int[] stages = new int[(int)EGamePhase.Num]; + private EGamePhase prevStage = EGamePhase.Launch; + private EGamePhase curStage = EGamePhase.Launch; + + public void OnAwake() + { + SetupGamePhases(); + + } + + private void SetupGamePhases() + { + m_Statemachine = new AsyncStatemachine(); + + stages[(int)EGamePhase.Launch] = m_Statemachine.RegisterState(new GamePhase_Launch()); + stages[(int)EGamePhase.Main] = m_Statemachine.RegisterState(new GamePhase_Main()); + stages[(int)EGamePhase.Battle] = m_Statemachine.RegisterState(new GamePhase_Battle()); + stages[(int)EGamePhase.Dojo] = m_Statemachine.RegisterState(new GamePhase_Dojo()); + + m_Statemachine.Start(stages[(int)EGamePhase.Launch]); + } + + public void OnStart() + { + } + + public void OnUpdate() + { + m_Statemachine.Update(Time.deltaTime); + } + + public void OnFixedUpdate() + { + } + + public void OnDestroy() + { + } + + public void OnApplicationPause() + { + } + + public void OnApplicationQuit() + { + } + + public void AsyncLoadStage(EGamePhase stage, bool forceLoad = false, AsyncStatemachine.LoadStateComplete loadStateComplete = null) + { + int curRunStage = m_Statemachine.GetCurStateID(); + if (!forceLoad && curRunStage == stages[(int)stage]) + { + if (null != loadStateComplete) + { + loadStateComplete(); + } + return; + } + + //LogHelper.LogEditorError("==> StageChange:" + curStage + " --> " + (EGamePhase)stage); + + prevStage = curStage; + curStage = stage; + m_Statemachine.GotoState(stages[(int)stage], false, forceLoad, loadStateComplete); + } + + public EGamePhase GetCurStage() + { + return curStage; + } + + public EGamePhase GetPrevStage() + { + return prevStage; + } + + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Phase/GameStageManager.cs.meta b/WorldlineKeepers/Assets/Scripts/Phase/GameStageManager.cs.meta new file mode 100644 index 0000000..0ce1cb9 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Phase/GameStageManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4b7f17be1928ff849ba0d7d28ca8e87d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Battle.cs b/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Battle.cs new file mode 100644 index 0000000..9cb86e3 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Battle.cs @@ -0,0 +1,15 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WK +{ + + public class GamePhase_Battle : GamePhaseBase + { + + + + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Battle.cs.meta b/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Battle.cs.meta new file mode 100644 index 0000000..9104992 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Battle.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ad0f7465a835f2942ab4a37df3a827b4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Dojo.cs b/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Dojo.cs new file mode 100644 index 0000000..2b7acd7 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Dojo.cs @@ -0,0 +1,51 @@ +using LitJson; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using WK.Data; + +namespace WK +{ + + /// <summary> + /// 训练道场 + /// </summary> + public class GamePhase_Dojo : GamePhaseBase + { + + public override IEnumerator<float> OnStart() + { + GameSceneManager.Instance.LoadScene(StaticDefine.Scene_Dojo); + while(!GameSceneManager.Instance.sceneOpt.isDone) + { + yield return 0f; + } + SceneMetadata stage = new SceneMetadata(); + stage.tests = new List<string>() + { + "asdas","asdasd","asdsd" + }; + stage.desc = new SceneDesc(); + stage.desc.name = "namestage"; + stage.desc.desc = "descddd"; + stage.pos = new Vector3(1, 2, 3); + stage.count = 233; + string json = JsonMapper.ToJson(stage); + LogHelper.Log(json); + var s = JsonMapper.ToObject<SceneMetadata>(json); + Debug.Log(s.pos); + } + + public override IEnumerator<float> OnEnd() + { + yield break; + } + + public override void OnUpdate(float deltaTime) + { + + } + + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Dojo.cs.meta b/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Dojo.cs.meta new file mode 100644 index 0000000..d4e25cf --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Dojo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 30c90d11e59fd3f42b4568e275bb3fbe +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Launch.cs b/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Launch.cs new file mode 100644 index 0000000..2f5abe0 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Launch.cs @@ -0,0 +1,39 @@ +using MovementEffects; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using Unity.VisualScripting; +using UnityEngine; +using WK.Data; + +namespace WK +{ + + public class GamePhase_Launch : GamePhaseBase + { + + CoroutineHandle m_CoLoadData; + + public override IEnumerator<float> OnStart() + { + m_CoLoadData = DataManager.Instance.AsyncLoadAll(); + + yield break; + } + + public override IEnumerator<float> OnEnd() + { + yield break; + } + + public override void OnUpdate(float deltaTime) + { + if (!m_CoLoadData.IsRunning) + { + //GotoStage(EGamePhase.Dojo); + } + } + + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Launch.cs.meta b/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Launch.cs.meta new file mode 100644 index 0000000..aa30aaa --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Launch.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 140927b1845ec1846814b71c4e114ad8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Main.cs b/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Main.cs new file mode 100644 index 0000000..8b8b321 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Main.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WK +{ + + /// <summary> + /// 主界面 + /// </summary> + public class GamePhase_Main : GamePhaseBase + { + + + + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Main.cs.meta b/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Main.cs.meta new file mode 100644 index 0000000..5add0f2 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Phase/GameStage_Main.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 102ce3dadc4654b44838f17cf9415384 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Phase/GameStages.cs b/WorldlineKeepers/Assets/Scripts/Phase/GameStages.cs new file mode 100644 index 0000000..fd12758 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Phase/GameStages.cs @@ -0,0 +1,19 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WK +{ + + public enum EGamePhase + { + Launch = 0, // splash screen + //Login = 1, // + Main = 2, // 主界面 + Battle = 3, // 战斗场景 + Dojo = 4, // 训练道场 + + Num + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Phase/GameStages.cs.meta b/WorldlineKeepers/Assets/Scripts/Phase/GameStages.cs.meta new file mode 100644 index 0000000..ea2c442 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Phase/GameStages.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a4b80a072bd95b643a7c2295281f3174 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |