summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Test 1
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-08-02 08:35:26 +0800
committerchai <chaifix@163.com>2021-08-02 08:35:26 +0800
commitce73a13f28e5a947df8f1f87f1f1be20010952ec (patch)
tree2c430bcd93f2c09bd35340def7c556c7294d6b5d /Assets/Scripts/Test 1
parent81acfeb9a1d88075899d9c21064330915caa59a4 (diff)
* 测试
Diffstat (limited to 'Assets/Scripts/Test 1')
-rw-r--r--Assets/Scripts/Test 1/TestErika.cs60
-rw-r--r--Assets/Scripts/Test 1/TestErika.cs.meta11
-rw-r--r--Assets/Scripts/Test 1/TestInput.cs28
-rw-r--r--Assets/Scripts/Test 1/TestInput.cs.meta11
4 files changed, 110 insertions, 0 deletions
diff --git a/Assets/Scripts/Test 1/TestErika.cs b/Assets/Scripts/Test 1/TestErika.cs
new file mode 100644
index 00000000..c76f09e0
--- /dev/null
+++ b/Assets/Scripts/Test 1/TestErika.cs
@@ -0,0 +1,60 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class TestErika : MonoBehaviour
+{
+ public UnitActionData actionData; // 动作配置
+
+ public GameObject unitControllerPrefab;
+
+ public GameObject unitPrefab;
+
+ public RuntimeAnimatorController animController;
+
+ public string unitFolder;
+
+ [HideInInspector]
+ public GameObject unit;
+
+ [HideInInspector]
+ public GameObject unitController;
+
+ private void Awake()
+ {
+ unitController = GameObject.Instantiate(unitControllerPrefab);
+ unitController.transform.position = Vector3.zero;
+ unitController.transform.rotation = Quaternion.identity;
+ unit = GameObject.Instantiate(unitPrefab);
+ unit.transform.SetParent(unitController.transform);
+
+ Init();
+
+ }
+
+ private void Init()
+ {
+ UnitController unitCtr = unitController.GetOrAddComponent<UnitController>();
+ unitCtr.Initialize(unit);
+
+ UnitRootMotion unitRootMotion = unitCtr.unitRootMotion;
+
+ RootMotionProxy rootMotionProxy = unit.GetOrAddComponent<RootMotionProxy>();
+
+ Animator animator = unit.GetComponent<Animator>();
+ AnimatorOverrideController animCtr = new AnimatorOverrideController(animController);
+ animCtr.name = unitPrefab.name + " Override Controller";
+ animator.runtimeAnimatorController = animCtr;
+
+ foreach(var action in actionData.actions)
+ {
+ animCtr[action.Key.ToString()] = action.Value;
+ }
+
+ unitCtr.unitState.ChangeState(UnitState.EUnitState.Idle, new UnitState.IdleParam());
+
+ //unitCtr.unitRootMotion.SetUpRootMotion(unitFolder, actionData);
+
+ }
+
+}
diff --git a/Assets/Scripts/Test 1/TestErika.cs.meta b/Assets/Scripts/Test 1/TestErika.cs.meta
new file mode 100644
index 00000000..53aeb6eb
--- /dev/null
+++ b/Assets/Scripts/Test 1/TestErika.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 7e8dd0fc77853444395ec5d0f8acdc25
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Test 1/TestInput.cs b/Assets/Scripts/Test 1/TestInput.cs
new file mode 100644
index 00000000..ed526f0d
--- /dev/null
+++ b/Assets/Scripts/Test 1/TestInput.cs
@@ -0,0 +1,28 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class TestInput : MonoBehaviour
+{
+
+ private void Update()
+ {
+ if(Input.GetKeyDown("j"))
+ {
+ InputManager.Instance.OnAttack();
+ }
+ if(Input.GetKeyDown("space"))
+ {
+ InputManager.Instance.OnJump();
+ }
+ if(Input.GetKeyDown("d"))
+ {
+ InputManager.Instance.OnMoveRight();
+ }
+ if(Input.GetKeyDown("a"))
+ {
+ InputManager.Instance.OnMoveLeft();
+ }
+ }
+
+}
diff --git a/Assets/Scripts/Test 1/TestInput.cs.meta b/Assets/Scripts/Test 1/TestInput.cs.meta
new file mode 100644
index 00000000..aeb1587e
--- /dev/null
+++ b/Assets/Scripts/Test 1/TestInput.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 78d3bc54e34721e468d0541fb5c0c839
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: