summaryrefslogtreecommitdiff
path: root/WorldlineKeepers/Assets/Tools/CharacterEditor/TestCharacter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'WorldlineKeepers/Assets/Tools/CharacterEditor/TestCharacter.cs')
-rw-r--r--WorldlineKeepers/Assets/Tools/CharacterEditor/TestCharacter.cs67
1 files changed, 67 insertions, 0 deletions
diff --git a/WorldlineKeepers/Assets/Tools/CharacterEditor/TestCharacter.cs b/WorldlineKeepers/Assets/Tools/CharacterEditor/TestCharacter.cs
new file mode 100644
index 0000000..56ca554
--- /dev/null
+++ b/WorldlineKeepers/Assets/Tools/CharacterEditor/TestCharacter.cs
@@ -0,0 +1,67 @@
+using LitJson;
+using MovementEffects;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Data;
+using System.IO;
+using UnityEditor.Compilation;
+using UnityEngine;
+using UnityEngine.UI;
+using WK;
+using WK.Data;
+
+public class TestCharacter : MonoBehaviour
+{
+ public Transform m_RootStage;
+ public string m_TestingScene = "Assets/Bundle/stages/stage_arena/stage.json";
+
+ public InputField m_CharacterJson;
+ public Button m_BtnCreate;
+
+ private PlayerController player;
+
+ private void Awake()
+ {
+ Timing.Instance.StartCoroutine(CoSetup());
+
+ m_BtnCreate.onClick.AddListener(OnClickCreate);
+ }
+
+ IEnumerator<float> CoSetup()
+ {
+ var handle = DataManager.Instance.AsyncLoadAll();
+ while (handle.IsRunning) yield return Timing.WaitForSeconds(0.1f);
+ PhysicsManager.Instance.Initialize();
+ yield return Timing.WaitForSeconds(0.1f);
+ BuildStage();
+ }
+
+ void BuildStage()
+ {
+ string file = m_TestingScene;
+ string content = File.ReadAllText(file);
+ StageMetadata metadata = JsonMapper.ToObject<StageMetadata>(content);
+ StageBuilder.Instance.AsyncBuildStage(metadata, m_RootStage);
+ }
+
+ void OnClickCreate()
+ {
+ string json = m_CharacterJson.text;
+ string content = File.ReadAllText(json);
+ CharacterMetadata meta = JsonMapper.ToObject<CharacterMetadata>(content);
+ if(meta != null)
+ {
+ CharacterBuilder builder = CommonFunction.CreateInstance(meta.builder) as CharacterBuilder;
+ if (builder == null)
+ return;
+ player = builder.Build(meta);
+ }
+ }
+
+ private void Update()
+ {
+ player?.OnUpdate();
+ }
+
+}