diff options
Diffstat (limited to 'WorldlineKeepers/Assets/Scripts')
48 files changed, 774 insertions, 86 deletions
diff --git a/WorldlineKeepers/Assets/Scripts/Buffs/Behaviours.meta b/WorldlineKeepers/Assets/Scripts/Buffs/Behaviours.meta new file mode 100644 index 0000000..f71f04d --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Buffs/Behaviours.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7451d6093f9cc26489367b95fcb1cdb1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Buffs/Buff.cs b/WorldlineKeepers/Assets/Scripts/Buffs/Buff.cs index 1c6ae5a..7c8d7ef 100644 --- a/WorldlineKeepers/Assets/Scripts/Buffs/Buff.cs +++ b/WorldlineKeepers/Assets/Scripts/Buffs/Buff.cs @@ -12,7 +12,7 @@ public abstract class Buff // 元数据 public BuffMetadata metadata; - // buff效果器 + // buff逻辑 public BuffBehaviour effector; public string uid diff --git a/WorldlineKeepers/Assets/Scripts/Buffs/BuffBehaviour.cs b/WorldlineKeepers/Assets/Scripts/Buffs/BuffBehaviour.cs index 0a0559f..4e20202 100644 --- a/WorldlineKeepers/Assets/Scripts/Buffs/BuffBehaviour.cs +++ b/WorldlineKeepers/Assets/Scripts/Buffs/BuffBehaviour.cs @@ -2,31 +2,74 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -public class BuffBehaviour -{ - private CharacterBase m_Character; - - /// <summary> - /// buff鐢熸垚鏃跺 - /// </summary> - public virtual void OnCreate() - { +//https://zhuanlan.zhihu.com/p/150812545 +//https://developer.valvesoftware.com/wiki/Dota_2_Workshop_Tools/Scripting/Abilities_Data_Driven/zh - } +namespace WK +{ /// <summary> - /// 鏇存柊 + /// Buff鐢熷懡鍛ㄦ湡 + /// 瀹炰緥鍖 -> 鍔犲叆鍒楄〃鍓 -> 鍔犲叆鍒楄〃鍚 -> 鏇存柊 -> 绉诲嚭鍒楄〃鍓 -> 绉诲嚭鍒楄〃鍚 + /// 姣忎竴姝ラ兘浼氬悜褰撳墠瀵硅薄浣滅敤鍩熷唴骞挎挱娑堟伅 /// </summary> - public virtual void OnUpdate() + public abstract class BuffBehaviour { + /// <summary> + /// buff瀹炰緥鍖栨椂 + /// </summary> + public virtual void OnCreate() + { - } + } - /// <summary> - /// 瑙掕壊姝讳骸 - /// </summary> - public virtual void OnCharacterDeath() - { - } + /// <summary> + /// 鑾峰緱杩欎釜buff锛堝姞鍏ュ垪琛ㄥ墠锛 + /// </summary> + public virtual void OnBeforeAttach() + { + } + + /// <summary> + /// 鍔犲叆鍒楄〃鍚庯紝婵娲昏繖涓猙uff + /// </summary> + public virtual void OnAfterAttach() + { + + } + + /// <summary> + /// 绗竴娆pdate鍓 + /// </summary> + public virtual void OnStart() + { + + } + + /// <summary> + /// 浠庡垪琛ㄧЩ鍑哄墠 + /// </summary> + public virtual void OnBeforeDeattach() + { + + } + + /// <summary> + /// 绉婚櫎杩欎釜buff锛堢Щ鍑哄垪琛ㄥ悗锛 + /// </summary> + public virtual void OnAfterDeattach() + { + + } + + /// <summary> + /// 姣忓抚閫昏緫鏇存柊锛堝鏋滈渶瑕佺殑璇濓級 + /// </summary> + public virtual void OnUpdate() + { + + } + + } } diff --git a/WorldlineKeepers/Assets/Scripts/Items/Behaviours.meta b/WorldlineKeepers/Assets/Scripts/Items/Behaviours.meta new file mode 100644 index 0000000..b6151d7 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Items/Behaviours.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3692bca7626d0b24eaf9fd9822f92440 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Items/ItemDaggerBehaviour.cs b/WorldlineKeepers/Assets/Scripts/Items/Behaviours/ItemDaggerBehaviour.cs index 1e0dfe6..1e0dfe6 100644 --- a/WorldlineKeepers/Assets/Scripts/Items/ItemDaggerBehaviour.cs +++ b/WorldlineKeepers/Assets/Scripts/Items/Behaviours/ItemDaggerBehaviour.cs diff --git a/WorldlineKeepers/Assets/Scripts/Items/ItemDaggerBehaviour.cs.meta b/WorldlineKeepers/Assets/Scripts/Items/Behaviours/ItemDaggerBehaviour.cs.meta index 409141f..409141f 100644 --- a/WorldlineKeepers/Assets/Scripts/Items/ItemDaggerBehaviour.cs.meta +++ b/WorldlineKeepers/Assets/Scripts/Items/Behaviours/ItemDaggerBehaviour.cs.meta diff --git a/WorldlineKeepers/Assets/Scripts/Items/ItemHellbellBehaviour.cs b/WorldlineKeepers/Assets/Scripts/Items/Behaviours/ItemHellbellBehaviour.cs index 1008eed..1008eed 100644 --- a/WorldlineKeepers/Assets/Scripts/Items/ItemHellbellBehaviour.cs +++ b/WorldlineKeepers/Assets/Scripts/Items/Behaviours/ItemHellbellBehaviour.cs diff --git a/WorldlineKeepers/Assets/Scripts/Items/ItemHellbellBehaviour.cs.meta b/WorldlineKeepers/Assets/Scripts/Items/Behaviours/ItemHellbellBehaviour.cs.meta index 341e7c0..341e7c0 100644 --- a/WorldlineKeepers/Assets/Scripts/Items/ItemHellbellBehaviour.cs.meta +++ b/WorldlineKeepers/Assets/Scripts/Items/Behaviours/ItemHellbellBehaviour.cs.meta diff --git a/WorldlineKeepers/Assets/Scripts/Items/ItemBehaviour.cs b/WorldlineKeepers/Assets/Scripts/Items/ItemBehaviour.cs index 520946a..9d7ce10 100644 --- a/WorldlineKeepers/Assets/Scripts/Items/ItemBehaviour.cs +++ b/WorldlineKeepers/Assets/Scripts/Items/ItemBehaviour.cs @@ -22,6 +22,12 @@ namespace WK.Items { } + + public virtual void OnUpdate() + { + + } + } } diff --git a/WorldlineKeepers/Assets/Scripts/Modifier/Modifier.cs b/WorldlineKeepers/Assets/Scripts/Modifier/Modifier.cs new file mode 100644 index 0000000..54e5140 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Modifier/Modifier.cs @@ -0,0 +1,10 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Modifier +{ + + + +} diff --git a/WorldlineKeepers/Assets/Scripts/Modifier/Modifier.cs.meta b/WorldlineKeepers/Assets/Scripts/Modifier/Modifier.cs.meta new file mode 100644 index 0000000..450a2c2 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Modifier/Modifier.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 77177e3292fb84d4cb05d7e54c6d4b6f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Rendering/GraphicsManager.cs b/WorldlineKeepers/Assets/Scripts/Rendering/GraphicsManager.cs new file mode 100644 index 0000000..0503c7d --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Rendering/GraphicsManager.cs @@ -0,0 +1,15 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WK.Rendering +{ + + public class GraphicsManager : Singleton<GraphicsManager> + { + + public List<Shader> m_Shaders; + + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Rendering/GraphicsManager.cs.meta b/WorldlineKeepers/Assets/Scripts/Rendering/GraphicsManager.cs.meta new file mode 100644 index 0000000..d98f33f --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Rendering/GraphicsManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c770205e561842a4cab48846601a1776 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimation.cs b/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimation.cs index f2b7e98..a6c6a6d 100644 --- a/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimation.cs +++ b/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimation.cs @@ -5,7 +5,7 @@ using UnityEngine; namespace WK.Rendering { - + [Serializable] public class SpriteAnimation { public List<Sprite> sprites; diff --git a/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimationController.cs b/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimationController.cs index 315cf91..63ba394 100644 --- a/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimationController.cs +++ b/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimationController.cs @@ -13,20 +13,49 @@ namespace WK.Rendering #endregion #region 鍏叡瀛楁 - + public bool playing + { + get + { + return m_IsPlaying; + } + set + { + m_IsPlaying = value; + } + } #endregion #region 绉佹湁瀛楁 - + private SpriteRenderer m_SpriteRenderer; + private bool m_IsPlaying; #endregion private void Awake() { - // 绉佹湁瀛楁璧嬪 + m_SpriteRenderer = GetComponent<SpriteRenderer>(); - // 鍏叡瀛楁璧嬪 + StartCoroutine(CoPlayAnimation(m_SpriteAnimation.duration)); - // 鍒濆鍖 + m_IsPlaying = true; + } + + IEnumerator CoPlayAnimation(float duration = 1f) + { + int index = 0; + while (true) + { + if (!playing) + { + yield return null; + continue; + } + + m_SpriteRenderer.sprite = m_SpriteAnimation.sprites[index]; + yield return new WaitForSeconds(m_SpriteAnimation.duration / m_SpriteAnimation.sprites.Count); + index++; + index %= m_SpriteAnimation.sprites.Count; + } } } diff --git a/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsBase.cs b/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsBase.cs index 8dbb161..49c6933 100644 --- a/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsBase.cs +++ b/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsBase.cs @@ -61,6 +61,11 @@ namespace WK } } + //public T Access<T>() + //{ + // return null; + //} + } } diff --git a/WorldlineKeepers/Assets/Scripts/Tests/TestEvent.cs b/WorldlineKeepers/Assets/Scripts/Tests/TestEvent.cs index c6e9bba..54df05b 100644 --- a/WorldlineKeepers/Assets/Scripts/Tests/TestEvent.cs +++ b/WorldlineKeepers/Assets/Scripts/Tests/TestEvent.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using UnityEngine; using WK; -public class TestEvent : MonoBehaviour +public class TestEvent : MonoBehaviour, INotification { #region 搴忓垪鍖 @@ -28,13 +28,15 @@ public class TestEvent : MonoBehaviour private void OnEnable() { - GlobalEventManager.Instance.Register("Health.BurnKill", OnEventCheck); - GlobalEventManager.Instance.Notify("Health.BurnKill"); + //GlobalEventManager.Instance.Register("Health.BurnKill", OnEventCheck); + //GlobalEventManager.Instance.Notify("Health.BurnKill"); + this.AddObserver("Health", OnEventCheck); + this.PostNotification("Health", "asdasd"); } private void OnEventCheck(params object[] p) { - Debug.Log("msg"); + Debug.Log("msg" + p[0]); } } diff --git a/WorldlineKeepers/Assets/Scripts/Tools/FlagManager.cs b/WorldlineKeepers/Assets/Scripts/Tools/FlagManager.cs new file mode 100644 index 0000000..b9a9454 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Tools/FlagManager.cs @@ -0,0 +1,44 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WK +{ + + /// <summary> + /// 全局标志管理 + /// </summary> + public class FlagManager : Singleton<FlagManager> + { + public Dictionary<string, bool> m_Flags; + + public void AddFlag(string flag, bool value = false) + { + if(!HasFlag(flag)) + { + m_Flags.Add(flag, value); + } + } + + public bool HasFlag(string flag) + { + return m_Flags.ContainsKey(flag); + } + + public bool IsFlag(string flag) + { + if(m_Flags.ContainsKey(flag)) return false; + return m_Flags[flag]; + } + + public void RemoveFlag(string flag) + { + if(HasFlag(flag)) + { + m_Flags.Remove(flag); + } + } + + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Tools/FlagManager.cs.meta b/WorldlineKeepers/Assets/Scripts/Tools/FlagManager.cs.meta new file mode 100644 index 0000000..1738634 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Tools/FlagManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2451904bd85094c40a69d59807d51c5e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Tools/GlobalEventManager.cs b/WorldlineKeepers/Assets/Scripts/Tools/GlobalEventManager.cs index 47f3990..c9cde83 100644 --- a/WorldlineKeepers/Assets/Scripts/Tools/GlobalEventManager.cs +++ b/WorldlineKeepers/Assets/Scripts/Tools/GlobalEventManager.cs @@ -6,7 +6,7 @@ using UnityEngine.UIElements; namespace WK { /// <summary> - /// 全局事件 + /// 不指定发送者的全局事件 /// </summary> public class GlobalEventManager : Singleton<GlobalEventManager> { diff --git a/WorldlineKeepers/Assets/Scripts/Tools/Notification.meta b/WorldlineKeepers/Assets/Scripts/Tools/Notification.meta new file mode 100644 index 0000000..b20b283 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Tools/Notification.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 12f4a3b409f294746a9546c44272660c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Tools/NotificationCenter.cs b/WorldlineKeepers/Assets/Scripts/Tools/Notification/NotificationCenter.cs index b3f299a..bb4e08e 100644 --- a/WorldlineKeepers/Assets/Scripts/Tools/NotificationCenter.cs +++ b/WorldlineKeepers/Assets/Scripts/Tools/Notification/NotificationCenter.cs @@ -5,24 +5,23 @@ using UnityEngine; namespace WK { - public class NotificationCenter + public class NotificationCenter : Singleton<NotificationCenter> { - private Dictionary<string, Dictionary<object, List<Action<object, object>>>> _table = new Dictionary<string, Dictionary<object, List<Action<object, object>>>>(); + public delegate void NotificatonHandler(params object[] args); - private HashSet<List<Action<object, object>>> _invoking = new HashSet<List<Action<object, object>>>(); + private Dictionary<string/*eventName*/, Dictionary<object/*publisher*/, List<NotificatonHandler>>> m_EventListeners = new Dictionary<string, Dictionary<object, List<NotificatonHandler>>>(); - public static readonly NotificationCenter instance = new NotificationCenter(); + /// <summary> + /// 当前在调用中的回调 + /// </summary> + private HashSet<List<NotificatonHandler>> m_CurInvokingCallbacks = new HashSet<List<NotificatonHandler>>(); - private NotificationCenter() + public void AddObserver(string notificationName, NotificatonHandler handler) { + AddObserver(null, notificationName, handler); } - public void AddObserver(Action<object, object> handler, string notificationName) - { - AddObserver(handler, notificationName, null); - } - - public void AddObserver(Action<object, object> handler, string notificationName, object sender) + public void AddObserver(object sender, string notificationName, NotificatonHandler handler) { if (handler == null) { @@ -34,30 +33,30 @@ namespace WK Debug.LogError("Can't observe an unnamed notification"); return; } - if (!_table.ContainsKey(notificationName)) + if (!m_EventListeners.ContainsKey(notificationName)) { - _table.Add(notificationName, new Dictionary<object, List<Action<object, object>>>()); + m_EventListeners.Add(notificationName, new Dictionary<object, List<NotificatonHandler>>()); } - Dictionary<object, List<Action<object, object>>> dictionary = _table[notificationName]; + Dictionary<object, List<NotificatonHandler>> dictionary = m_EventListeners[notificationName]; object key = ((sender != null) ? sender : this); if (!dictionary.ContainsKey(key)) { - dictionary.Add(key, new List<Action<object, object>>()); + dictionary.Add(key, new List<NotificatonHandler>()); } - List<Action<object, object>> list = dictionary[key]; - if (_invoking.Contains(list)) + List<NotificatonHandler> list = dictionary[key]; + if (m_CurInvokingCallbacks.Contains(list)) { - list = (dictionary[key] = new List<Action<object, object>>(list)); + list = (dictionary[key] = new List<NotificatonHandler>(list)); } list.Add(handler); } - public void RemoveObserver(Action<object, object> handler, string notificationName) + public void RemoveObserver(string notificationName, NotificatonHandler handler) { - RemoveObserver(handler, notificationName, null); + RemoveObserver(null, notificationName, handler); } - public void RemoveObserver(Action<object, object> handler, string notificationName, object sender) + public void RemoveObserver(object sender, string notificationName, NotificatonHandler handler) { if (handler == null) { @@ -69,23 +68,23 @@ namespace WK } else { - if (!_table.ContainsKey(notificationName)) + if (!m_EventListeners.ContainsKey(notificationName)) { return; } - Dictionary<object, List<Action<object, object>>> dictionary = _table[notificationName]; + Dictionary<object, List<NotificatonHandler>> dictionary = m_EventListeners[notificationName]; object key = ((sender != null) ? sender : this); if (!dictionary.ContainsKey(key)) { return; } - List<Action<object, object>> list = dictionary[key]; + List<NotificatonHandler> list = dictionary[key]; int num = list.IndexOf(handler); if (num != -1) { - if (_invoking.Contains(list)) + if (m_CurInvokingCallbacks.Contains(list)) { - list = (dictionary[key] = new List<Action<object, object>>(list)); + list = (dictionary[key] = new List<NotificatonHandler>(list)); } list.RemoveAt(num); } @@ -94,12 +93,12 @@ namespace WK public void Clean() { - string[] array = new string[_table.Keys.Count]; - _table.Keys.CopyTo(array, 0); + string[] array = new string[m_EventListeners.Keys.Count]; + m_EventListeners.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]; + Dictionary<object, List<NotificatonHandler>> dictionary = m_EventListeners[key]; object[] array2 = new object[dictionary.Keys.Count]; dictionary.Keys.CopyTo(array2, 0); for (int num2 = array2.Length - 1; num2 >= 0; num2--) @@ -112,7 +111,7 @@ namespace WK } if (dictionary.Count == 0) { - _table.Remove(key); + m_EventListeners.Remove(key); } } } @@ -122,12 +121,12 @@ namespace WK PostNotification(notificationName, null); } - public void PostNotification(string notificationName, object sender) + public void PostNotification(object sender, string notificationName) { - PostNotification(notificationName, sender, null); + PostNotification(sender, notificationName, null); } - public void PostNotification(string notificationName, object sender, object e) + public void PostNotification(object sender, string notificationName, params object[] p) { if (string.IsNullOrEmpty(notificationName)) { @@ -135,33 +134,34 @@ namespace WK } else { - if (!_table.ContainsKey(notificationName)) + if (!m_EventListeners.ContainsKey(notificationName)) { return; } - Dictionary<object, List<Action<object, object>>> dictionary = _table[notificationName]; + Dictionary<object, List<NotificatonHandler>> dictionary = m_EventListeners[notificationName]; if (sender != null && dictionary.ContainsKey(sender)) { - List<Action<object, object>> list = dictionary[sender]; - _invoking.Add(list); + List<NotificatonHandler> list = dictionary[sender]; + m_CurInvokingCallbacks.Add(list); for (int i = 0; i < list.Count; i++) { - list[i](sender, e); + list[i](p); } - _invoking.Remove(list); + m_CurInvokingCallbacks.Remove(list); } if (dictionary.ContainsKey(this)) { - List<Action<object, object>> list2 = dictionary[this]; - _invoking.Add(list2); + List<NotificatonHandler> list2 = dictionary[this]; + m_CurInvokingCallbacks.Add(list2); for (int j = 0; j < list2.Count; j++) { - list2[j](sender, e); + list2[j](p); } - _invoking.Remove(list2); + m_CurInvokingCallbacks.Remove(list2); } } } + } } diff --git a/WorldlineKeepers/Assets/Scripts/Tools/NotificationCenter.cs.meta b/WorldlineKeepers/Assets/Scripts/Tools/Notification/NotificationCenter.cs.meta index 13d54ee..13d54ee 100644 --- a/WorldlineKeepers/Assets/Scripts/Tools/NotificationCenter.cs.meta +++ b/WorldlineKeepers/Assets/Scripts/Tools/Notification/NotificationCenter.cs.meta diff --git a/WorldlineKeepers/Assets/Scripts/Tools/Notification/NotificationExtensions.cs b/WorldlineKeepers/Assets/Scripts/Tools/Notification/NotificationExtensions.cs new file mode 100644 index 0000000..8313f7b --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Tools/Notification/NotificationExtensions.cs @@ -0,0 +1,17 @@ +using System; + +namespace WK +{ + + public interface INotification + { + } + + public static class NotificationExtensions + { + public static void AddObserver(this INotification _this, string msg, NotificationCenter.NotificatonHandler handler) { NotificationCenter.Instance.AddObserver(_this, msg, handler); } + public static void RemoveObserver(this INotification _this, string msg, NotificationCenter.NotificatonHandler handler) { NotificationCenter.Instance.RemoveObserver(_this, msg, handler); } + public static void PostNotification(this INotification _this, string msg, params object[] p) { NotificationCenter.Instance.PostNotification(_this, msg, p); } + + } +} diff --git a/WorldlineKeepers/Assets/Scripts/Tools/Notification/NotificationExtensions.cs.meta b/WorldlineKeepers/Assets/Scripts/Tools/Notification/NotificationExtensions.cs.meta new file mode 100644 index 0000000..a805d3a --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Tools/Notification/NotificationExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 75fb0f8661eca5c4faf394f140fcae88 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Tools/Notification/ScopedNotification.cs b/WorldlineKeepers/Assets/Scripts/Tools/Notification/ScopedNotification.cs new file mode 100644 index 0000000..0002f14 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Tools/Notification/ScopedNotification.cs @@ -0,0 +1,89 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WK +{ + + public class ScopedNotification + { + public delegate void NotificatonHandler(params object[] args); + + private Dictionary<string, List<NotificatonHandler>> m_EventListeners = new Dictionary<string, List<NotificatonHandler>>(); + + public void AddObserver(string eventName, NotificatonHandler handler) + { + if (handler == null) + { + return; + } + + if (string.IsNullOrEmpty(eventName)) + { + return; + } + + List<NotificatonHandler> handlers; + if (!m_EventListeners.ContainsKey(eventName)) + { + m_EventListeners.Add(eventName, new List<NotificatonHandler>()); + } + + handlers = m_EventListeners[eventName]; + handlers.Add(handler); + } + + public void RemoveObserver(string eventName, NotificatonHandler handler) + { + if(handler == null) { return; } + + if(string.IsNullOrEmpty(eventName)) { return; } + + if (!m_EventListeners.ContainsKey(eventName)) + return; + + List<NotificatonHandler> handlers = m_EventListeners[eventName]; + if(handlers.Contains(handler)) + handlers.Remove(handler); + } + + public void RemoveEvent(string eventName) + { + if (string.IsNullOrEmpty(eventName)) { return; } + if(m_EventListeners.ContainsKey(eventName)) + { + m_EventListeners.Remove(eventName); + } + } + + public void Clean() + { + m_EventListeners.Clear(); + } + + public void PostNotification(string eventName, params object[] args) + { + if (string.IsNullOrEmpty(eventName)) { return; } + + if (!m_EventListeners.ContainsKey(eventName)) + return; + + List<NotificatonHandler> handlers = m_EventListeners[eventName]; + for(int i = 0; i < handlers.Count; i++) + { + var handler = handlers[i]; + if(handler != null) + { + handler(args); + } + } + } + + public void PostNotification(string eventName) + { + PostNotification(eventName, null); + } + + } + +}
\ No newline at end of file diff --git a/WorldlineKeepers/Assets/Scripts/Tools/Notification/ScopedNotification.cs.meta b/WorldlineKeepers/Assets/Scripts/Tools/Notification/ScopedNotification.cs.meta new file mode 100644 index 0000000..4ec5672 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Tools/Notification/ScopedNotification.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 66ddfe88aa791154ea0663b56917da4a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem.meta b/WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem.meta new file mode 100644 index 0000000..a6922dc --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 035c400d50feb2747bb551b48ff42f8f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem/ActiveTrigger.cs b/WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem/ActiveTrigger.cs new file mode 100644 index 0000000..1a4e988 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem/ActiveTrigger.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json.Serialization; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WK +{ + + /// <summary> + /// 定期轮训条件的主动式触发器。不安全 + /// </summary> + public class ActiveTrigger + { + + + + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem/ActiveTrigger.cs.meta b/WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem/ActiveTrigger.cs.meta new file mode 100644 index 0000000..1fa37dc --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem/ActiveTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6e06c17e867b36f4bb0b6796ed74b89b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem/Trigger.cs b/WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem/Trigger.cs new file mode 100644 index 0000000..ed69284 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem/Trigger.cs @@ -0,0 +1,110 @@ +using System.Collections.Generic; +using System.Diagnostics.Tracing; + +namespace WK +{ + + /// <summary> + /// 事件发生后检测条件的被动触发器 + /// </summary> + public class Trigger + { + public class ConditionBase + { + public virtual bool Evaluate(params object[] args) { return false; } + + public static ConditionBase Always = new ConditionAlways(); + public static ConditionBase AlwaysNot = new ConditionAlwaysNot(); + } + + public class ConditionAlways : ConditionBase + { + public override bool Evaluate(params object[] args) + { + return true; + } + } + + public class ConditionAlwaysNot : ConditionBase + { + public override bool Evaluate(params object[] args) + { + return false; + } + } + + public class ConditionAnd : ConditionBase + { + private ConditionBase m_Left; + private ConditionBase m_Right; + public ConditionAnd(ConditionBase left, ConditionBase right) + { + m_Left = left; + m_Right = right; + } + public override bool Evaluate(params object[] args) + { + return m_Left.Evaluate(args) && m_Right.Evaluate(args); + } + } + + public class ConditionOr : ConditionBase + { + private ConditionBase m_Left; + private ConditionBase m_Right; + public ConditionOr(ConditionBase left, ConditionBase right) + { + m_Left = left; + m_Right = right; + } + public override bool Evaluate(params object[] args) + { + return m_Left.Evaluate(args) || m_Right.Evaluate(args); + } + } + + public delegate void Action(params object[] args); + + // 触发事件 + private string m_Event; + // 触发条件 + private ConditionBase m_Condition; + // 触发操作 + private List<Action> m_Actions = new List<Action>(); + + public void SetEvent(string eventType) + { + if (m_Event != string.Empty || m_Event != null) + { + GlobalEventManager.Instance.UnRegister(m_Event, OnEvent); + } + m_Event = eventType; + GlobalEventManager.Instance.Register(eventType, OnEvent); + } + + public void AddAction(Action action) + { + m_Actions.Add(action); + } + + public void SetCondition(ConditionBase condition) + { + m_Condition = condition; + } + + public void OnEvent(params object[] args) + { + if (m_Condition == null) + return; + if (m_Condition.Evaluate()) + { + foreach (Action action in m_Actions) + { + action.Invoke(args); + } + } + } + + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem/Trigger.cs.meta b/WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem/Trigger.cs.meta new file mode 100644 index 0000000..c5f1c19 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem/Trigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c3ee81c4dceea3346b4c5e7b1d371e92 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/Berserker.meta b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Berserker.meta new file mode 100644 index 0000000..86a6143 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Berserker.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 65b7da83d18b0a045a33527f5d446de7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/Berserker/BerserkerBehaviour.cs b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Berserker/BerserkerBehaviour.cs new file mode 100644 index 0000000..bdb18a2 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Berserker/BerserkerBehaviour.cs @@ -0,0 +1,15 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WK +{ + + public class BerserkerBehaviour : CharacterBehaviour + { + + + + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/Berserker/BerserkerBehaviour.cs.meta b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Berserker/BerserkerBehaviour.cs.meta new file mode 100644 index 0000000..2718863 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Berserker/BerserkerBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 28a1e81c0e2cc314085ee6e5fc2528ed +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/Berserker/BerserkerBuilder.cs b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Berserker/BerserkerBuilder.cs new file mode 100644 index 0000000..9601783 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Berserker/BerserkerBuilder.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WK +{ + + public class BerserkerBuilder : CharacterBuilder + { + + protected override PlayerController BuildPhaseController() + { + return base.BuildPhaseController(); + } + + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/Berserker/BerserkerBuilder.cs.meta b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Berserker/BerserkerBuilder.cs.meta new file mode 100644 index 0000000..270e5a5 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Berserker/BerserkerBuilder.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e49b90c4b84cbc54bb4ad7d14925e5db +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterBehaviour.cs b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterBehaviour.cs index 7674523..f056056 100644 --- a/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterBehaviour.cs +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterBehaviour.cs @@ -11,7 +11,7 @@ namespace WK public abstract class CharacterBehaviour { private PlayerController m_Controller; - public PlayerController controller { get { return m_Controller; } } + protected PlayerController controller { get { return m_Controller; } } public CharacterInfo info { get { return m_Controller.info; } } @@ -19,14 +19,19 @@ namespace WK { } - public virtual void OnGlobalUpdate() + public virtual void OnPreUpdate() { } - public virtual void OnStageUpdate() + public virtual void OnUpdate() { } + public virtual void OnPostUpdate() + { + + } + } }
\ No newline at end of file diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterBuilder.cs b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterBuilder.cs new file mode 100644 index 0000000..c51d565 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterBuilder.cs @@ -0,0 +1,41 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using WK.Data; + +namespace WK +{ + + public class CharacterBuilder + { + protected GameObject m_Root; + protected CharacterMetadata m_Metadata; + + public GameObject Build(CharacterMetadata metadata) + { + m_Metadata = metadata; + + m_Root = BuildPhaseRootGameObject(); + + return m_Root; + } + + protected virtual GameObject BuildPhaseRootGameObject() + { + GameObject go = new GameObject(); + return go; + } + + protected virtual PlayerController BuildPhaseController() + { + return null; + } + + protected virtual void BuildPhaseSpriteRenderer() + { + + } + + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterBuilder.cs.meta b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterBuilder.cs.meta new file mode 100644 index 0000000..a859554 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterBuilder.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c4e33239fb24da54cb24d06bd2c5cc51 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterInfo.cs b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterInfo.cs index 62dd830..63bf35f 100644 --- a/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterInfo.cs +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterInfo.cs @@ -118,7 +118,7 @@ namespace WK } /// <summary> - /// 角色当前状态 + /// 角色当前状态,包括: 属性数值、buff、perk /// </summary> public class CharacterInfo { @@ -132,6 +132,11 @@ namespace WK public CharacterPerksCollection perks { get { return m_Perks; } } public CharacterPerksCollection m_Perks; + public void OnUpdate() + { + + } + } } diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterMetadata.cs b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterMetadata.cs index 81b80c0..c8409da 100644 --- a/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterMetadata.cs +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterMetadata.cs @@ -8,16 +8,19 @@ namespace WK.Data public class CharacterMetadata { - public string uid; public string name_key; - public Dictionary<string, string> stats; + public string stats; public string behaviour; - public string extra_data; + public string builder; + + public string level_stats; + + public Dictionary<string, string> extra_data; } } diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/Dracula.meta b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Dracula.meta new file mode 100644 index 0000000..ffeee0a --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Dracula.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a9d6564032bf7864fbf3b2ef87aafa6d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/Dracula/DraculaBehaviour.cs b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Dracula/DraculaBehaviour.cs new file mode 100644 index 0000000..0789b9a --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Dracula/DraculaBehaviour.cs @@ -0,0 +1,10 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class DraculaBehaviour +{ + + + +} diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/Dracula/DraculaBehaviour.cs.meta b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Dracula/DraculaBehaviour.cs.meta new file mode 100644 index 0000000..2ebde89 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Dracula/DraculaBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9c1fd60947162c742a3ed5448c72b76b +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 2f19fb3..5ca87e6 100644 --- a/WorldlineKeepers/Assets/Scripts/Unit/Characters/PlayerController.cs +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/PlayerController.cs @@ -5,10 +5,13 @@ using UnityEngine; namespace WK { - public class PlayerController + /// <summary> + /// 玩家角色根节点 + /// </summary> + public sealed class PlayerController : INotification { /// <summary> - /// 角色所有当前数值 + /// 角色所有当前数值集合 /// </summary> private CharacterInfo m_CharacterInfo; public CharacterInfo info { get { return m_CharacterInfo; } } @@ -19,6 +22,32 @@ namespace WK private CharacterBehaviour m_CharacterBehaviour; public CharacterBehaviour behaviour { get { return m_CharacterBehaviour; } } + /// <summary> + /// gameobject根节点 + /// </summary> + private GameObject m_GameObject; + public GameObject gameObject { get { return m_GameObject;} } + + public void OnCreate() + { + } + + /// <summary> + /// 逻辑更新 + /// </summary> + public void OnUpdate() + { + // preupdate + behaviour.OnPreUpdate(); + + // update + info.OnUpdate(); + behaviour.OnUpdate(); + + // post update + behaviour.OnPostUpdate(); + } + } }
\ No newline at end of file diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/Samurai/SamuraiScript.cs b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Samurai/SamuraiScript.cs index 966c3d0..6e877b3 100644 --- a/WorldlineKeepers/Assets/Scripts/Unit/Characters/Samurai/SamuraiScript.cs +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Samurai/SamuraiScript.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UIElements; +using WK.Rendering; namespace MH { @@ -121,7 +122,7 @@ namespace MH m_Moving = false; } - GetComponent<Animator>().speed = m_Moving ? 1 : 0; + GetComponent<SpriteAnimationController>().playing = m_Moving ? true : false; if(Input.GetMouseButtonUp(0)) { diff --git a/WorldlineKeepers/Assets/Scripts/Unit/UnitManager.cs b/WorldlineKeepers/Assets/Scripts/Unit/UnitManager.cs index 9ec97f3..9ecb088 100644 --- a/WorldlineKeepers/Assets/Scripts/Unit/UnitManager.cs +++ b/WorldlineKeepers/Assets/Scripts/Unit/UnitManager.cs @@ -5,10 +5,13 @@ using UnityEngine; namespace WK { - public class UnitManager + public class UnitManager : Singleton<UnitManager> { - + /// <summary> + /// 公共的标准角色构建流程 + /// </summary> + public readonly CharacterBuilder standardCharacterBuilder = new CharacterBuilder(); } |