diff options
Diffstat (limited to 'Assets/Scripts/Unit/Component')
-rw-r--r-- | Assets/Scripts/Unit/Component/UnitAnimation.cs | 18 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Component/UnitAnimation.cs.meta | 11 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Component/UnitCollider.cs | 19 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Component/UnitCollider.cs.meta | 11 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Component/UnitComponent.cs | 28 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Component/UnitComponent.cs.meta | 11 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Component/UnitRender.cs | 19 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Component/UnitRender.cs.meta | 11 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Component/UnitSkill.cs | 12 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Component/UnitSkill.cs.meta | 11 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Component/UnitState.cs | 115 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Component/UnitState.cs.meta | 11 |
12 files changed, 277 insertions, 0 deletions
diff --git a/Assets/Scripts/Unit/Component/UnitAnimation.cs b/Assets/Scripts/Unit/Component/UnitAnimation.cs new file mode 100644 index 00000000..ac04148d --- /dev/null +++ b/Assets/Scripts/Unit/Component/UnitAnimation.cs @@ -0,0 +1,18 @@ +using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+// 播放动画,执行帧事件
+[DisallowMultipleComponent]
+public class UnitAnimation : UnitComponent
+{
+ private Animator m_Animator;
+
+ private TimelineEvent m_Timeline;
+
+ public void Play()
+ {
+
+ }
+
+}
diff --git a/Assets/Scripts/Unit/Component/UnitAnimation.cs.meta b/Assets/Scripts/Unit/Component/UnitAnimation.cs.meta new file mode 100644 index 00000000..75ce33fe --- /dev/null +++ b/Assets/Scripts/Unit/Component/UnitAnimation.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4af875f33239ebf409f3e4954c0ee0cb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Unit/Component/UnitCollider.cs b/Assets/Scripts/Unit/Component/UnitCollider.cs new file mode 100644 index 00000000..46b79f26 --- /dev/null +++ b/Assets/Scripts/Unit/Component/UnitCollider.cs @@ -0,0 +1,19 @@ +using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+[DisallowMultipleComponent]
+public class UnitCollider : MonoBehaviour
+{
+ // Start is called before the first frame update
+ void Start()
+ {
+
+ }
+
+ // Update is called once per frame
+ void Update()
+ {
+
+ }
+}
diff --git a/Assets/Scripts/Unit/Component/UnitCollider.cs.meta b/Assets/Scripts/Unit/Component/UnitCollider.cs.meta new file mode 100644 index 00000000..fa98ddc9 --- /dev/null +++ b/Assets/Scripts/Unit/Component/UnitCollider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1a4f3dea33ad590458ab820a086a8be3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Unit/Component/UnitComponent.cs b/Assets/Scripts/Unit/Component/UnitComponent.cs new file mode 100644 index 00000000..28f49eda --- /dev/null +++ b/Assets/Scripts/Unit/Component/UnitComponent.cs @@ -0,0 +1,28 @@ +using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class UnitComponent : MonoBehaviour
+{
+ protected UnitController m_Owner;
+
+ public bool IsAlive
+ {
+ get
+ {
+ return m_Owner != null;
+ }
+ }
+
+ public virtual void Initialize()
+ {
+ m_Owner = GetComponent<UnitController>();
+ }
+
+ public virtual void Release()
+ {
+ m_Owner = null;
+ StopAllCoroutines();
+ }
+
+}
diff --git a/Assets/Scripts/Unit/Component/UnitComponent.cs.meta b/Assets/Scripts/Unit/Component/UnitComponent.cs.meta new file mode 100644 index 00000000..2641a06f --- /dev/null +++ b/Assets/Scripts/Unit/Component/UnitComponent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4c2f1fe7707e5364aab4ddc6a962bb6e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Unit/Component/UnitRender.cs b/Assets/Scripts/Unit/Component/UnitRender.cs new file mode 100644 index 00000000..cf308bab --- /dev/null +++ b/Assets/Scripts/Unit/Component/UnitRender.cs @@ -0,0 +1,19 @@ +using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+[DisallowMultipleComponent]
+public class UnitRender : MonoBehaviour
+{
+ // Start is called before the first frame update
+ void Start()
+ {
+
+ }
+
+ // Update is called once per frame
+ void Update()
+ {
+
+ }
+}
diff --git a/Assets/Scripts/Unit/Component/UnitRender.cs.meta b/Assets/Scripts/Unit/Component/UnitRender.cs.meta new file mode 100644 index 00000000..98aaba31 --- /dev/null +++ b/Assets/Scripts/Unit/Component/UnitRender.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8a5b6a015d074924b8a247980bb04693 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Unit/Component/UnitSkill.cs b/Assets/Scripts/Unit/Component/UnitSkill.cs new file mode 100644 index 00000000..6a6a3a0e --- /dev/null +++ b/Assets/Scripts/Unit/Component/UnitSkill.cs @@ -0,0 +1,12 @@ +using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+// 技能逻辑
+[DisallowMultipleComponent]
+
+public class UnitSkill : UnitComponent
+{
+
+
+}
diff --git a/Assets/Scripts/Unit/Component/UnitSkill.cs.meta b/Assets/Scripts/Unit/Component/UnitSkill.cs.meta new file mode 100644 index 00000000..882bb398 --- /dev/null +++ b/Assets/Scripts/Unit/Component/UnitSkill.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d55937c5d88bcc84986d79cd2ec0468b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Unit/Component/UnitState.cs b/Assets/Scripts/Unit/Component/UnitState.cs new file mode 100644 index 00000000..d5b91cec --- /dev/null +++ b/Assets/Scripts/Unit/Component/UnitState.cs @@ -0,0 +1,115 @@ +using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+// 角色状态机
+[DisallowMultipleComponent]
+public class UnitState : UnitComponent
+{
+ public enum EUnitState
+ {
+ Idle = 1,
+ Move = 1 << 2,
+ Spawn = 1 << 3,
+ Die = 1 << 4,
+ Dead = 1 << 5,
+ Skill = 1 << 6,
+ //
+ HitAir = 1 << 7,
+ HitAirHit = 1 << 8,
+ Knockdown = 1 << 9,
+ //
+ HitGuard = 1 << 10,
+ //
+ Walk = 1 << 11,
+ }
+
+ [SerializeField] private EUnitState m_State;
+ public EUnitState CurrentState { get { return m_State; } }
+
+ private delegate void ExitStateHandler(EUnitState nextState);
+ private delegate void EnterStateHandler(EUnitState prevState);
+
+ private Dictionary<EUnitState, ExitStateHandler> m_ExitStateHandlerDic = new Dictionary<EUnitState, ExitStateHandler>();
+ private Dictionary<EUnitState, EnterStateHandler> m_EnterStateHandlerDic = new Dictionary<EUnitState, EnterStateHandler>();
+
+ #region state param
+ public struct IdleParam {}
+
+ public struct MoveParam
+ {
+ }
+
+ public struct SkillParam
+ {
+
+ }
+ #endregion
+
+ void InitState()
+ {
+ m_EnterStateHandlerDic.Add(EUnitState.Idle, OnIdleEnter);
+ m_EnterStateHandlerDic.Add(EUnitState.Move, OnMoveEnter);
+
+ m_ExitStateHandlerDic.Add(EUnitState.Idle, OnIdleExit);
+ m_ExitStateHandlerDic.Add(EUnitState.Move, OnMoveExit);
+ }
+
+ public void ChangeState<T>(EUnitState nextState, T param, bool bForce = false)
+ {
+ if (!IsChange(nextState, bForce))
+ return;
+
+ StopAllCoroutines();
+
+ m_ExitStateHandlerDic[m_State](nextState);
+
+ EUnitState prevState = m_State;
+ m_State = nextState;
+ m_EnterStateHandlerDic[m_State](prevState);
+
+ StartCoroutine(m_State.ToString(), param);
+ }
+
+ bool IsChange(EUnitState newState, bool bForce)
+ {
+ if (newState != m_State || bForce)
+ return true;
+ return false;
+ }
+
+ #region Idle
+ void OnIdleEnter(EUnitState prevState)
+ {
+
+ }
+ IEnumerator Idle(IdleParam param)
+ {
+ m_Owner.unitAnimation.Play();
+ yield return null;
+ }
+ void OnIdleExit(EUnitState nextState)
+ {
+
+ }
+ #endregion
+
+ #region Move
+ void OnMoveEnter(EUnitState prevState)
+ {
+
+ }
+
+ IEnumerator Move(MoveParam param)
+ {
+ yield return null;
+ }
+
+ void OnMoveExit(EUnitState nextState)
+ {
+
+ }
+
+ #endregion
+
+}
diff --git a/Assets/Scripts/Unit/Component/UnitState.cs.meta b/Assets/Scripts/Unit/Component/UnitState.cs.meta new file mode 100644 index 00000000..781994dc --- /dev/null +++ b/Assets/Scripts/Unit/Component/UnitState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e5c9c1db07e3c734ebf185f14cc7356a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |