summaryrefslogtreecommitdiff
path: root/WorldlineKeepers/Assets/Scripts
diff options
context:
space:
mode:
Diffstat (limited to 'WorldlineKeepers/Assets/Scripts')
-rw-r--r--WorldlineKeepers/Assets/Scripts/Buffs/Buff.cs2
-rw-r--r--WorldlineKeepers/Assets/Scripts/Buffs/BuffBehaviour.cs (renamed from WorldlineKeepers/Assets/Scripts/Buffs/BuffEfectorBase.cs)2
-rw-r--r--WorldlineKeepers/Assets/Scripts/Buffs/BuffBehaviour.cs.meta (renamed from WorldlineKeepers/Assets/Scripts/Buffs/BuffEfectorBase.cs.meta)0
-rw-r--r--WorldlineKeepers/Assets/Scripts/Common/Statemachine.cs254
-rw-r--r--WorldlineKeepers/Assets/Scripts/Common/Statemachine.cs.meta11
-rw-r--r--WorldlineKeepers/Assets/Scripts/Data/DataManager.cs13
-rw-r--r--WorldlineKeepers/Assets/Scripts/EntityBase.cs2
-rw-r--r--WorldlineKeepers/Assets/Scripts/Items/Inventory.cs15
-rw-r--r--WorldlineKeepers/Assets/Scripts/Items/Inventory.cs.meta11
-rw-r--r--WorldlineKeepers/Assets/Scripts/Items/Item.cs21
-rw-r--r--WorldlineKeepers/Assets/Scripts/Items/Item.cs.meta11
-rw-r--r--WorldlineKeepers/Assets/Scripts/Items/ItemBehaviour.cs27
-rw-r--r--WorldlineKeepers/Assets/Scripts/Items/ItemBehaviour.cs.meta11
-rw-r--r--WorldlineKeepers/Assets/Scripts/Items/ItemDaggerBehaviour.cs15
-rw-r--r--WorldlineKeepers/Assets/Scripts/Items/ItemDaggerBehaviour.cs.meta11
-rw-r--r--WorldlineKeepers/Assets/Scripts/Items/ItemHellbellBehaviour.cs15
-rw-r--r--WorldlineKeepers/Assets/Scripts/Items/ItemHellbellBehaviour.cs.meta11
-rw-r--r--WorldlineKeepers/Assets/Scripts/Items/ItemMetadata.cs23
-rw-r--r--WorldlineKeepers/Assets/Scripts/Items/ItemMetadata.cs.meta11
-rw-r--r--WorldlineKeepers/Assets/Scripts/StaticDefine.cs2
-rw-r--r--WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsBase.cs28
-rw-r--r--WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsMetadata.cs2
-rw-r--r--WorldlineKeepers/Assets/Scripts/Tests/TestEvent.cs40
-rw-r--r--WorldlineKeepers/Assets/Scripts/Tests/TestEvent.cs.meta11
-rw-r--r--WorldlineKeepers/Assets/Scripts/Tools.meta8
-rw-r--r--WorldlineKeepers/Assets/Scripts/Tools/GlobalEventManager.cs97
-rw-r--r--WorldlineKeepers/Assets/Scripts/Tools/GlobalEventManager.cs.meta11
-rw-r--r--WorldlineKeepers/Assets/Scripts/Tools/NotificationCenter.cs167
-rw-r--r--WorldlineKeepers/Assets/Scripts/Tools/NotificationCenter.cs.meta11
-rw-r--r--WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterBehaviour.cs (renamed from WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterController.cs)0
-rw-r--r--WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterBehaviour.cs.meta (renamed from WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterController.cs.meta)0
-rw-r--r--WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterMetadata.cs23
-rw-r--r--WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterMetadata.cs.meta11
-rw-r--r--WorldlineKeepers/Assets/Scripts/Unit/Characters/PlayerController.cs6
-rw-r--r--WorldlineKeepers/Assets/Scripts/Unit/Characters/Ronin/RoninBehaviour.cs3
-rw-r--r--WorldlineKeepers/Assets/Scripts/Unit/Enemies/SpiritScript.cs4
-rw-r--r--WorldlineKeepers/Assets/Scripts/Unit/UnitManager.cs15
-rw-r--r--WorldlineKeepers/Assets/Scripts/Unit/UnitManager.cs.meta11
38 files changed, 900 insertions, 16 deletions
diff --git a/WorldlineKeepers/Assets/Scripts/Buffs/Buff.cs b/WorldlineKeepers/Assets/Scripts/Buffs/Buff.cs
index 8f65991..1c6ae5a 100644
--- a/WorldlineKeepers/Assets/Scripts/Buffs/Buff.cs
+++ b/WorldlineKeepers/Assets/Scripts/Buffs/Buff.cs
@@ -13,7 +13,7 @@ public abstract class Buff
public BuffMetadata metadata;
// buff效果器
- public BuffEfectorBase effector;
+ public BuffBehaviour effector;
public string uid
{
diff --git a/WorldlineKeepers/Assets/Scripts/Buffs/BuffEfectorBase.cs b/WorldlineKeepers/Assets/Scripts/Buffs/BuffBehaviour.cs
index b90beb8..0a0559f 100644
--- a/WorldlineKeepers/Assets/Scripts/Buffs/BuffEfectorBase.cs
+++ b/WorldlineKeepers/Assets/Scripts/Buffs/BuffBehaviour.cs
@@ -2,7 +2,7 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
-public class BuffEfectorBase
+public class BuffBehaviour
{
private CharacterBase m_Character;
diff --git a/WorldlineKeepers/Assets/Scripts/Buffs/BuffEfectorBase.cs.meta b/WorldlineKeepers/Assets/Scripts/Buffs/BuffBehaviour.cs.meta
index a433744..a433744 100644
--- a/WorldlineKeepers/Assets/Scripts/Buffs/BuffEfectorBase.cs.meta
+++ b/WorldlineKeepers/Assets/Scripts/Buffs/BuffBehaviour.cs.meta
diff --git a/WorldlineKeepers/Assets/Scripts/Common/Statemachine.cs b/WorldlineKeepers/Assets/Scripts/Common/Statemachine.cs
new file mode 100644
index 0000000..ffa33a2
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Common/Statemachine.cs
@@ -0,0 +1,254 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using MEC;
+
+namespace WK
+{
+
+ /// <summary>
+ /// 公共状态机
+ /// </summary>
+ public class StateMachine
+ {
+
+ public delegate void LoadStateComplete();
+
+ public abstract class State
+ {
+ public StateMachine owner;
+ public int stateID;
+ public abstract IEnumerator<float> OnStart();
+ public abstract IEnumerator<float> OnEnd();
+ public abstract void OnUpdate(float deltaTime);
+ }
+
+ public const int NULL_STATE_ID = -1;
+ public const float COROUINT_DELTIME = 0.01f;
+
+ private Dictionary<int/*stateID*/, State> allState = new Dictionary<int, State>();
+ private int curStateID = NULL_STATE_ID;
+ private int stateIDDistributor = 0;
+ // 在状态切换完成前为false,不能进行update
+ private bool isUpdateActive = false;
+
+ /// <summary>
+ /// 添加状态,并返回在状态机中的ID
+ /// </summary>
+ /// <param name="newState"></param>
+ /// <returns></returns>
+ public int RegisterState(State newState)
+ {
+ if (newState == null)
+ return NULL_STATE_ID;
+ if (stateIDDistributor + 1 >= int.MaxValue)
+ {
+ Debug.LogError("状态机添加状态失败,此状态机中添加的状态过多");
+ return NULL_STATE_ID;
+ }
+ ++stateIDDistributor;
+ if (!allState.ContainsKey(stateIDDistributor))
+ {
+ newState.owner = this;
+ newState.stateID = stateIDDistributor;
+ allState.Add(stateIDDistributor, newState);
+ return stateIDDistributor;
+ }
+ Debug.LogError("状态机添加状态失败,状态已经存在");
+ return NULL_STATE_ID;
+ }
+
+ public bool RemoveState(State state)
+ {
+ if (state != null)
+ {
+ return RemoveState(state.stateID);
+ }
+ Debug.LogError("状态机删除状态失败,状态为空");
+ return false;
+ }
+
+ public bool RemoveState(int stateID)
+ {
+ if (allState.ContainsKey(stateID))
+ {
+ allState.Remove(stateID);
+ return true;
+ }
+ Debug.LogError("状态机删除状态失败,该状态不存在,stateID = " + stateID);
+ return false;
+ }
+
+ /// <summary>
+ /// 开始运行状态机
+ /// </summary>
+ /// <param name="stateID"></param>
+ /// <returns></returns>
+ public bool Start(int stateID)
+ {
+ if (!HasBegin())
+ {
+ ForceGotoState(stateID);
+ return true;
+ }
+ return false;
+ }
+
+ /// <summary>
+ /// 结束状态机
+ /// </summary>
+ /// <returns></returns>
+ public bool Stop()
+ {
+ if (HasBegin())
+ {
+ ForceGotoState(NULL_STATE_ID);
+ return true;
+ }
+ return false;
+ }
+
+ /// <summary>
+ /// 更新状态机
+ /// </summary>
+ /// <param name="deltaTime"></param>
+ public void Update(float deltaTime)
+ {
+ if (HasBegin())
+ {
+ UpdateState(curStateID, deltaTime);
+ }
+ }
+
+ public bool GotoState(int stateID, bool skipStartFunc = false, bool bForce = false, LoadStateComplete callback = null)
+ {
+ if (HasBegin())
+ return ForceGotoState(stateID, skipStartFunc, bForce, callback);
+ return false;
+ }
+
+ public bool ForceGotoState(int nextStateID, bool skipStartFunc = false, bool bForce = false, LoadStateComplete callback = null)
+ {
+ if (curStateID != nextStateID || bForce)
+ {
+ Timing.Instance.RunCoroutineOnInstance(AyncForceGotoState(nextStateID, skipStartFunc, callback));
+ return true;
+ }
+ if (callback != null)
+ callback();
+ return false;
+ }
+
+ /// <summary>
+ /// 异步的切换到某个状态
+ /// </summary>
+ /// <returns></returns>
+ private IEnumerator<float> AyncForceGotoState(int nextStateID, bool skipStartFunc = false, LoadStateComplete callback = null)
+ {
+ isUpdateActive = false;
+ CoroutineHandle handle = Timing.RunCoroutine(EndState(curStateID));
+ while (handle.IsValid)
+ {
+ yield return Timing.WaitForSeconds(COROUINT_DELTIME);
+ }
+ curStateID = nextStateID;
+ if (!skipStartFunc)
+ {
+ CoroutineHandle handle2 = Timing.RunCoroutine(StartState(curStateID));
+ while (handle2.IsValid)
+ {
+ yield return Timing.WaitForSeconds(COROUINT_DELTIME);
+ }
+ }
+ if (callback != null)
+ callback();
+ isUpdateActive = true;
+ }
+
+ public int GetCurStateID()
+ {
+ return curStateID;
+ }
+
+ public bool HasBegin()
+ {
+ if (curStateID != NULL_STATE_ID && allState.ContainsKey(curStateID))
+ return true;
+ return false;
+ }
+
+ public bool IsInState(int stateID)
+ {
+ if (HasBegin())
+ {
+ return curStateID == stateID;
+ }
+ return false;
+ }
+
+ public State GetState(int stateID)
+ {
+ if (allState.ContainsKey(stateID))
+ {
+ return allState[stateID];
+ }
+ return null;
+ }
+
+ public void Clean()
+ {
+ allState.Clear();
+ curStateID = NULL_STATE_ID;
+ stateIDDistributor = 0;
+ }
+
+ public void ResetCurState()
+ {
+ curStateID = NULL_STATE_ID;
+ }
+
+ private IEnumerator<float> StartState(int stateID)
+ {
+ if (HasBegin())
+ {
+ State state = GetState(stateID);
+ if (state != null)
+ {
+ CoroutineHandle handle = Timing.RunCoroutine(state.OnStart());
+ while (handle.IsValid)
+ {
+ yield return Timing.WaitForSeconds(COROUINT_DELTIME);
+ }
+ }
+ }
+ }
+
+ private IEnumerator<float> EndState(int stateID)
+ {
+ if (HasBegin())
+ {
+ State state = GetState(stateID);
+ if (state != null)
+ {
+ CoroutineHandle handle = Timing.RunCoroutine(state.OnEnd());
+ while (handle.IsValid)
+ {
+ yield return Timing.WaitForSeconds(COROUINT_DELTIME);
+ }
+ }
+ }
+ }
+
+ private void UpdateState(int stateID, float deltaTime)
+ {
+ if (HasBegin())
+ {
+ State state = GetState(stateID);
+ if (state != null)
+ state.OnUpdate(deltaTime);
+ }
+ }
+
+ }
+
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Common/Statemachine.cs.meta b/WorldlineKeepers/Assets/Scripts/Common/Statemachine.cs.meta
new file mode 100644
index 0000000..e2b8d49
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Common/Statemachine.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: c43b283f086a24140b0e6e6e0e9efbef
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Data/DataManager.cs b/WorldlineKeepers/Assets/Scripts/Data/DataManager.cs
index a3d1257..3bb9ef2 100644
--- a/WorldlineKeepers/Assets/Scripts/Data/DataManager.cs
+++ b/WorldlineKeepers/Assets/Scripts/Data/DataManager.cs
@@ -1,3 +1,4 @@
+using LitJson;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
@@ -11,6 +12,7 @@ namespace WK.Data
private Dictionary<string/*uid*/, CharacterStatsMetadata> m_CharacterStatsMetadata = new Dictionary<string, CharacterStatsMetadata>();
private Dictionary<string/*uid*/, BuffMetadata> m_BuffMetadata = new Dictionary<string, BuffMetadata>();
+ private Dictionary<string/*uid*/, CharacterMetadata> m_CharacterMetadata = new Dictionary<string, CharacterMetadata>();
public CharacterStatsMetadata GetCharacterStats(string uid)
{
@@ -35,6 +37,7 @@ namespace WK.Data
public void Load()
{
LoadDefaultStats();
+ LoadDefaultCharacters();
}
private void LoadDefaultStats()
@@ -47,6 +50,16 @@ namespace WK.Data
}
}
+ private void LoadDefaultCharacters()
+ {
+ TextAsset text = ResourceManager.Instance.LoadAsset<TextAsset>(StaticDefine.RoninPath);
+ CharacterMetadata metadata = JsonMapper.ToObject<CharacterMetadata>(text.text);
+ if(metadata != null)
+ {
+ m_CharacterMetadata.Add(metadata.uid, metadata);
+ }
+ }
+
}
} \ No newline at end of file
diff --git a/WorldlineKeepers/Assets/Scripts/EntityBase.cs b/WorldlineKeepers/Assets/Scripts/EntityBase.cs
index 3470d3c..f894d20 100644
--- a/WorldlineKeepers/Assets/Scripts/EntityBase.cs
+++ b/WorldlineKeepers/Assets/Scripts/EntityBase.cs
@@ -6,7 +6,7 @@ public class EntityBase : MonoBehaviour
{
public SpriteRenderer m_Shadow;
- private SpriteRenderer m_SpriteRenderer;
+ protected SpriteRenderer m_SpriteRenderer;
protected virtual void Awake()
{
diff --git a/WorldlineKeepers/Assets/Scripts/Items/Inventory.cs b/WorldlineKeepers/Assets/Scripts/Items/Inventory.cs
new file mode 100644
index 0000000..f620a93
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Items/Inventory.cs
@@ -0,0 +1,15 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace WK.Items
+{
+
+ public class Inventory
+ {
+
+
+
+ }
+
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Items/Inventory.cs.meta b/WorldlineKeepers/Assets/Scripts/Items/Inventory.cs.meta
new file mode 100644
index 0000000..a6a021f
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Items/Inventory.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 0fd1d1f499057e44097943c0eb053781
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Items/Item.cs b/WorldlineKeepers/Assets/Scripts/Items/Item.cs
new file mode 100644
index 0000000..bcffc5b
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Items/Item.cs
@@ -0,0 +1,21 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using WK.Data;
+using WK.Items;
+
+namespace Wk.Items
+{
+
+ public class Item
+ {
+ private ItemMetadata m_Metadata;
+ public ItemMetadata metadata { get { return m_Metadata; } }
+
+ private ItemBehaviour m_Behaviour;
+ public ItemBehaviour behaviour { get { return m_Behaviour; } }
+
+
+ }
+
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Items/Item.cs.meta b/WorldlineKeepers/Assets/Scripts/Items/Item.cs.meta
new file mode 100644
index 0000000..828b300
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Items/Item.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d7ae8ebc7348cf647a6cf90a67bd1711
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Items/ItemBehaviour.cs b/WorldlineKeepers/Assets/Scripts/Items/ItemBehaviour.cs
new file mode 100644
index 0000000..520946a
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Items/ItemBehaviour.cs
@@ -0,0 +1,27 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace WK.Items
+{
+
+ public class ItemBehaviour
+ {
+
+ public virtual void OnEquiped()
+ {
+
+ }
+
+ public virtual void OnUnEquiped()
+ {
+
+ }
+
+ public virtual void OnStack()
+ {
+
+ }
+ }
+
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Items/ItemBehaviour.cs.meta b/WorldlineKeepers/Assets/Scripts/Items/ItemBehaviour.cs.meta
new file mode 100644
index 0000000..1acab27
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Items/ItemBehaviour.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 6ecedcd123438614db9ea58933287d13
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Items/ItemDaggerBehaviour.cs b/WorldlineKeepers/Assets/Scripts/Items/ItemDaggerBehaviour.cs
new file mode 100644
index 0000000..1e0dfe6
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Items/ItemDaggerBehaviour.cs
@@ -0,0 +1,15 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace WK.Items
+{
+
+ public class ItemDaggerBehaviour : ItemBehaviour
+ {
+
+
+
+ }
+
+} \ No newline at end of file
diff --git a/WorldlineKeepers/Assets/Scripts/Items/ItemDaggerBehaviour.cs.meta b/WorldlineKeepers/Assets/Scripts/Items/ItemDaggerBehaviour.cs.meta
new file mode 100644
index 0000000..409141f
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Items/ItemDaggerBehaviour.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 759db356bc563824882ce1b4ee8fd879
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Items/ItemHellbellBehaviour.cs b/WorldlineKeepers/Assets/Scripts/Items/ItemHellbellBehaviour.cs
new file mode 100644
index 0000000..1008eed
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Items/ItemHellbellBehaviour.cs
@@ -0,0 +1,15 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace WK.Items
+{
+
+ public class ItemHellbellBehaviour : ItemBehaviour
+ {
+
+
+
+ }
+
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Items/ItemHellbellBehaviour.cs.meta b/WorldlineKeepers/Assets/Scripts/Items/ItemHellbellBehaviour.cs.meta
new file mode 100644
index 0000000..341e7c0
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Items/ItemHellbellBehaviour.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1156ea03b49c6264692b0552676e606c
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Items/ItemMetadata.cs b/WorldlineKeepers/Assets/Scripts/Items/ItemMetadata.cs
new file mode 100644
index 0000000..e77f494
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Items/ItemMetadata.cs
@@ -0,0 +1,23 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace WK.Data
+{
+
+ public class ItemMetadata
+ {
+
+ public string uid;
+
+ public string name_key;
+
+ public string desc_key;
+
+ public string icon_path;
+
+ public string extra_data;
+
+ }
+
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Items/ItemMetadata.cs.meta b/WorldlineKeepers/Assets/Scripts/Items/ItemMetadata.cs.meta
new file mode 100644
index 0000000..07ede60
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Items/ItemMetadata.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 2f5b94a115aa35a4c84083a3743c2639
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/StaticDefine.cs b/WorldlineKeepers/Assets/Scripts/StaticDefine.cs
index 53219b5..3f62e8c 100644
--- a/WorldlineKeepers/Assets/Scripts/StaticDefine.cs
+++ b/WorldlineKeepers/Assets/Scripts/StaticDefine.cs
@@ -10,6 +10,8 @@ namespace WK
public static string StatsFilePath = "metadata/default_stats.csv";
public static string BuffFilePath = "metadata/default_buffs.csv";
+ public static string RoninPath = "characters/ronin/ronin.json";
+
}
} \ No newline at end of file
diff --git a/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsBase.cs b/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsBase.cs
index b4869cb..8dbb161 100644
--- a/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsBase.cs
+++ b/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsBase.cs
@@ -7,24 +7,24 @@ using WK.Data;
namespace WK
{
- [System.Runtime.InteropServices.StructLayout(LayoutKind.Explicit)]
+ [StructLayout(LayoutKind.Explicit)]
public struct CharacterStatsValue
{
- [System.Runtime.InteropServices.FieldOffset(0)]
+ [FieldOffset(0)]
public int i;
- [System.Runtime.InteropServices.FieldOffset(0)]
+ [FieldOffset(0)]
public float f;
- [System.Runtime.InteropServices.FieldOffset(0)]
+ [FieldOffset(0)]
public bool boolean;
- [System.Runtime.InteropServices.FieldOffset(0)]
+ [FieldOffset(0)]
public char c;
- [System.Runtime.InteropServices.FieldOffset(0)]
+ [FieldOffset(0)]
public Vector2 v2;
- [System.Runtime.InteropServices.FieldOffset(0)]
+ [FieldOffset(0)]
public Vector3 v3;
- [System.Runtime.InteropServices.FieldOffset(0)]
+ [FieldOffset(0)]
public Vector4 v4;
- [System.Runtime.InteropServices.FieldOffset(0)]
+ [FieldOffset(0)]
public Color color;
}
@@ -44,7 +44,15 @@ namespace WK
/// 当前属性值
/// </summary>
public CharacterStatsValue value;
-
+
+ public ref int intValue => ref value.i;
+ public ref bool boolValue => ref value.boolean;
+ public ref float floatValue => ref value.f;
+ public ref char chartValue => ref value.c;
+ public ref Vector2 Vector2Value => ref value.v2;
+ public ref Vector3 Vector3Value => ref value.v3;
+ public ref Vector4 Vector4Value => ref value.v4;
+
public string uid
{
get
diff --git a/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsMetadata.cs b/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsMetadata.cs
index c240ca1..dbb0942 100644
--- a/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsMetadata.cs
+++ b/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsMetadata.cs
@@ -16,6 +16,8 @@ namespace WK.Data
public string type;
+ public string behaviour;
+
// 暂留数据
public string extra_data;
}
diff --git a/WorldlineKeepers/Assets/Scripts/Tests/TestEvent.cs b/WorldlineKeepers/Assets/Scripts/Tests/TestEvent.cs
new file mode 100644
index 0000000..c6e9bba
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Tests/TestEvent.cs
@@ -0,0 +1,40 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using WK;
+
+public class TestEvent : MonoBehaviour
+{
+ #region 搴忓垪鍖
+
+ #endregion
+
+ #region 鍏叡瀛楁
+
+ #endregion
+
+ #region 绉佹湁瀛楁
+
+ #endregion
+
+ private void Awake()
+ {
+ // 绉佹湁瀛楁璧嬪
+
+ // 鍏叡瀛楁璧嬪
+
+ // 鍒濆鍖
+ }
+
+ private void OnEnable()
+ {
+ GlobalEventManager.Instance.Register("Health.BurnKill", OnEventCheck);
+ GlobalEventManager.Instance.Notify("Health.BurnKill");
+ }
+
+ private void OnEventCheck(params object[] p)
+ {
+ Debug.Log("msg");
+ }
+
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Tests/TestEvent.cs.meta b/WorldlineKeepers/Assets/Scripts/Tests/TestEvent.cs.meta
new file mode 100644
index 0000000..965ecdd
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Tests/TestEvent.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 0825a89e4815bc94eb58cd23aa6f4814
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Tools.meta b/WorldlineKeepers/Assets/Scripts/Tools.meta
new file mode 100644
index 0000000..bc5c8b7
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Tools.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 0f4ad5525cbe4b942bba307305127136
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Tools/GlobalEventManager.cs b/WorldlineKeepers/Assets/Scripts/Tools/GlobalEventManager.cs
new file mode 100644
index 0000000..47f3990
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Tools/GlobalEventManager.cs
@@ -0,0 +1,97 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UIElements;
+
+namespace WK
+{
+ /// <summary>
+ /// 全局事件
+ /// </summary>
+ public class GlobalEventManager : Singleton<GlobalEventManager>
+ {
+
+ // callback
+ public delegate void EventCallback(params object[] objs);
+ public Dictionary<string, LinkedList<EventCallback>> AllEvents = new Dictionary<string, LinkedList<EventCallback>>();
+
+ public void Register(string eventName, EventCallback callback, bool addFirst = false)
+ {
+ if (callback == null)
+ {
+ Debug.LogError("监听函数不能为空");
+ return;
+ }
+ LinkedList<EventCallback> list;
+ if (!AllEvents.TryGetValue(eventName, out list))
+ {
+ list = new LinkedList<EventCallback>(); // 这里最好从池子里拿
+ AllEvents.Add(eventName, list);
+ }
+ if (!list.Contains(callback))
+ {
+ if (addFirst && list.Count > 0)
+ {
+ list.AddFirst(callback);
+ }
+ else
+ {
+ list.AddLast(callback);
+ }
+ }
+ else
+ {
+ Debug.LogError("重复添加监听, eventName=" + eventName);
+ }
+ }
+
+ public void UnRegister(string eventName, EventCallback callback)
+ {
+ if (callback == null)
+ {
+ Debug.LogError("监听函数不能为空");
+ return;
+ }
+ LinkedList<EventCallback> list;
+ if (!AllEvents.TryGetValue(eventName, out list))
+ {
+ return;
+ }
+ list.Remove(callback);
+ if (list.Count == 0)
+ {
+ AllEvents.Remove(eventName);
+ // 如果这里list是从池子里拿的,回收它
+ }
+ }
+
+ public void UnRegisterEvent(string eventName)
+ {
+ if (AllEvents.ContainsKey(eventName))
+ {
+ AllEvents.Remove(eventName);
+ }
+ }
+
+ public void UnRegisterAll(string eventName)
+ {
+ AllEvents.Remove(eventName);
+ }
+
+ public void Notify(string eventName, params object[] objs)
+ {
+ LinkedList<EventCallback> list;
+ if (AllEvents.TryGetValue(eventName, out list) && list != null && list.Count > 0)
+ {
+ foreach (EventCallback callback in list)
+ {
+ if (callback != null)
+ {
+ callback.Invoke(objs);
+ }
+ }
+ }
+ }
+
+ }
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Tools/GlobalEventManager.cs.meta b/WorldlineKeepers/Assets/Scripts/Tools/GlobalEventManager.cs.meta
new file mode 100644
index 0000000..0c2c8ec
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Tools/GlobalEventManager.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 7a9f38c8080be5e41ad5220346ba8c7f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Tools/NotificationCenter.cs b/WorldlineKeepers/Assets/Scripts/Tools/NotificationCenter.cs
new file mode 100644
index 0000000..b3f299a
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Tools/NotificationCenter.cs
@@ -0,0 +1,167 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace WK
+{
+
+ public class NotificationCenter
+ {
+ private Dictionary<string, Dictionary<object, List<Action<object, object>>>> _table = new Dictionary<string, Dictionary<object, List<Action<object, object>>>>();
+
+ private HashSet<List<Action<object, object>>> _invoking = new HashSet<List<Action<object, object>>>();
+
+ public static readonly NotificationCenter instance = new NotificationCenter();
+
+ private NotificationCenter()
+ {
+ }
+
+ public void AddObserver(Action<object, object> handler, string notificationName)
+ {
+ AddObserver(handler, notificationName, null);
+ }
+
+ public void AddObserver(Action<object, object> handler, string notificationName, object sender)
+ {
+ if (handler == null)
+ {
+ Debug.LogError("Can't add a null event handler for notification, " + notificationName);
+ return;
+ }
+ if (string.IsNullOrEmpty(notificationName))
+ {
+ Debug.LogError("Can't observe an unnamed notification");
+ return;
+ }
+ if (!_table.ContainsKey(notificationName))
+ {
+ _table.Add(notificationName, new Dictionary<object, List<Action<object, object>>>());
+ }
+ Dictionary<object, List<Action<object, object>>> dictionary = _table[notificationName];
+ object key = ((sender != null) ? sender : this);
+ if (!dictionary.ContainsKey(key))
+ {
+ dictionary.Add(key, new List<Action<object, object>>());
+ }
+ List<Action<object, object>> list = dictionary[key];
+ if (_invoking.Contains(list))
+ {
+ list = (dictionary[key] = new List<Action<object, object>>(list));
+ }
+ list.Add(handler);
+ }
+
+ public void RemoveObserver(Action<object, object> handler, string notificationName)
+ {
+ RemoveObserver(handler, notificationName, null);
+ }
+
+ public void RemoveObserver(Action<object, object> handler, string notificationName, object sender)
+ {
+ if (handler == null)
+ {
+ Debug.LogError("Can't remove a null event handler for notification, " + notificationName);
+ }
+ else if (string.IsNullOrEmpty(notificationName))
+ {
+ Debug.LogError("A notification name is required to stop observation");
+ }
+ else
+ {
+ if (!_table.ContainsKey(notificationName))
+ {
+ return;
+ }
+ Dictionary<object, List<Action<object, object>>> dictionary = _table[notificationName];
+ object key = ((sender != null) ? sender : this);
+ if (!dictionary.ContainsKey(key))
+ {
+ return;
+ }
+ List<Action<object, object>> list = dictionary[key];
+ int num = list.IndexOf(handler);
+ if (num != -1)
+ {
+ if (_invoking.Contains(list))
+ {
+ list = (dictionary[key] = new List<Action<object, object>>(list));
+ }
+ list.RemoveAt(num);
+ }
+ }
+ }
+
+ public void Clean()
+ {
+ string[] array = new string[_table.Keys.Count];
+ _table.Keys.CopyTo(array, 0);
+ for (int num = array.Length - 1; num >= 0; num--)
+ {
+ string key = array[num];
+ Dictionary<object, List<Action<object, object>>> dictionary = _table[key];
+ object[] array2 = new object[dictionary.Keys.Count];
+ dictionary.Keys.CopyTo(array2, 0);
+ for (int num2 = array2.Length - 1; num2 >= 0; num2--)
+ {
+ object key2 = array2[num2];
+ if (dictionary[key2].Count == 0)
+ {
+ dictionary.Remove(key2);
+ }
+ }
+ if (dictionary.Count == 0)
+ {
+ _table.Remove(key);
+ }
+ }
+ }
+
+ public void PostNotification(string notificationName)
+ {
+ PostNotification(notificationName, null);
+ }
+
+ public void PostNotification(string notificationName, object sender)
+ {
+ PostNotification(notificationName, sender, null);
+ }
+
+ public void PostNotification(string notificationName, object sender, object e)
+ {
+ if (string.IsNullOrEmpty(notificationName))
+ {
+ Debug.LogError("A notification name is required");
+ }
+ else
+ {
+ if (!_table.ContainsKey(notificationName))
+ {
+ return;
+ }
+ Dictionary<object, List<Action<object, object>>> dictionary = _table[notificationName];
+ if (sender != null && dictionary.ContainsKey(sender))
+ {
+ List<Action<object, object>> list = dictionary[sender];
+ _invoking.Add(list);
+ for (int i = 0; i < list.Count; i++)
+ {
+ list[i](sender, e);
+ }
+ _invoking.Remove(list);
+ }
+ if (dictionary.ContainsKey(this))
+ {
+ List<Action<object, object>> list2 = dictionary[this];
+ _invoking.Add(list2);
+ for (int j = 0; j < list2.Count; j++)
+ {
+ list2[j](sender, e);
+ }
+ _invoking.Remove(list2);
+ }
+ }
+ }
+ }
+
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Tools/NotificationCenter.cs.meta b/WorldlineKeepers/Assets/Scripts/Tools/NotificationCenter.cs.meta
new file mode 100644
index 0000000..13d54ee
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Tools/NotificationCenter.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f222398a57afbf446b471ccf17bb9575
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterController.cs b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterBehaviour.cs
index 7674523..7674523 100644
--- a/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterController.cs
+++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterBehaviour.cs
diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterController.cs.meta b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterBehaviour.cs.meta
index 330a2d3..330a2d3 100644
--- a/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterController.cs.meta
+++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterBehaviour.cs.meta
diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterMetadata.cs b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterMetadata.cs
new file mode 100644
index 0000000..81b80c0
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterMetadata.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace WK.Data
+{
+
+ public class CharacterMetadata
+ {
+
+ public string uid;
+
+ public string name_key;
+
+ public Dictionary<string, string> stats;
+
+ public string behaviour;
+
+ public string extra_data;
+ }
+
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterMetadata.cs.meta b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterMetadata.cs.meta
new file mode 100644
index 0000000..f39e3ec
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterMetadata.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ecafd17226029e748994c5814d59cc03
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/PlayerController.cs b/WorldlineKeepers/Assets/Scripts/Unit/Characters/PlayerController.cs
index 66bf6df..2f19fb3 100644
--- a/WorldlineKeepers/Assets/Scripts/Unit/Characters/PlayerController.cs
+++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/PlayerController.cs
@@ -7,9 +7,15 @@ namespace WK
public class PlayerController
{
+ /// <summary>
+ /// 角色所有当前数值
+ /// </summary>
private CharacterInfo m_CharacterInfo;
public CharacterInfo info { get { return m_CharacterInfo; } }
+ /// <summary>
+ /// 角色行为逻辑
+ /// </summary>
private CharacterBehaviour m_CharacterBehaviour;
public CharacterBehaviour behaviour { get { return m_CharacterBehaviour; } }
diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/Ronin/RoninBehaviour.cs b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Ronin/RoninBehaviour.cs
index 4a348eb..1964323 100644
--- a/WorldlineKeepers/Assets/Scripts/Unit/Characters/Ronin/RoninBehaviour.cs
+++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Ronin/RoninBehaviour.cs
@@ -13,7 +13,8 @@ public class RoninBehaviour : CharacterBehaviour
if (info.stats["max_health"] != null)
{
- int health = info.stats["max_health"].value.i;
+ int health = info.stats["max_health"].intValue;
+
}
}
diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Enemies/SpiritScript.cs b/WorldlineKeepers/Assets/Scripts/Unit/Enemies/SpiritScript.cs
index 7ebae9c..dbcab58 100644
--- a/WorldlineKeepers/Assets/Scripts/Unit/Enemies/SpiritScript.cs
+++ b/WorldlineKeepers/Assets/Scripts/Unit/Enemies/SpiritScript.cs
@@ -17,7 +17,7 @@ public class SpiritScript : UnitBase
private static List<IQuadTreeObject> collisions = new List<IQuadTreeObject>();
- private SpriteRenderer m_SpriteRenderer;
+ //private SpriteRenderer m_SpriteRenderer;
private int m_CollisionCheckerCount = 0;
@@ -32,7 +32,7 @@ public class SpiritScript : UnitBase
speed = 2;
TestSpirits.spirits.Add(this);
}
-
+
protected override void Update()
{
base.Update();
diff --git a/WorldlineKeepers/Assets/Scripts/Unit/UnitManager.cs b/WorldlineKeepers/Assets/Scripts/Unit/UnitManager.cs
new file mode 100644
index 0000000..9ec97f3
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Unit/UnitManager.cs
@@ -0,0 +1,15 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace WK
+{
+
+ public class UnitManager
+ {
+
+
+
+ }
+
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Unit/UnitManager.cs.meta b/WorldlineKeepers/Assets/Scripts/Unit/UnitManager.cs.meta
new file mode 100644
index 0000000..a1d3faf
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Unit/UnitManager.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 6c5e1e3ffbd73844aa887ef5d5a829f0
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: