diff --git a/Assets/AddressableAssetsData/link.xml b/Assets/AddressableAssetsData/link.xml deleted file mode 100644 index 325df3f09..000000000 --- a/Assets/AddressableAssetsData/link.xml +++ /dev/null @@ -1,338 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Assets/AddressableAssetsData/link.xml.meta b/Assets/AddressableAssetsData/link.xml.meta deleted file mode 100644 index c855d2e95..000000000 --- a/Assets/AddressableAssetsData/link.xml.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: cd966470c04680c4a97c0568dc56e6eb -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/QFramework.meta b/Assets/Plugins/QFramework.meta deleted file mode 100644 index e1bd176c5..000000000 --- a/Assets/Plugins/QFramework.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 17f2d95280452404dbb3f62d8e0de359 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/QFramework/Framework.meta b/Assets/Plugins/QFramework/Framework.meta deleted file mode 100644 index 886730e04..000000000 --- a/Assets/Plugins/QFramework/Framework.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2c64798740b034274bbe7de863517ca1 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/QFramework/Framework/Scripts.meta b/Assets/Plugins/QFramework/Framework/Scripts.meta deleted file mode 100644 index acd22a2cb..000000000 --- a/Assets/Plugins/QFramework/Framework/Scripts.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2b3ecb0221ffc4967908529774091b89 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/QFramework/Framework/Scripts/QFramework.asmdef b/Assets/Plugins/QFramework/Framework/Scripts/QFramework.asmdef deleted file mode 100644 index d17efd092..000000000 --- a/Assets/Plugins/QFramework/Framework/Scripts/QFramework.asmdef +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "QFramework" -} diff --git a/Assets/Plugins/QFramework/Framework/Scripts/QFramework.asmdef.meta b/Assets/Plugins/QFramework/Framework/Scripts/QFramework.asmdef.meta deleted file mode 100644 index 4a92ab47d..000000000 --- a/Assets/Plugins/QFramework/Framework/Scripts/QFramework.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 9e97e42c28a41430880bee376c274c86 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/QFramework/Framework/Scripts/QFramework.cs b/Assets/Plugins/QFramework/Framework/Scripts/QFramework.cs deleted file mode 100644 index eb42123d5..000000000 --- a/Assets/Plugins/QFramework/Framework/Scripts/QFramework.cs +++ /dev/null @@ -1,944 +0,0 @@ -/**************************************************************************** - * Copyright (c) 2015 ~ 2024 liangxiegame MIT License - * - * QFramework v1.0 - * - * https://qframework.cn - * https://github.com/liangxiegame/QFramework - * https://gitee.com/liangxiegame/QFramework - * - * Author: - * liangxie https://github.com/liangxie - * soso https://github.com/so-sos-so - * - * Contributor - * TastSong https://github.com/TastSong - * 京产肠饭 https://gitee.com/JingChanChangFan/hk_-unity-tools - * 猫叔(一只皮皮虾) https://space.bilibili.com/656352/ - * misakiMeiii https://github.com/misakiMeiii - * New一天 - * 幽飞冷凝雪~冷 - * - * Community - * QQ Group: 623597263 - * - * Latest Update: 2024.5.12 20:17 add UnRegisterWhenCurrentSceneUnloaded(Suggested by misakiMeiii) - ****************************************************************************/ - -using System; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; -using UnityEngine.SceneManagement; - -namespace QFramework -{ - #region Architecture - - public interface IArchitecture - { - void RegisterSystem(T system) where T : ISystem; - - void RegisterModel(T model) where T : IModel; - - void RegisterUtility(T utility) where T : IUtility; - - T GetSystem() where T : class, ISystem; - - T GetModel() where T : class, IModel; - - T GetUtility() where T : class, IUtility; - - void SendCommand(T command) where T : ICommand; - - TResult SendCommand(ICommand command); - - TResult SendQuery(IQuery query); - - void SendEvent() where T : new(); - void SendEvent(T e); - - IUnRegister RegisterEvent(Action onEvent); - void UnRegisterEvent(Action onEvent); - - void Deinit(); - } - - public abstract class Architecture : IArchitecture where T : Architecture, new() - { - private bool mInited = false; - - - public static Action OnRegisterPatch = architecture => { }; - - protected static T mArchitecture; - - public static IArchitecture Interface - { - get - { - if (mArchitecture == null) MakeSureArchitecture(); - return mArchitecture; - } - } - - - static void MakeSureArchitecture() - { - if (mArchitecture == null) - { - mArchitecture = new T(); - mArchitecture.Init(); - - OnRegisterPatch?.Invoke(mArchitecture); - - foreach (var model in mArchitecture.mContainer.GetInstancesByType().Where(m => !m.Initialized)) - { - model.Init(); - model.Initialized = true; - } - - foreach (var system in mArchitecture.mContainer.GetInstancesByType() - .Where(m => !m.Initialized)) - { - system.Init(); - system.Initialized = true; - } - - mArchitecture.mInited = true; - } - } - - protected abstract void Init(); - - public void Deinit() - { - OnDeinit(); - foreach (var system in mContainer.GetInstancesByType().Where(s => s.Initialized)) system.Deinit(); - foreach (var model in mContainer.GetInstancesByType().Where(m => m.Initialized)) model.Deinit(); - mContainer.Clear(); - mArchitecture = null; - } - - protected virtual void OnDeinit() - { - } - - private IOCContainer mContainer = new IOCContainer(); - - public void RegisterSystem(TSystem system) where TSystem : ISystem - { - system.SetArchitecture(this); - mContainer.Register(system); - - if (mInited) - { - system.Init(); - system.Initialized = true; - } - } - - public void RegisterModel(TModel model) where TModel : IModel - { - model.SetArchitecture(this); - mContainer.Register(model); - - if (mInited) - { - model.Init(); - model.Initialized = true; - } - } - - public void RegisterUtility(TUtility utility) where TUtility : IUtility => - mContainer.Register(utility); - - public TSystem GetSystem() where TSystem : class, ISystem => mContainer.Get(); - - public TModel GetModel() where TModel : class, IModel => mContainer.Get(); - - public TUtility GetUtility() where TUtility : class, IUtility => mContainer.Get(); - - public TResult SendCommand(ICommand command) => ExecuteCommand(command); - - public void SendCommand(TCommand command) where TCommand : ICommand => ExecuteCommand(command); - - protected virtual TResult ExecuteCommand(ICommand command) - { - command.SetArchitecture(this); - return command.Execute(); - } - - protected virtual void ExecuteCommand(ICommand command) - { - command.SetArchitecture(this); - command.Execute(); - } - - public TResult SendQuery(IQuery query) => DoQuery(query); - - protected virtual TResult DoQuery(IQuery query) - { - query.SetArchitecture(this); - return query.Do(); - } - - private TypeEventSystem mTypeEventSystem = new TypeEventSystem(); - - public void SendEvent() where TEvent : new() => mTypeEventSystem.Send(); - - public void SendEvent(TEvent e) => mTypeEventSystem.Send(e); - - public IUnRegister RegisterEvent(Action onEvent) => mTypeEventSystem.Register(onEvent); - - public void UnRegisterEvent(Action onEvent) => mTypeEventSystem.UnRegister(onEvent); - } - - public interface IOnEvent - { - void OnEvent(T e); - } - - public static class OnGlobalEventExtension - { - public static IUnRegister RegisterEvent(this IOnEvent self) where T : struct => - TypeEventSystem.Global.Register(self.OnEvent); - - public static void UnRegisterEvent(this IOnEvent self) where T : struct => - TypeEventSystem.Global.UnRegister(self.OnEvent); - } - - #endregion - - #region Controller - - public interface IController : IBelongToArchitecture, ICanSendCommand, ICanGetSystem, ICanGetModel, - ICanRegisterEvent, ICanSendQuery, ICanGetUtility - { - } - - #endregion - - #region System - - public interface ISystem : IBelongToArchitecture, ICanSetArchitecture, ICanGetModel, ICanGetUtility, - ICanRegisterEvent, ICanSendEvent, ICanGetSystem, ICanInit - { - } - - public abstract class AbstractSystem : ISystem - { - private IArchitecture mArchitecture; - - IArchitecture IBelongToArchitecture.GetArchitecture() => mArchitecture; - - void ICanSetArchitecture.SetArchitecture(IArchitecture architecture) => mArchitecture = architecture; - - public bool Initialized { get; set; } - void ICanInit.Init() => OnInit(); - - public void Deinit() => OnDeinit(); - - protected virtual void OnDeinit() - { - } - - protected abstract void OnInit(); - } - - #endregion - - #region Model - - public interface IModel : IBelongToArchitecture, ICanSetArchitecture, ICanGetUtility, ICanSendEvent, ICanInit - { - } - - public abstract class AbstractModel : IModel - { - private IArchitecture mArchitecturel; - - IArchitecture IBelongToArchitecture.GetArchitecture() => mArchitecturel; - - void ICanSetArchitecture.SetArchitecture(IArchitecture architecture) => mArchitecturel = architecture; - - public bool Initialized { get; set; } - void ICanInit.Init() => OnInit(); - public void Deinit() => OnDeinit(); - - protected virtual void OnDeinit() - { - } - - protected abstract void OnInit(); - } - - #endregion - - #region Utility - - public interface IUtility - { - } - - #endregion - - #region Command - - public interface ICommand : IBelongToArchitecture, ICanSetArchitecture, ICanGetSystem, ICanGetModel, ICanGetUtility, - ICanSendEvent, ICanSendCommand, ICanSendQuery - { - void Execute(); - } - - public interface ICommand : IBelongToArchitecture, ICanSetArchitecture, ICanGetSystem, ICanGetModel, - ICanGetUtility, - ICanSendEvent, ICanSendCommand, ICanSendQuery - { - TResult Execute(); - } - - public abstract class AbstractCommand : ICommand - { - private IArchitecture mArchitecture; - - IArchitecture IBelongToArchitecture.GetArchitecture() => mArchitecture; - - void ICanSetArchitecture.SetArchitecture(IArchitecture architecture) => mArchitecture = architecture; - - void ICommand.Execute() => OnExecute(); - - protected abstract void OnExecute(); - } - - public abstract class AbstractCommand : ICommand - { - private IArchitecture mArchitecture; - - IArchitecture IBelongToArchitecture.GetArchitecture() => mArchitecture; - - void ICanSetArchitecture.SetArchitecture(IArchitecture architecture) => mArchitecture = architecture; - - TResult ICommand.Execute() => OnExecute(); - - protected abstract TResult OnExecute(); - } - - #endregion - - #region Query - - public interface IQuery : IBelongToArchitecture, ICanSetArchitecture, ICanGetModel, ICanGetSystem, - ICanSendQuery - { - TResult Do(); - } - - public abstract class AbstractQuery : IQuery - { - public T Do() => OnDo(); - - protected abstract T OnDo(); - - - private IArchitecture mArchitecture; - - public IArchitecture GetArchitecture() => mArchitecture; - - public void SetArchitecture(IArchitecture architecture) => mArchitecture = architecture; - } - - #endregion - - #region Rule - - public interface IBelongToArchitecture - { - IArchitecture GetArchitecture(); - } - - public interface ICanSetArchitecture - { - void SetArchitecture(IArchitecture architecture); - } - - public interface ICanGetModel : IBelongToArchitecture - { - } - - public static class CanGetModelExtension - { - public static T GetModel(this ICanGetModel self) where T : class, IModel => - self.GetArchitecture().GetModel(); - } - - public interface ICanGetSystem : IBelongToArchitecture - { - } - - public static class CanGetSystemExtension - { - public static T GetSystem(this ICanGetSystem self) where T : class, ISystem => - self.GetArchitecture().GetSystem(); - } - - public interface ICanGetUtility : IBelongToArchitecture - { - } - - public static class CanGetUtilityExtension - { - public static T GetUtility(this ICanGetUtility self) where T : class, IUtility => - self.GetArchitecture().GetUtility(); - } - - public interface ICanRegisterEvent : IBelongToArchitecture - { - } - - public static class CanRegisterEventExtension - { - public static IUnRegister RegisterEvent(this ICanRegisterEvent self, Action onEvent) => - self.GetArchitecture().RegisterEvent(onEvent); - - public static void UnRegisterEvent(this ICanRegisterEvent self, Action onEvent) => - self.GetArchitecture().UnRegisterEvent(onEvent); - } - - public interface ICanSendCommand : IBelongToArchitecture - { - } - - public static class CanSendCommandExtension - { - public static void SendCommand(this ICanSendCommand self) where T : ICommand, new() => - self.GetArchitecture().SendCommand(new T()); - - public static void SendCommand(this ICanSendCommand self, T command) where T : ICommand => - self.GetArchitecture().SendCommand(command); - - public static TResult SendCommand(this ICanSendCommand self, ICommand command) => - self.GetArchitecture().SendCommand(command); - } - - public interface ICanSendEvent : IBelongToArchitecture - { - } - - public static class CanSendEventExtension - { - public static void SendEvent(this ICanSendEvent self) where T : new() => - self.GetArchitecture().SendEvent(); - - public static void SendEvent(this ICanSendEvent self, T e) => self.GetArchitecture().SendEvent(e); - } - - public interface ICanSendQuery : IBelongToArchitecture - { - } - - public static class CanSendQueryExtension - { - public static TResult SendQuery(this ICanSendQuery self, IQuery query) => - self.GetArchitecture().SendQuery(query); - } - - public interface ICanInit - { - bool Initialized { get; set; } - void Init(); - void Deinit(); - } - - #endregion - - #region TypeEventSystem - - public interface IUnRegister - { - void UnRegister(); - } - - public interface IUnRegisterList - { - List UnregisterList { get; } - } - - public static class IUnRegisterListExtension - { - public static void AddToUnregisterList(this IUnRegister self, IUnRegisterList unRegisterList) => - unRegisterList.UnregisterList.Add(self); - - public static void UnRegisterAll(this IUnRegisterList self) - { - foreach (var unRegister in self.UnregisterList) - { - unRegister.UnRegister(); - } - - self.UnregisterList.Clear(); - } - } - - public struct CustomUnRegister : IUnRegister - { - private Action mOnUnRegister { get; set; } - public CustomUnRegister(Action onUnRegister) => mOnUnRegister = onUnRegister; - - public void UnRegister() - { - mOnUnRegister.Invoke(); - mOnUnRegister = null; - } - } - -#if UNITY_5_6_OR_NEWER - public abstract class UnRegisterTrigger : UnityEngine.MonoBehaviour - { - private readonly HashSet mUnRegisters = new HashSet(); - - public IUnRegister AddUnRegister(IUnRegister unRegister) - { - mUnRegisters.Add(unRegister); - return unRegister; - } - - public void RemoveUnRegister(IUnRegister unRegister) => mUnRegisters.Remove(unRegister); - - public void UnRegister() - { - foreach (var unRegister in mUnRegisters) - { - unRegister.UnRegister(); - } - - mUnRegisters.Clear(); - } - } - - public class UnRegisterOnDestroyTrigger : UnRegisterTrigger - { - private void OnDestroy() - { - UnRegister(); - } - } - - public class UnRegisterOnDisableTrigger : UnRegisterTrigger - { - private void OnDisable() - { - UnRegister(); - } - } - - public class UnRegisterCurrentSceneUnloadedTrigger : UnRegisterTrigger - { - private static UnRegisterCurrentSceneUnloadedTrigger mDefault; - - public static UnRegisterCurrentSceneUnloadedTrigger Get - { - get - { - if (!mDefault) - { - mDefault = new GameObject("UnRegisterCurrentSceneUnloadedTrigger") - .AddComponent(); - } - - return mDefault; - } - } - - private void Awake() - { - DontDestroyOnLoad(this); - hideFlags = HideFlags.HideInHierarchy; - SceneManager.sceneUnloaded += OnSceneUnloaded; - } - - private void OnDestroy() => SceneManager.sceneUnloaded -= OnSceneUnloaded; - void OnSceneUnloaded(Scene scene) => UnRegister(); - } -#endif - - public static class UnRegisterExtension - { -#if UNITY_5_6_OR_NEWER - - static T GetOrAddComponent(GameObject gameObject) where T : Component - { - var trigger = gameObject.GetComponent(); - - if (!trigger) - { - trigger = gameObject.AddComponent(); - } - - return trigger; - } - - public static IUnRegister UnRegisterWhenGameObjectDestroyed(this IUnRegister unRegister, - UnityEngine.GameObject gameObject) => - GetOrAddComponent(gameObject) - .AddUnRegister(unRegister); - - public static IUnRegister UnRegisterWhenGameObjectDestroyed(this IUnRegister self, T component) - where T : UnityEngine.Component => - self.UnRegisterWhenGameObjectDestroyed(component.gameObject); - - public static IUnRegister UnRegisterWhenDisabled(this IUnRegister self, T component) - where T : UnityEngine.Component => - self.UnRegisterWhenDisabled(component.gameObject); - - public static IUnRegister UnRegisterWhenDisabled(this IUnRegister unRegister, - UnityEngine.GameObject gameObject) => - GetOrAddComponent(gameObject) - .AddUnRegister(unRegister); - - public static IUnRegister UnRegisterWhenCurrentSceneUnloaded(this IUnRegister self) => - UnRegisterCurrentSceneUnloadedTrigger.Get.AddUnRegister(self); -#endif - - -#if GODOT - public static IUnRegister UnRegisterWhenNodeExitTree(this IUnRegister unRegister, Godot.Node node) - { - node.TreeExiting += unRegister.UnRegister; - return unRegister; - } -#endif - } - - public class TypeEventSystem - { - private readonly EasyEvents mEvents = new EasyEvents(); - - public static readonly TypeEventSystem Global = new TypeEventSystem(); - - public void Send() where T : new() => mEvents.GetEvent>()?.Trigger(new T()); - - public void Send(T e) => mEvents.GetEvent>()?.Trigger(e); - - public IUnRegister Register(Action onEvent) => mEvents.GetOrAddEvent>().Register(onEvent); - - public void UnRegister(Action onEvent) - { - var e = mEvents.GetEvent>(); - e?.UnRegister(onEvent); - } - } - - #endregion - - #region IOC - - public class IOCContainer - { - private Dictionary mInstances = new Dictionary(); - - public void Register(T instance) - { - var key = typeof(T); - - if (mInstances.ContainsKey(key)) - { - mInstances[key] = instance; - } - else - { - mInstances.Add(key, instance); - } - } - - public T Get() where T : class - { - var key = typeof(T); - - if (mInstances.TryGetValue(key, out var retInstance)) - { - return retInstance as T; - } - - return null; - } - - public IEnumerable GetInstancesByType() - { - var type = typeof(T); - return mInstances.Values.Where(instance => type.IsInstanceOfType(instance)).Cast(); - } - - public void Clear() => mInstances.Clear(); - } - - #endregion - - #region BindableProperty - - public interface IBindableProperty : IReadonlyBindableProperty - { - new T Value { get; set; } - void SetValueWithoutEvent(T newValue); - } - - public interface IReadonlyBindableProperty : IEasyEvent - { - T Value { get; } - - IUnRegister RegisterWithInitValue(Action action); - void UnRegister(Action onValueChanged); - IUnRegister Register(Action onValueChanged); - } - - public class BindableProperty : IBindableProperty - { - public BindableProperty(T defaultValue = default) => mValue = defaultValue; - - protected T mValue; - - public static Func Comparer { get; set; } = (a, b) => a.Equals(b); - - public BindableProperty WithComparer(Func comparer) - { - Comparer = comparer; - return this; - } - - public T Value - { - get => GetValue(); - set - { - if (value == null && mValue == null) return; - if (value != null && Comparer(value, mValue)) return; - - SetValue(value); - mOnValueChanged.Trigger(value); - } - } - - protected virtual void SetValue(T newValue) => mValue = newValue; - - protected virtual T GetValue() => mValue; - - public void SetValueWithoutEvent(T newValue) => mValue = newValue; - - private EasyEvent mOnValueChanged = new EasyEvent(); - - public IUnRegister Register(Action onValueChanged) - { - return mOnValueChanged.Register(onValueChanged); - } - - public IUnRegister RegisterWithInitValue(Action onValueChanged) - { - onValueChanged(mValue); - return Register(onValueChanged); - } - - public void UnRegister(Action onValueChanged) => mOnValueChanged.UnRegister(onValueChanged); - - IUnRegister IEasyEvent.Register(Action onEvent) - { - return Register(Action); - void Action(T _) => onEvent(); - } - - public override string ToString() => Value.ToString(); - } - - internal class ComparerAutoRegister - { -#if UNITY_5_6_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] - public static void AutoRegister() - { - BindableProperty.Comparer = (a, b) => a == b; - BindableProperty.Comparer = (a, b) => a == b; - BindableProperty.Comparer = (a, b) => a == b; - BindableProperty.Comparer = (a, b) => a == b; - BindableProperty.Comparer = (a, b) => a == b; - BindableProperty.Comparer = (a, b) => a == b; - BindableProperty.Comparer = (a, b) => a == b; - BindableProperty.Comparer = (a, b) => a == b; - BindableProperty.Comparer = (a, b) => a == b; - BindableProperty.Comparer = - (a, b) => a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a; - BindableProperty.Comparer = (a, b) => a == b; - BindableProperty.Comparer = (a, b) => a == b; - BindableProperty.Comparer = (a, b) => a == b; - BindableProperty.Comparer = (a, b) => a == b; - BindableProperty.Comparer = (a, b) => a == b; - BindableProperty.Comparer = (a, b) => a == b; - BindableProperty.Comparer = (a, b) => a.start == b.start && a.length == b.length; - BindableProperty.Comparer = (a, b) => a.Equals(b); - } -#endif - } - - #endregion - - #region EasyEvent - - public interface IEasyEvent - { - IUnRegister Register(Action onEvent); - } - - public class EasyEvent : IEasyEvent - { - private Action mOnEvent = () => { }; - - public IUnRegister Register(Action onEvent) - { - mOnEvent += onEvent; - return new CustomUnRegister(() => { UnRegister(onEvent); }); - } - - public void UnRegister(Action onEvent) => mOnEvent -= onEvent; - - public void Trigger() => mOnEvent?.Invoke(); - } - - public class EasyEvent : IEasyEvent - { - private Action mOnEvent = e => { }; - - public IUnRegister Register(Action onEvent) - { - mOnEvent += onEvent; - return new CustomUnRegister(() => { UnRegister(onEvent); }); - } - - public void UnRegister(Action onEvent) => mOnEvent -= onEvent; - - public void Trigger(T t) => mOnEvent?.Invoke(t); - - IUnRegister IEasyEvent.Register(Action onEvent) - { - return Register(Action); - void Action(T _) => onEvent(); - } - } - - public class EasyEvent : IEasyEvent - { - private Action mOnEvent = (t, k) => { }; - - public IUnRegister Register(Action onEvent) - { - mOnEvent += onEvent; - return new CustomUnRegister(() => { UnRegister(onEvent); }); - } - - public void UnRegister(Action onEvent) => mOnEvent -= onEvent; - - public void Trigger(T t, K k) => mOnEvent?.Invoke(t, k); - - IUnRegister IEasyEvent.Register(Action onEvent) - { - return Register(Action); - void Action(T _, K __) => onEvent(); - } - } - - public class EasyEvent : IEasyEvent - { - private Action mOnEvent = (t, k, s) => { }; - - public IUnRegister Register(Action onEvent) - { - mOnEvent += onEvent; - return new CustomUnRegister(() => { UnRegister(onEvent); }); - } - - public void UnRegister(Action onEvent) => mOnEvent -= onEvent; - - public void Trigger(T t, K k, S s) => mOnEvent?.Invoke(t, k, s); - - IUnRegister IEasyEvent.Register(Action onEvent) - { - return Register(Action); - void Action(T _, K __, S ___) => onEvent(); - } - } - - public class EasyEvents - { - private static readonly EasyEvents mGlobalEvents = new EasyEvents(); - - public static T Get() where T : IEasyEvent => mGlobalEvents.GetEvent(); - - public static void Register() where T : IEasyEvent, new() => mGlobalEvents.AddEvent(); - - private readonly Dictionary mTypeEvents = new Dictionary(); - - public void AddEvent() where T : IEasyEvent, new() => mTypeEvents.Add(typeof(T), new T()); - - public T GetEvent() where T : IEasyEvent - { - return mTypeEvents.TryGetValue(typeof(T), out var e) ? (T)e : default; - } - - public T GetOrAddEvent() where T : IEasyEvent, new() - { - var eType = typeof(T); - if (mTypeEvents.TryGetValue(eType, out var e)) - { - return (T)e; - } - - var t = new T(); - mTypeEvents.Add(eType, t); - return t; - } - } - - #endregion - - - #region Event Extension - - public class OrEvent : IUnRegisterList - { - public OrEvent Or(IEasyEvent easyEvent) - { - easyEvent.Register(Trigger).AddToUnregisterList(this); - return this; - } - - private Action mOnEvent = () => { }; - - public IUnRegister Register(Action onEvent) - { - mOnEvent += onEvent; - return new CustomUnRegister(() => { UnRegister(onEvent); }); - } - - public void UnRegister(Action onEvent) - { - mOnEvent -= onEvent; - this.UnRegisterAll(); - } - - private void Trigger() => mOnEvent?.Invoke(); - - public List UnregisterList { get; } = new List(); - } - - public static class OrEventExtensions - { - public static OrEvent Or(this IEasyEvent self, IEasyEvent e) => new OrEvent().Or(self).Or(e); - } - - #endregion - -#if UNITY_EDITOR - internal class EditorMenus - { - [UnityEditor.MenuItem("QFramework/Install QFrameworkWithToolKits")] - public static void InstallPackageKit() => UnityEngine.Application.OpenURL("https://qframework.cn/qf"); - } -#endif -} \ No newline at end of file diff --git a/Assets/Plugins/QFramework/Framework/Scripts/QFramework.cs.meta b/Assets/Plugins/QFramework/Framework/Scripts/QFramework.cs.meta deleted file mode 100644 index 254542910..000000000 --- a/Assets/Plugins/QFramework/Framework/Scripts/QFramework.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7a1fba0c3bb80422c82f18ba7b548eda -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/QFramework/Framework/Scripts/link.xml b/Assets/Plugins/QFramework/Framework/Scripts/link.xml deleted file mode 100644 index 712aaa137..000000000 --- a/Assets/Plugins/QFramework/Framework/Scripts/link.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/Assets/Plugins/QFramework/Framework/Scripts/link.xml.meta b/Assets/Plugins/QFramework/Framework/Scripts/link.xml.meta deleted file mode 100644 index 3eaed9744..000000000 --- a/Assets/Plugins/QFramework/Framework/Scripts/link.xml.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 32878c59179e84e84ab2d2132693f8f4 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/Art/ClueBoard.meta b/Assets/Resources/Art/ClueBoard.meta deleted file mode 100644 index 368dd8d4c..000000000 --- a/Assets/Resources/Art/ClueBoard.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: cf640d6fae113ee42b18a6e3d15725e4 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scenes/ExpressFixScene.unity b/Assets/Scenes/ExpressFixScene.unity index 0c4e1ace9..67be65987 100644 --- a/Assets/Scenes/ExpressFixScene.unity +++ b/Assets/Scenes/ExpressFixScene.unity @@ -123,7 +123,7 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} ---- !u!1 &26713700 +--- !u!1 &18238394 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -131,37 +131,37 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 26713701} - - component: {fileID: 26713702} + - component: {fileID: 18238395} + - component: {fileID: 18238396} m_Layer: 0 - m_Name: Dial Plate + m_Name: Dashboard Background m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &26713701 +--- !u!4 &18238395 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 26713700} + m_GameObject: {fileID: 18238394} serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -3.1427, y: -1.9055, z: 0} - m_LocalScale: {x: 0.5606, y: 2.175, z: 1} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0.79, y: 0.36999977, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 863998405} + m_Father: {fileID: 1964529542} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!212 &26713702 +--- !u!212 &18238396 SpriteRenderer: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 26713700} + m_GameObject: {fileID: 18238394} m_Enabled: 1 m_CastShadows: 0 m_ReceiveShadows: 0 @@ -195,13 +195,13 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: 1 - m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3} + m_SortingOrder: 3 + m_Sprite: {fileID: 8330958895188906776, guid: 6de0a74e5b5268b4998dc7a5c687fb95, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 m_FlipY: 0 m_DrawMode: 0 - m_Size: {x: 1, y: 1} + m_Size: {x: 0.43, y: 0.43} m_AdaptiveModeThreshold: 0.5 m_SpriteTileMode: 0 m_WasSpriteAssigned: 1 @@ -534,121 +534,6 @@ Material: - _ShadowColor: {r: 0, g: 0, b: 0, a: 1} - _ShineColor: {r: 1, g: 1, b: 1, a: 1} m_BuildTextureStacks: [] ---- !u!1 &139644182 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 139644183} - - component: {fileID: 139644184} - m_Layer: 0 - m_Name: Dial Plate - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &139644183 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 139644182} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -1, y: -1.9055, z: 0} - m_LocalScale: {x: 0.5606, y: 2.175, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 1691014403} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!212 &139644184 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 139644182} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 0 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 1 - m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 1, y: 1} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 - m_MaskInteraction: 0 - m_SpriteSortPoint: 0 ---- !u!1 &187844037 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 187844038} - m_Layer: 0 - m_Name: Gears Anime - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &187844038 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 187844037} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 1112213369} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &199118572 GameObject: m_ObjectHideFlags: 0 @@ -898,6 +783,90 @@ LineRenderer: m_UseWorldSpace: 1 m_Loop: 0 m_ApplyActiveColorSpace: 1 +--- !u!1 &285714351 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 285714352} + - component: {fileID: 285714353} + m_Layer: 0 + m_Name: Heart Cover + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!4 &285714352 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 285714351} + serializedVersion: 2 + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0.75, y: 0.26000008, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1964529542} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &285714353 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 285714351} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 4 + m_Sprite: {fileID: -8759480157694563036, guid: 6de0a74e5b5268b4998dc7a5c687fb95, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 --- !u!1 &307041274 GameObject: m_ObjectHideFlags: 0 @@ -1010,8 +979,7 @@ Transform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 1015604843} + m_Children: [] m_Father: {fileID: 657112469} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &420163262 @@ -1805,7 +1773,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5489eacced0c49c4ab26308cd50fb917, type: 3} m_Name: m_EditorClassIdentifier: - gearPrefab: {fileID: 5285827322175967477, guid: 1711cb9f16070e0488096c259d4eee3d, type: 3} + runType: 0 --- !u!1 &693951178 GameObject: m_ObjectHideFlags: 0 @@ -2128,13 +2096,14 @@ GameObject: m_Component: - component: {fileID: 863998405} - component: {fileID: 863998406} + - component: {fileID: 863998407} m_Layer: 0 m_Name: Oil Dashboard m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &863998405 Transform: m_ObjectHideFlags: 0 @@ -2144,12 +2113,10 @@ Transform: m_GameObject: {fileID: 863998404} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: -0.844, y: 0.759, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 26713701} - - {fileID: 1313204897} + m_Children: [] m_Father: {fileID: 1112213369} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &863998406 @@ -2164,8 +2131,58 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5f1dc6d4faf506b479900b5b2b534d14, type: 3} m_Name: m_EditorClassIdentifier: - topPosY: -1 - bottomPosY: -2.95 +--- !u!212 &863998407 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 863998404} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 3 + m_Sprite: {fileID: -7430884138805397470, guid: 6de0a74e5b5268b4998dc7a5c687fb95, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 0.08, y: 1.215} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 --- !u!1 &885292091 GameObject: m_ObjectHideFlags: 0 @@ -2416,164 +2433,6 @@ Transform: - {fileID: 30335134} m_Father: {fileID: 1410382569} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &928740851 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 928740852} - - component: {fileID: 928740853} - m_Layer: 0 - m_Name: Min Pointer - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &928740852 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 928740851} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -1.05, y: -2.95, z: 0} - m_LocalScale: {x: 0.4334, y: 0.03467707, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 1691014403} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!212 &928740853 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 928740851} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 0 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 2 - m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3} - m_Color: {r: 0, g: 0.4034543, b: 1, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 1, y: 1} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 - m_MaskInteraction: 0 - m_SpriteSortPoint: 0 ---- !u!1001 &1015604842 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - serializedVersion: 3 - m_TransformParent: {fileID: 360323325} - m_Modifications: - - target: {fileID: 3319742319015225169, guid: 1711cb9f16070e0488096c259d4eee3d, type: 3} - propertyPath: data - value: - objectReference: {fileID: 11400000, guid: 0b31f7a5b65969146ace2f70ffebf57e, type: 2} - - target: {fileID: 5285827322175967477, guid: 1711cb9f16070e0488096c259d4eee3d, type: 3} - propertyPath: m_Name - value: Gear - objectReference: {fileID: 0} - - target: {fileID: 5471826428459579353, guid: 1711cb9f16070e0488096c259d4eee3d, type: 3} - propertyPath: m_LocalPosition.x - value: -4.55 - objectReference: {fileID: 0} - - target: {fileID: 5471826428459579353, guid: 1711cb9f16070e0488096c259d4eee3d, type: 3} - propertyPath: m_LocalPosition.y - value: 0.39 - objectReference: {fileID: 0} - - target: {fileID: 5471826428459579353, guid: 1711cb9f16070e0488096c259d4eee3d, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5471826428459579353, guid: 1711cb9f16070e0488096c259d4eee3d, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 5471826428459579353, guid: 1711cb9f16070e0488096c259d4eee3d, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5471826428459579353, guid: 1711cb9f16070e0488096c259d4eee3d, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5471826428459579353, guid: 1711cb9f16070e0488096c259d4eee3d, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5471826428459579353, guid: 1711cb9f16070e0488096c259d4eee3d, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5471826428459579353, guid: 1711cb9f16070e0488096c259d4eee3d, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5471826428459579353, guid: 1711cb9f16070e0488096c259d4eee3d, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6708275724089666452, guid: 1711cb9f16070e0488096c259d4eee3d, type: 3} - propertyPath: m_SortingLayer - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6708275724089666452, guid: 1711cb9f16070e0488096c259d4eee3d, type: 3} - propertyPath: m_SortingLayerID - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_RemovedGameObjects: [] - m_AddedGameObjects: [] - m_AddedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 1711cb9f16070e0488096c259d4eee3d, type: 3} ---- !u!4 &1015604843 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 5471826428459579353, guid: 1711cb9f16070e0488096c259d4eee3d, type: 3} - m_PrefabInstance: {fileID: 1015604842} - m_PrefabAsset: {fileID: 0} --- !u!1 &1035218747 GameObject: m_ObjectHideFlags: 0 @@ -2911,7 +2770,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &1104267851 Transform: m_ObjectHideFlags: 0 @@ -2961,13 +2820,13 @@ Transform: m_LocalScale: {x: 0.93, y: 0.93, z: 0.93} m_ConstrainProportionsScale: 0 m_Children: + - {fileID: 1964529542} - {fileID: 1691014403} - {fileID: 2019900043} - {fileID: 863998405} - {fileID: 885292092} - {fileID: 1537489913} - {fileID: 551825977} - - {fileID: 187844038} m_Father: {fileID: 1104267851} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!212 &1112213370 @@ -3173,90 +3032,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a2e20b111511460a8f3a151bd470da9d, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!1 &1313204896 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1313204897} - - component: {fileID: 1313204898} - m_Layer: 0 - m_Name: Pointer - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1313204897 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1313204896} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -3.206, y: -2.9411, z: 0} - m_LocalScale: {x: 0.4334, y: 0.03467707, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 863998405} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!212 &1313204898 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1313204896} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 0 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 2 - m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3} - m_Color: {r: 1, g: 0, b: 0, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 1, y: 1} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 - m_MaskInteraction: 0 - m_SpriteSortPoint: 0 --- !u!1 &1410382568 GameObject: m_ObjectHideFlags: 0 @@ -3388,90 +3163,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 14ffdfdc63be167489dc01c0b661c1ac, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!1 &1504845248 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1504845249} - - component: {fileID: 1504845250} - m_Layer: 0 - m_Name: Pointer - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1504845249 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1504845248} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -1.05, y: -2.95, z: 0} - m_LocalScale: {x: 0.4334, y: 0.03467707, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 1691014403} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!212 &1504845250 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1504845248} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 0 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 2 - m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3} - m_Color: {r: 1, g: 0, b: 0, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 1, y: 1} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 - m_MaskInteraction: 0 - m_SpriteSortPoint: 0 --- !u!1 &1537489912 GameObject: m_ObjectHideFlags: 0 @@ -3656,13 +3347,14 @@ GameObject: m_Component: - component: {fileID: 1691014403} - component: {fileID: 1691014404} + - component: {fileID: 1691014405} m_Layer: 0 m_Name: Air Dashboard m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &1691014403 Transform: m_ObjectHideFlags: 0 @@ -3672,14 +3364,10 @@ Transform: m_GameObject: {fileID: 1691014402} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: -0.427, y: 0.761, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 139644183} - - {fileID: 1504845249} - - {fileID: 2079041947} - - {fileID: 928740852} + m_Children: [] m_Father: {fileID: 1112213369} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1691014404 @@ -3696,6 +3384,58 @@ MonoBehaviour: m_EditorClassIdentifier: topPosY: -1 bottomPosY: -2.95 +--- !u!212 &1691014405 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1691014402} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 4 + m_Sprite: {fileID: 3452926339856333695, guid: 6de0a74e5b5268b4998dc7a5c687fb95, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 0.08, y: 1.215} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 --- !u!1 &1732205054 GameObject: m_ObjectHideFlags: 0 @@ -3712,7 +3452,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &1732205055 Transform: m_ObjectHideFlags: 0 @@ -3895,7 +3635,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &1814664091 Transform: m_ObjectHideFlags: 0 @@ -4529,6 +4269,39 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!1 &1964529541 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1964529542} + m_Layer: 0 + m_Name: Moveable Parts + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1964529542 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1964529541} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 285714352} + - {fileID: 18238395} + m_Father: {fileID: 1112213369} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &2000626642 GameObject: m_ObjectHideFlags: 0 @@ -4849,90 +4622,6 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 ---- !u!1 &2079041946 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2079041947} - - component: {fileID: 2079041948} - m_Layer: 0 - m_Name: Max Pointer - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &2079041947 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2079041946} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -1.05, y: -2.95, z: 0} - m_LocalScale: {x: 0.4334, y: 0.03467707, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 1691014403} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!212 &2079041948 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2079041946} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 0 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 2 - m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3} - m_Color: {r: 0, g: 0.5306525, b: 1, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 1, y: 1} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 - m_MaskInteraction: 0 - m_SpriteSortPoint: 0 --- !u!1 &2133683124 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Framework/Config/ConfigUtil.cs b/Assets/Scripts/Framework/Config/ConfigUtil.cs index ee5fd2c39..470685564 100644 --- a/Assets/Scripts/Framework/Config/ConfigUtil.cs +++ b/Assets/Scripts/Framework/Config/ConfigUtil.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using Newtonsoft.Json.Serialization; using UnityEngine; namespace AibisDream.Kit @@ -69,5 +70,9 @@ namespace AibisDream.Kit { return _baseConfigDic.TryGetValue(key, out value); } + + // public bool TryToLoadConfig(string path, string key, out T res) + // { + // } } } \ No newline at end of file diff --git a/Assets/Scripts/Framework/Core/AppCenter.cs b/Assets/Scripts/Framework/Core/AppCenter.cs new file mode 100644 index 000000000..77e9c60b8 --- /dev/null +++ b/Assets/Scripts/Framework/Core/AppCenter.cs @@ -0,0 +1,9 @@ +namespace Framework.Core +{ + public enum RunType + { + Editor, + Test, + Pro + } +} \ No newline at end of file diff --git a/Assets/Scripts/Framework/Core/AppCenter.cs.meta b/Assets/Scripts/Framework/Core/AppCenter.cs.meta new file mode 100644 index 000000000..2bc110a9e --- /dev/null +++ b/Assets/Scripts/Framework/Core/AppCenter.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a1e14444d3ce49aabda2476eefb6e20f +timeCreated: 1732360239 \ No newline at end of file diff --git a/Assets/Scripts/Framework/Core/Core.cs b/Assets/Scripts/Framework/Core/Core.cs index 7645af3ba..f2548c4ac 100644 --- a/Assets/Scripts/Framework/Core/Core.cs +++ b/Assets/Scripts/Framework/Core/Core.cs @@ -1,37 +1,83 @@ using System; using System.Collections.Generic; -using MeadowGames.UINodeConnect4.GraphicRenderer; +using System.Linq; +using Newtonsoft.Json; -namespace Framework.Core +namespace AibisDream.Framework { public interface IModule { void Init(); void Enable(); void Disable(); - void End(); + void Deinit(); + } + + public interface ISystem + { + void Init(); + void Enable(); + void Disable(); + void Deinit(); } public interface IData { - void SaveData(); - void LoadData(); } - public interface IConfig + public static class DataExtension { - void SaveConfig(); - void LoadConfig(); + public static void Save(this IData data) + { + string json = JsonConvert.SerializeObject(data, Formatting.Indented); + } + + public static void Load(this IData data) + { + + } + } + + #region IOC容器 + + public class IOCContainer + { + private readonly Dictionary _instances = new Dictionary(); + + public void Register(T instance) + { + var key = typeof(T); + + if (_instances.ContainsKey(key)) + { + _instances[key] = instance; + } + else + { + _instances.Add(key, instance); + } + } + + public T Get() where T : class + { + var key = typeof(T); + + if (_instances.TryGetValue(key, out var retInstance)) + { + return retInstance as T; + } + + return null; + } + + public IEnumerable GetInstancesByType() + { + var type = typeof(T); + return _instances.Values.Where(instance => type.IsInstanceOfType(instance)).Cast(); + } + + public void Clear() => _instances.Clear(); } - public interface ISystem : IModule, IConfig, IData - { - } - - public class IocContainer - { - private Dictionary _container; - - public void Register() {} - } + #endregion } \ No newline at end of file diff --git a/Assets/Scripts/Framework/Core/UnityTool.cs b/Assets/Scripts/Framework/Core/UnityTool.cs index b584affe0..56ed6cae4 100644 --- a/Assets/Scripts/Framework/Core/UnityTool.cs +++ b/Assets/Scripts/Framework/Core/UnityTool.cs @@ -10,6 +10,7 @@ namespace Framework.Core { public readonly string goName; public readonly bool getChild; + /// /// 查找游戏物体组件的特性 /// @@ -17,13 +18,20 @@ namespace Framework.Core /// /// true => 查找对应名字对象的下一级子物体 通常名字为父物体名字 类型为子物体 /// false => 查找对应名字的对象 通常会将类型和名字对应 - public FindComponentAttribute(string goName, bool getChild = true) + public FindComponentAttribute(string goName = null, bool getChild = true) { this.goName = goName; this.getChild = getChild; } } - + + [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] + public class FindComponentsInChildrenAttribute : Attribute + { + /// 空类 + /// 直接获取下层所有组件 + } + public static class UnityTool { /// @@ -32,47 +40,91 @@ namespace Framework.Core /// public static void FindComponents(this Component mono) { - Dictionary dic = null; + Dictionary dic = new(); var flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance; foreach (var field in mono.GetType().GetFields(flags)) { - var attribute = field.GetCustomAttribute(); + Attribute attribute = GetFindCompAttribute(field); if (attribute == null) continue; - dic ??= new Dictionary(); + Type type = field.FieldType; - if (!dic.TryGetValue(type, out var components)) + var components = GetComponentsByType(mono, type, dic); + + switch (attribute) { - components = mono.GetComponentsInChildren(type, true); - if (components == null || components.Length == 0) - { -#if UNITY_EDITOR - Debug.Log($"无法找到{type}对象"); -#endif - continue; - } - dic.Add(type, components); + case FindComponentAttribute componentAttribute: + HandleFindComponent(mono, field, components, componentAttribute); + break; + case FindComponentsInChildrenAttribute: + HandleFindComponentsInChildren(mono, field, components); + break; } - if (attribute.getChild) + } + } + + private static Attribute GetFindCompAttribute(FieldInfo field) + { + var attr1 = field.GetCustomAttribute(); + if (attr1 != null) + { + return attr1; + } + + var attr2 = field.GetCustomAttribute(); + return attr2; + } + + private static void HandleFindComponent(Component mono, FieldInfo field, Component[] components, + FindComponentAttribute attribute) + { + if (string.IsNullOrEmpty(attribute.goName)) + { + field.SetValue(mono, components[0]); + return; + } + + if (attribute.getChild) + { + foreach (var component in components) { - foreach (var component in components) + if (component.transform.parent.name == attribute.goName) { - if (component.transform.parent.name == attribute.goName) - { - field.SetValue(mono, component); - break; - } - } - } - else - { - foreach (var component in components) - { - if (component.name != attribute.goName) continue; field.SetValue(mono, component); break; } } } + else + { + foreach (var component in components) + { + if (component.name != attribute.goName) continue; + field.SetValue(mono, component); + break; + } + } + } + + private static void HandleFindComponentsInChildren(Component mono, FieldInfo field, Component[] components) + { + field.SetValue(mono, components); + } + + private static Component[] GetComponentsByType(Component mono, Type type, Dictionary dic) + { + if (dic.TryGetValue(type, out var components)) return components; + + components = mono.GetComponentsInChildren(type, true); + if (components == null || components.Length == 0) + { +#if UNITY_EDITOR + Debug.Log($"无法找到{type}对象"); +#endif + return null; + } + + dic.Add(type, components); + return components; } } } \ No newline at end of file diff --git a/Assets/Scripts/Framework/IocContainer.cs b/Assets/Scripts/Framework/IocContainer.cs deleted file mode 100644 index 5b87951b2..000000000 --- a/Assets/Scripts/Framework/IocContainer.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace AibisDream.Framework -{ - public class IocContainer - { - private readonly Dictionary _container = new(); - - public void Register(T instance) - { - var key = typeof(T); - - if (_container.ContainsKey(key)) - { - _container[key] = instance; - } - else - { - _container.Add(key, instance); - } - } - - public T Get() where T : class - { - var key = typeof(T); - - if (_container.TryGetValue(key, out var retInstance)) - { - return retInstance as T; - } - - return null; - } - - public IEnumerable GetInstancesByType() - { - var type = typeof(T); - return _container.Values.Where(instance => type.IsInstanceOfType(instance)).Cast(); - } - - public void Clear() => _container.Clear(); - } - - public static class IocTools - { - private static readonly IocContainer IocContainer = new(); - - public static void RegisterIoc(this object self, T instance) - { - IocContainer.Register(instance); - } - - public static T GetIoc(this object self) where T : class - { - return IocContainer.Get(); - } - - public static IEnumerable GetIocInstancesByType() - { - return IocContainer.GetInstancesByType(); - } - - public static void ClearIoc() - { - IocContainer.Clear(); - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/Framework/IocContainer.cs.meta b/Assets/Scripts/Framework/IocContainer.cs.meta deleted file mode 100644 index b29e68f1a..000000000 --- a/Assets/Scripts/Framework/IocContainer.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: e3900bea9d184aa0b42e5a151b931571 -timeCreated: 1731417783 \ No newline at end of file diff --git a/Assets/Scripts/Framework/Moveable.meta b/Assets/Scripts/Framework/Moveable.meta new file mode 100644 index 000000000..0d6800e14 --- /dev/null +++ b/Assets/Scripts/Framework/Moveable.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9a9cfd121f9a45c0a72e5f056e7ce308 +timeCreated: 1732358305 \ No newline at end of file diff --git a/Assets/Scripts/MiniGame/Gear/IMoveable.cs b/Assets/Scripts/Framework/Moveable/IMoveable.cs similarity index 87% rename from Assets/Scripts/MiniGame/Gear/IMoveable.cs rename to Assets/Scripts/Framework/Moveable/IMoveable.cs index 0953ff515..463c0e36c 100644 --- a/Assets/Scripts/MiniGame/Gear/IMoveable.cs +++ b/Assets/Scripts/Framework/Moveable/IMoveable.cs @@ -2,7 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -namespace AibisDream +namespace AibisDream.Framework { public interface IMoveable { diff --git a/Assets/Scripts/MiniGame/Gear/IMoveable.cs.meta b/Assets/Scripts/Framework/Moveable/IMoveable.cs.meta similarity index 100% rename from Assets/Scripts/MiniGame/Gear/IMoveable.cs.meta rename to Assets/Scripts/Framework/Moveable/IMoveable.cs.meta diff --git a/Assets/Scripts/Framework/Moveable/MoveableSystem.cs b/Assets/Scripts/Framework/Moveable/MoveableSystem.cs new file mode 100644 index 000000000..b89bbd2dc --- /dev/null +++ b/Assets/Scripts/Framework/Moveable/MoveableSystem.cs @@ -0,0 +1,79 @@ +using System; +using UnityEngine; + +namespace AibisDream.Framework +{ + public class MoveableSystem : MonoBehaviour + { + private bool _isDragging; + private IMoveable _dragObj; + private Vector3 _offset; + private Camera _camera; + + private void Start() + { + _camera = Camera.main; + } + + private void Update() + { + // 鼠标按下 + if (Input.GetMouseButtonDown(0)) + { + OnMouseClickDown(); + } + + // 鼠标按住 + if (Input.GetMouseButton(0) && _isDragging) + { + OnMouseHolding(); + } + + // 鼠标松开 + if (Input.GetMouseButtonUp(0)) + { + OnMouseClickUp(); + } + } + + private void OnMouseClickDown() + { + // 按下时发出检查射线 + Ray ray = _camera.ScreenPointToRay(Input.mousePosition); + RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction); + + // 检测命中的物体 + if (hit.collider && hit.collider.CompareTag("Moveable")) + { + _dragObj = hit.collider.gameObject.GetComponent(); + if (_dragObj == null) return; + + _dragObj.StartMove(); + _offset = hit.collider.transform.position - GetMouseAsWorldPoint(); + + _isDragging = true; + } + } + + private void OnMouseHolding() + { + _dragObj.Move(GetMouseAsWorldPoint() + _offset); + } + + private void OnMouseClickUp() + { + if (!_isDragging) return; + + _dragObj?.StopMove(); + _dragObj = null; + _isDragging = false; + } + + private Vector3 GetMouseAsWorldPoint() + { + Vector3 mousePoint = Input.mousePosition; + mousePoint.z = _camera.nearClipPlane; + return _camera.ScreenToWorldPoint(mousePoint); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Framework/Moveable/MoveableSystem.cs.meta b/Assets/Scripts/Framework/Moveable/MoveableSystem.cs.meta new file mode 100644 index 000000000..0268f4b0c --- /dev/null +++ b/Assets/Scripts/Framework/Moveable/MoveableSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5d755460ba0142f39c5677d8f948c777 +timeCreated: 1732358554 \ No newline at end of file diff --git a/Assets/Scripts/MiniGame/Engine/AirDashboard.cs b/Assets/Scripts/MiniGame/Engine/AirDashboard.cs index 2f78a904c..65725f81d 100644 --- a/Assets/Scripts/MiniGame/Engine/AirDashboard.cs +++ b/Assets/Scripts/MiniGame/Engine/AirDashboard.cs @@ -1,30 +1,24 @@ using System.Collections; using System.Collections.Generic; +using DG.Tweening; +using Framework.Core; using UnityEngine; namespace AibisDream { public class AirDashboard : Dashboard { - private Transform _pointer; - private Transform _minPointer; - private Transform _maxPointer; + [FindComponent("Pointer")] private Transform _pointer; + [FindComponent("Min Pointer")] private Transform _minPointer; + [FindComponent("Max Pointer")] private Transform _maxPointer; [SerializeField] private float topPosY; [SerializeField] private float bottomPosY; - - protected override void OnStart() - { - _pointer = transform.Find("Pointer"); - _maxPointer = transform.Find("Max Pointer"); - _minPointer = transform.Find("Min Pointer"); - } protected override void UpdateDashboard(EngineData data) { // 气门 - var targetPosY = (topPosY - bottomPosY) * data.curAir + bottomPosY; - _pointer.position = new Vector3(_pointer.position.x, targetPosY, _pointer.position.z); + _pointer.DOScaleY(data.curAir, Time.deltaTime); // 气门上下限 var minPosY = (topPosY - bottomPosY) * data.curAirMin + bottomPosY; diff --git a/Assets/Scripts/MiniGame/Engine/Dashboard.cs b/Assets/Scripts/MiniGame/Engine/Dashboard.cs index 65b1e8307..8a910d03b 100644 --- a/Assets/Scripts/MiniGame/Engine/Dashboard.cs +++ b/Assets/Scripts/MiniGame/Engine/Dashboard.cs @@ -1,3 +1,4 @@ +using Framework.Core; using UnityEngine; namespace AibisDream @@ -9,6 +10,7 @@ namespace AibisDream private void Awake() { engineSystem = transform.parent.GetComponent(); + this.FindComponents(); OnStart(); } diff --git a/Assets/Scripts/MiniGame/Engine/OilDashboard.cs b/Assets/Scripts/MiniGame/Engine/OilDashboard.cs index d83a1a704..fc0953747 100644 --- a/Assets/Scripts/MiniGame/Engine/OilDashboard.cs +++ b/Assets/Scripts/MiniGame/Engine/OilDashboard.cs @@ -1,25 +1,13 @@ -using System.Collections; -using System.Collections.Generic; +using DG.Tweening; using UnityEngine; namespace AibisDream { public class OilDashBoard : Dashboard { - private Transform _pointer; - - [SerializeField] private float topPosY; - [SerializeField] private float bottomPosY; - - protected override void OnStart() - { - _pointer = transform.Find("Pointer"); - } - protected override void UpdateDashboard(EngineData data) { - var targetPosY = (topPosY - bottomPosY) * data.curOil + bottomPosY; - _pointer.position = new Vector3(_pointer.position.x, targetPosY, _pointer.position.z); + transform.DOScaleY(data.curOil, Time.deltaTime); } } } diff --git a/Assets/Scripts/MiniGame/Gear/Gear.cs b/Assets/Scripts/MiniGame/Gear/Gear.cs index f02626522..6009bb424 100644 --- a/Assets/Scripts/MiniGame/Gear/Gear.cs +++ b/Assets/Scripts/MiniGame/Gear/Gear.cs @@ -1,3 +1,4 @@ +using AibisDream.Framework; using DG.Tweening; using UnityEngine; @@ -10,7 +11,6 @@ namespace AibisDream public GearModel Data { - get => data; set { data = value; diff --git a/Assets/Scripts/MiniGame/Gear/GearController.cs b/Assets/Scripts/MiniGame/Gear/GearController.cs index f219f4ef9..3715b1924 100644 --- a/Assets/Scripts/MiniGame/Gear/GearController.cs +++ b/Assets/Scripts/MiniGame/Gear/GearController.cs @@ -1,77 +1,69 @@ +using AibisDream.Framework; +using Framework.Core; using UnityEngine; namespace AibisDream { - public class GearController : MonoBehaviour + public class GearController : MonoBehaviour, ISystem { - [SerializeField] private GameObject gearPrefab; + #region 索引 - private ShaftGraph shaftGraph; + private GameObject _gearPrefab; + [FindComponentsInChildren] private Shaft[] _shafts; + [FindComponentsInChildren] private Gear[] _gears; - private Shaft[] shafts; - - private Vector3 offset; // 鼠标点击位置与物体pos偏移量 - - private Gear draggingGear; + #endregion + + private ShaftGraph _shaftGraph; + private GearSysTemLevelData _levelData; + public RunType runType; + private void Awake() { - shafts = GetComponentsInChildren(); + Init(); } private void OnEnable() { - shaftGraph = new ShaftGraph(shafts); + Enable(); } private void OnDisable() { - shaftGraph = null; + Disable(); } - private void Update() + #region 生命周期管理 + + public void Init() { - // 鼠标按下 - if (Input.GetMouseButtonDown(0)) - { - OnMouseClickDown(); - } - - // 鼠标拖动 - if (Input.GetMouseButton(0) && draggingGear) - { - draggingGear.Move(GetMouseAsWorldPoint() + offset); - } - - // 鼠标释放 - if (Input.GetMouseButtonUp(0)) // 检查鼠标左键释放 - { - draggingGear?.StopMove(); - - if (draggingGear && draggingGear.targetShaft) - { - shaftGraph.ChangeVertex(draggingGear.targetShaft.GetInstanceID()); - } - - draggingGear = null; - } + this.FindComponents(); + _gearPrefab = Resources.Load("Prefabs/Gear System/Gear"); } - private void OnMouseClickDown() + public void Enable() { - // 按下时发出检查射线 - Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); - RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction); - - // 检测命中的物体 - if (hit.collider && hit.collider.CompareTag("Moveable")) + if (runType == RunType.Editor) { - offset = hit.collider.transform.position - GetMouseAsWorldPoint(); - draggingGear = hit.collider.gameObject.GetComponent(); - draggingGear.StartMove(); + } + + _shaftGraph = new ShaftGraph(_shafts); } + public void Disable() + { + _shaftGraph = null; + } + + public void Deinit() + { + throw new System.NotImplementedException(); + } + + #endregion + /// /// 判断吸附位置 /// @@ -80,16 +72,9 @@ namespace AibisDream /// 能够被吸附的轴 public Shaft CheckClosestShaft(Vector3 pos, float gearRadius) { - return shaftGraph.QuerySnapShaft(pos, gearRadius); + return _shaftGraph.QuerySnapShaft(pos, gearRadius); } - - private Vector3 GetMouseAsWorldPoint() - { - Vector3 mousePoint = Input.mousePosition; - mousePoint.z = Camera.main.nearClipPlane; - return Camera.main.ScreenToWorldPoint(mousePoint); - } - + /// /// 生成齿轮 /// @@ -99,15 +84,40 @@ namespace AibisDream /// 齿轮Obj public GameObject InitGear(Vector3 pos, GearModel gearModel, float speed) { - GameObject gear = Instantiate(gearPrefab, pos, Quaternion.identity); + GameObject gear = Instantiate(_gearPrefab, pos, Quaternion.identity); gear.transform.parent = transform.GetChild(0).transform; gear.GetComponent().Data = gearModel; return gear; } + /// + /// 某个轴上齿轮发生变化时更新临接关系 + /// + /// 轴ID + public void ChangeGraphVertex(int shaftId) + { + _shaftGraph?.ChangeVertex(shaftId); + } + public void Succeed() { Debug.Log("达成目标"); } + + /// + /// 加载关卡配置 + /// + public void LoadLevelData() + { + + } + + /// + /// 保存关卡配置 + /// + public void SaveLevelData() + { + + } } } \ No newline at end of file diff --git a/Assets/Scripts/MiniGame/Gear/GearSystemConfig.cs b/Assets/Scripts/MiniGame/Gear/GearSystemConfig.cs new file mode 100644 index 000000000..1a3cda8a0 --- /dev/null +++ b/Assets/Scripts/MiniGame/Gear/GearSystemConfig.cs @@ -0,0 +1,40 @@ +using System; +using UnityEngine; + +namespace AibisDream +{ + [Serializable] + public class GearSysTemLevelData + { + public GearLevelData[] gearLevelDataArray; + public ShaftLevelData[] shaftLevelDataArray; + } + + [Serializable] + public class GearLevelData + { + public const string GearPicPath = "Art/Fix/Stone"; + + public Vector3 gearPos; + public float radius; + public string gearPic; + + public Sprite GearSprite => Resources.Load($"{GearPicPath}/{gearPic}"); + } + + [Serializable] + public class ShaftLevelData + { + public int id; + public ShaftType shaftType; + // 初始角速度(仅Driver有) + public float initialSpeed; + // 目标角速度(仅Target有) + public float targetSpeed; + + // 初始齿轮情况(Driver, Target, Constant必须有,Pluggable不一定) + public bool hasChildGear; + public float radius; + public string gearPic; + } +} \ No newline at end of file diff --git a/Assets/Scripts/MiniGame/Gear/GearSystemConfig.cs.meta b/Assets/Scripts/MiniGame/Gear/GearSystemConfig.cs.meta new file mode 100644 index 000000000..51b66b84d --- /dev/null +++ b/Assets/Scripts/MiniGame/Gear/GearSystemConfig.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1f588bece13144969fb1eb88bed44f56 +timeCreated: 1732358007 \ No newline at end of file diff --git a/Assets/Scripts/MiniGame/Gear/Shaft.cs b/Assets/Scripts/MiniGame/Gear/Shaft.cs index 57fd98f2a..1ae153831 100644 --- a/Assets/Scripts/MiniGame/Gear/Shaft.cs +++ b/Assets/Scripts/MiniGame/Gear/Shaft.cs @@ -197,6 +197,7 @@ namespace AibisDream Driver, // 拥有初始速度,没有目标速度,全局仅有一个 Target, // 没有初始速度,有目标速度,全局有多个 Constant, // 没有初始速度,没有目标速度,不可拖动 - Pluggable // 没有初始速度,没有目标速度,可拔插 + Pluggable, // 没有初始速度,没有目标速度,可拔插 + Outside // 放在身体外面的轴,仅用于放置齿轮 } } \ No newline at end of file diff --git a/Assets/Scripts/MiniGame/Gear/ShaftGraph.cs b/Assets/Scripts/MiniGame/Gear/ShaftGraph.cs index 33bc8746e..074820867 100644 --- a/Assets/Scripts/MiniGame/Gear/ShaftGraph.cs +++ b/Assets/Scripts/MiniGame/Gear/ShaftGraph.cs @@ -8,33 +8,29 @@ namespace AibisDream public class ShaftGraph { // 顶点数量 - int vertexSize; - + private readonly int _vertexSize; // 顶点Map - Shaft[] vertexArray; - + private readonly Shaft[] _vertexArray; // 邻接表 - float[,] edgeTable; - + private float[,] _edgeTable; // 遍历记录 - bool[] vertexRecordArray; - + private readonly bool[] _vertexRecordArray; // 动力轴序号 - int rootIdx; + private readonly int _rootIdx; public ShaftGraph(Shaft[] shafts) { // 为轴赋值 - vertexSize = shafts.Length; - vertexRecordArray = new bool[vertexSize]; - vertexArray = shafts; - foreach (var shaft in vertexArray) + _vertexSize = shafts.Length; + _vertexRecordArray = new bool[_vertexSize]; + _vertexArray = shafts; + foreach (var shaft in _vertexArray) { shaft.InitShaft(); } // 寻找唯一的驱动轴序号 - rootIdx = FindDriverIdx(); + _rootIdx = FindDriverIdx(); // 生成边邻接表 GeneEdgeTable(); @@ -44,9 +40,9 @@ namespace AibisDream private int FindDriverIdx() { - for (int i = 0; i < vertexSize; i++) + for (int i = 0; i < _vertexSize; i++) { - if (vertexArray[i].shaftType == ShaftType.Driver) + if (_vertexArray[i].shaftType == ShaftType.Driver) { return i; } @@ -60,22 +56,22 @@ namespace AibisDream /// private void GeneEdgeTable() { - edgeTable = new float[vertexSize, vertexSize]; + _edgeTable = new float[_vertexSize, _vertexSize]; - for (int i = 0; i < vertexSize - 1; i++) + for (int i = 0; i < _vertexSize - 1; i++) { - for (int j = i + 1; j < vertexSize; j++) + for (int j = i + 1; j < _vertexSize; j++) { // 判断两个Shaft是否临接 - if (Shaft.IsShaftConnected(vertexArray[i], vertexArray[j])) + if (Shaft.IsShaftConnected(_vertexArray[i], _vertexArray[j])) { - edgeTable[i, j] = Shaft.CalcAngularVelocityRatio(vertexArray[i], vertexArray[j]); - edgeTable[j, i] = Shaft.CalcAngularVelocityRatio(vertexArray[j], vertexArray[i]); + _edgeTable[i, j] = Shaft.CalcAngularVelocityRatio(_vertexArray[i], _vertexArray[j]); + _edgeTable[j, i] = Shaft.CalcAngularVelocityRatio(_vertexArray[j], _vertexArray[i]); } else { - edgeTable[i, j] = 0; - edgeTable[j, i] = 0; + _edgeTable[i, j] = 0; + _edgeTable[j, i] = 0; } } } @@ -91,7 +87,7 @@ namespace AibisDream int idx = TranInstanceIDToIdx(instanceID); // 更新该节点对应的邻接表 - for (int i = 0; i < vertexSize; i++) + for (int i = 0; i < _vertexSize; i++) { // 遇到自身跳过 if (i == idx) @@ -100,15 +96,15 @@ namespace AibisDream } // 判断两个Shaft是否临接 - if (Shaft.IsShaftConnected(vertexArray[idx], vertexArray[i])) + if (Shaft.IsShaftConnected(_vertexArray[idx], _vertexArray[i])) { - edgeTable[idx, i] = Shaft.CalcAngularVelocityRatio(vertexArray[idx], vertexArray[i]); - edgeTable[i, idx] = Shaft.CalcAngularVelocityRatio(vertexArray[i], vertexArray[idx]); + _edgeTable[idx, i] = Shaft.CalcAngularVelocityRatio(_vertexArray[idx], _vertexArray[i]); + _edgeTable[i, idx] = Shaft.CalcAngularVelocityRatio(_vertexArray[i], _vertexArray[idx]); } else { - edgeTable[idx, i] = 0; - edgeTable[i, idx] = 0; + _edgeTable[idx, i] = 0; + _edgeTable[i, idx] = 0; } } @@ -119,9 +115,9 @@ namespace AibisDream { // 查找对应的序号 int idx = -1; - for (int i = 0; i < vertexSize; i++) + for (int i = 0; i < _vertexSize; i++) { - if (instanceID == vertexArray[i].GetInstanceID()) + if (instanceID == _vertexArray[i].GetInstanceID()) { idx = i; break; @@ -137,12 +133,12 @@ namespace AibisDream public void UpdateSpeed() { // 清除遍历记录 - Array.Clear(vertexRecordArray, 0, vertexSize); + Array.Clear(_vertexRecordArray, 0, _vertexSize); // 从驱动轴开始计算速度 - vertexRecordArray[rootIdx] = true; - UpdateShaftSpeedByIdx(rootIdx); + _vertexRecordArray[_rootIdx] = true; + UpdateShaftSpeedByIdx(_rootIdx); // 更新完速度后统一更新动画 - foreach (var shaft in vertexArray) + foreach (var shaft in _vertexArray) { shaft.UpdateSpeed(); } @@ -151,23 +147,23 @@ namespace AibisDream private void UpdateShaftSpeedByIdx(int idx) { // 已知当前齿轮速度 - float currentSpeed = vertexArray[idx].speed; + float currentSpeed = _vertexArray[idx].speed; - for (int i = 0; i < vertexSize; i++) + for (int i = 0; i < _vertexSize; i++) { // 遍历临接齿轮 - if (i != idx && edgeTable[idx, i] > 0) + if (i != idx && _edgeTable[idx, i] > 0) { // 已遍历过就跳过 - if (vertexRecordArray[i]) + if (_vertexRecordArray[i]) { continue; } // 更新速度 - vertexArray[i].speed = - currentSpeed * edgeTable[idx, i]; + _vertexArray[i].speed = - currentSpeed * _edgeTable[idx, i]; // 已遍历的轴加上标记 - vertexRecordArray[i] = true; + _vertexRecordArray[i] = true; // 继续寻找相邻齿轮 UpdateShaftSpeedByIdx(i); } @@ -182,7 +178,7 @@ namespace AibisDream /// 吸附轴 public Shaft QuerySnapShaft(Vector3 pos, float gearRadius) { - if (vertexArray == null || vertexArray.Length == 0) + if (_vertexArray == null || _vertexArray.Length == 0) { return null; } @@ -190,7 +186,7 @@ namespace AibisDream // 查询距离最近的,可吸附的Shaft Shaft closestShaft = null; float minDistance = -1; - foreach (var vertex in vertexArray) + foreach (var vertex in _vertexArray) { if (vertex.shaftType == ShaftType.Pluggable && !vertex.HasChildGear()) { diff --git a/Assets/Scripts/Utility/JsonUtil.cs b/Assets/Scripts/Utility/JsonUtil.cs new file mode 100644 index 000000000..8573a52a1 --- /dev/null +++ b/Assets/Scripts/Utility/JsonUtil.cs @@ -0,0 +1,43 @@ +using System.IO; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Serialization; +using UnityEngine.Device; + +namespace Utility +{ + public static class JsonUtil + { + // public static T ReadBean(string path, string key) + // { + // // 加载自由结构Json + // string json = File.ReadAllText(path); + // var jObject = JObject.Parse(json); + // jObject.TryGetValue(key); + // } + + /// + /// 按路径加载Json + /// + /// + /// + /// + public static T ReadBean(string path) + { + string json = File.ReadAllText(path); + return JsonConvert.DeserializeObject(json); + } + + /// + /// 按路径加载Json + /// + /// 路径 + /// Bean + /// 目标Bean + public static T[] ReadBeanArray(string path) + { + string json = File.ReadAllText(path); + return JsonConvert.DeserializeObject(json); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Utility/JsonUtil.cs.meta b/Assets/Scripts/Utility/JsonUtil.cs.meta new file mode 100644 index 000000000..c1f3baaa3 --- /dev/null +++ b/Assets/Scripts/Utility/JsonUtil.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1057e13b721749ac9d715da49023320a +timeCreated: 1732363097 \ No newline at end of file