├── .gitignore ├── README.md └── u3d ├── Assets ├── Core.meta ├── Core │ ├── 3D-InputControlAndCameraControl.meta │ ├── 3D-InputControlAndCameraControl │ │ ├── CameraControl.cs │ │ ├── CameraControl.cs.meta │ │ ├── Input3DController.cs │ │ └── Input3DController.cs.meta │ ├── CFile.cs │ ├── CFile.cs.meta │ ├── CMathCurve.cs │ ├── CMathCurve.cs.meta │ ├── CMisc.cs │ ├── CMisc.cs.meta │ ├── CPropertyValue.cs │ ├── CPropertyValue.cs.meta │ ├── CRandom.cs │ ├── CRandom.cs.meta │ ├── CSingleton.cs │ ├── CSingleton.cs.meta │ ├── CSingletonMono.cs │ ├── CSingletonMono.cs.meta │ ├── DebugWrap.cs │ ├── DebugWrap.cs.meta │ ├── Editor.meta │ ├── Editor │ │ ├── ClearMissComponent.cs │ │ ├── ClearMissComponent.cs.meta │ │ ├── FindMissComponent.cs │ │ ├── FindMissComponent.cs.meta │ │ ├── RemoveDebugLog.cs │ │ └── RemoveDebugLog.cs.meta │ ├── GMath.cs │ ├── GMath.cs.meta │ ├── GameStateMachine.cs │ ├── GameStateMachine.cs.meta │ ├── LineMesh.cs │ ├── LineMesh.cs.meta │ ├── LocalNotificationManager.cs │ ├── LocalNotificationManager.cs.meta │ ├── MeshGenerate.meta │ ├── MeshGenerate │ │ ├── MeshCreator.cs │ │ ├── MeshCreator.cs.meta │ │ ├── UILineMesh.cs │ │ └── UILineMesh.cs.meta │ ├── MiniJSON.cs │ ├── MiniJSON.cs.meta │ ├── MixUtils.cs │ ├── MixUtils.cs.meta │ ├── ObjectPool.meta │ ├── ObjectPool │ │ ├── GameObjectPool.cs │ │ ├── GameObjectPool.cs.meta │ │ ├── GameObjectPoolAutoDestroy.cs │ │ ├── GameObjectPoolAutoDestroy.cs.meta │ │ ├── ListPool.cs │ │ ├── ListPool.cs.meta │ │ ├── ObjectPool.cs │ │ └── ObjectPool.cs.meta │ ├── Polar.cs │ ├── Polar.cs.meta │ ├── PrefabLightmapData.cs │ ├── PrefabLightmapData.cs.meta │ ├── SecureNumber.cs │ ├── SecureNumber.cs.meta │ ├── SoundEffect.cs │ ├── SoundEffect.cs.meta │ ├── TextureTileAnimationWholeMesh.cs │ ├── TextureTileAnimationWholeMesh.cs.meta │ ├── TimeConvert.cs │ ├── TimeConvert.cs.meta │ ├── Vector3_Extensions.cs │ ├── Vector3_Extensions.cs.meta │ ├── batchRender.meta │ ├── batchRender │ │ ├── BatchRenderer.cs │ │ ├── BatchRenderer.cs.meta │ │ ├── BatchRendererManager.cs │ │ └── BatchRendererManager.cs.meta │ ├── eppzGeometry.meta │ ├── eppzGeometry │ │ ├── Clipper.cs │ │ ├── Clipper.cs.meta │ │ ├── Edge.cs │ │ ├── Edge.cs.meta │ │ ├── Geometry.cs │ │ ├── Geometry.cs.meta │ │ ├── Polygon.cs │ │ ├── Polygon.cs.meta │ │ ├── Segment.cs │ │ ├── Segment.cs.meta │ │ ├── Vector2.cs │ │ ├── Vector2.cs.meta │ │ ├── Vector3.cs │ │ ├── Vector3.cs.meta │ │ ├── Vertex.cs │ │ └── Vertex.cs.meta │ ├── pathFinder.meta │ ├── pathFinder │ │ ├── IPathFinder.cs │ │ ├── IPathFinder.cs.meta │ │ ├── PathFinder.cs │ │ ├── PathFinder.cs.meta │ │ ├── PathFinderFast.cs │ │ ├── PathFinderFast.cs.meta │ │ ├── PathManager.cs │ │ ├── PathManager.cs.meta │ │ ├── PathObject.cs │ │ ├── PathObject.cs.meta │ │ ├── PerformanceWatcher.cs │ │ ├── PerformanceWatcher.cs.meta │ │ ├── Point.cs │ │ ├── Point.cs.meta │ │ ├── PriorityQueueB.cs │ │ ├── PriorityQueueB.cs.meta │ │ ├── PriorityQueueC.cs │ │ └── PriorityQueueC.cs.meta │ ├── sort.meta │ └── sort │ │ ├── CQuickSort.cs │ │ ├── CQuickSort.cs.meta │ │ ├── DictionaryInt.cs │ │ ├── DictionaryInt.cs.meta │ │ ├── DictionarySort.cs │ │ ├── DictionarySort.cs.meta │ │ ├── DictionaryStr.cs │ │ ├── DictionaryStr.cs.meta │ │ ├── Heap.cs │ │ └── Heap.cs.meta ├── Example.meta ├── Example │ ├── 3D-InputControlAndCameraControl.meta │ ├── 3D-InputControlAndCameraControl │ │ ├── example.unity │ │ └── example.unity.meta │ ├── SoundEffect.meta │ ├── SoundEffect │ │ ├── Resources.meta │ │ ├── Resources │ │ │ ├── sound.meta │ │ │ └── sound │ │ │ │ ├── Acquire_Quest.mp3 │ │ │ │ ├── Acquire_Quest.mp3.meta │ │ │ │ ├── Master Menu Theme.mp3 │ │ │ │ └── Master Menu Theme.mp3.meta │ │ ├── SoundTest.cs │ │ ├── SoundTest.cs.meta │ │ ├── sound.unity │ │ └── sound.unity.meta │ ├── sort.meta │ └── sort │ │ ├── example-sort.unity │ │ ├── example-sort.unity.meta │ │ ├── example_srot.cs │ │ └── example_srot.cs.meta ├── Plugins.meta ├── Plugins │ ├── Android.meta │ └── Android │ │ ├── libs.meta │ │ └── libs │ │ ├── DeviceIDLib.jar │ │ ├── DeviceIDLib.jar.meta │ │ ├── PushLib.jar │ │ ├── PushLib.jar.meta │ │ ├── glb.zip │ │ └── glb.zip.meta ├── Scripts.meta └── Scripts │ └── .gitkeep ├── Logs └── Packages-Update.log ├── Packages └── manifest.json └── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityConnectSettings.asset └── VFXManager.asset /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | u3d/Library 3 | u3d/Temp 4 | u3d/obj 5 | u3d/*.pidb 6 | u3d/*.unityproj 7 | u3d/*.csproj 8 | u3d/*.sln 9 | u3d/*.userprefs 10 | u3d/Assets/StreamingAssets/build_info.txt* 11 | *.o 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Unity3D Game Develop Util 2 | =========== 3 | 4 | ### Welcome to my blog : http://www.luzexi.com 5 | 6 | ### Use Unity2018 version 7 | 8 | Unity3D Util library 9 | 10 | 3D-InputControlAndCameraControl: 3D输入事件构建,与摄像头拖动,渲染,缩放 11 | 12 | batchRender : 实时动态合并模型Mesh 13 | 14 | Editor : 编辑工具 15 | 16 | ClearMissComponent.cs : 清除丢失的脚本 17 | 18 | FindMissComponent.cs : 找到丢失的脚本 19 | 20 | RemoveDebugLog.cs : 移除Debug.Log打印日志语句 21 | 22 | MeshGenerte : 程序Mesh构建 23 | 24 | UILineMesh.cs : UI 连续线条mesh构建 25 | 26 | MeshCreator.cs : 3D 线条Mesh构建, 3D 方块Mesh构建, 方格Mesh构建 27 | 28 | ObjectPool : 对象池 29 | 30 | GameObjectPool.cs : GameObject对象池 31 | 32 | ListPool.cs : 列表对象池 33 | 34 | ObjectPool.cs : 对象池基类 35 | 36 | pathFinder : A星寻路算法 37 | 38 | sort : 排序算法 39 | 40 | DictionaryStr.cs : string为Key的字典数据结构,用快排构建 41 | 42 | DictionaryInt.cs : Int为Key的字典数据结构,用快排构建 43 | 44 | CQuickSort.cs : 快排 + 二分查找 + 查找插入点 45 | 46 | Heap.cs : 二叉堆,最小和最大堆都可。适用于搭建型数据结构 47 | 48 | CFile.cs : 文件操作 49 | 50 | CMathCurve.cs : 数学曲线 51 | 52 | CPropertyValue : 解决精度问题,未完成 53 | 54 | CRandom.cs : 在做老虎机游戏时写的赌博概率随机 55 | 56 | CSingleton.cs : 单例,以及清空所有单例的接口类 57 | 58 | CSingletonMono.cs : Mono单例,以及清空所有单例的接口类 59 | 60 | DebugWrap.cs : Debug封装 61 | 62 | GameStateMachine.cs : 状态机封装 63 | 64 | GMath.cs : Graphic math 图形学计算工具 65 | 66 | LineMesh.cs : 画线工具 67 | 68 | MiniJSON.cs : 常用Json解析类 69 | 70 | MixUtils.cs : 常用零散的方法 71 | 72 | getDeviceUniqueId(),获取设备唯一ID 73 | 74 | GetAndroidContext(),获取安卓当前运行窗口 75 | 76 | GetSavePath(),获取有写入权限的文件夹地址 77 | 78 | GetString(),通过二进制获取字符串 79 | 80 | GetMd5Hash(),MD5某个字符串或二进制数据 81 | 82 | Polar.cs : 球面曲线运动轨迹 83 | 84 | PrefabLightmapData : 烘培模型动态加载 85 | 86 | SecureNumber.cs : 数字在内存中加密 87 | 88 | SoundEffect.cs : 声音组件,播放音效,播放背景音乐。 89 | 90 | TextureTileAnimationWholeMesh.cs : 利用图集排列的贴图精灵动画 91 | 92 | TimeConvert.cs : 时间转换 93 | 94 | Vector3_Extensions.cs : Vector3的扩展 95 | -------------------------------------------------------------------------------- /u3d/Assets/Core.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f1e0d2f39db349c79a2ad2933dbf40c 3 | folderAsset: yes 4 | timeCreated: 1536472189 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /u3d/Assets/Core/3D-InputControlAndCameraControl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 13d4cf21a17671d4fb41e96ee789e590 3 | folderAsset: yes 4 | timeCreated: 1536636287 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /u3d/Assets/Core/3D-InputControlAndCameraControl/CameraControl.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b1f0a97773000d4d8721486396b8751 3 | timeCreated: 1536636287 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/3D-InputControlAndCameraControl/Input3DController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 964d351091a751b4f9984e4c682ac164 3 | timeCreated: 1536644818 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/CFile.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | 7 | 8 | //file tool 9 | public class CFile 10 | { 11 | //get files by dir 12 | public string[] GetFiles(string dir , string param = "*") 13 | { 14 | if(string.IsNullOrEmpty(dir)) return null; 15 | 16 | DirectoryInfo info = new DirectoryInfo(dir); 17 | FileInfo[] fileInfos = info.GetFiles(param , SearchOption.AllDirectories); 18 | string[] filenames = new string[fileInfos.Length]; 19 | for(int i = 0 ; i ("getUniqueId"); 24 | #elif UNITY_IPHONE 25 | sDeviceId = SystemInfo.deviceUniqueIdentifier; 26 | #endif 27 | return sDeviceId; 28 | } 29 | 30 | public static string GetPersistentDataPath() 31 | { 32 | if (string.IsNullOrEmpty(s_persistentDataPath)) 33 | { 34 | if (string.IsNullOrEmpty(UnityEngine.Application.persistentDataPath)) 35 | { 36 | #if UNITY_ANDROID 37 | s_persistentDataPath = InternalGetPersistentDataPath(); 38 | #endif 39 | } 40 | else 41 | { 42 | s_persistentDataPath = UnityEngine.Application.persistentDataPath; 43 | } 44 | } 45 | return s_persistentDataPath; 46 | } 47 | 48 | #if UNITY_ANDROID 49 | private static string InternalGetPersistentDataPath() 50 | { 51 | string path = ""; 52 | try 53 | { 54 | IntPtr obj_context = AndroidJNI.FindClass("android.os.Environment"); 55 | IntPtr method_getExternalStorageDirectory = AndroidJNIHelper.GetMethodID(obj_context, "getExternalStorageDirectory", "()Ljava/io/File;", true); 56 | IntPtr file = AndroidJNI.CallStaticObjectMethod(obj_context, method_getExternalStorageDirectory, new jvalue[0]); 57 | IntPtr obj_file = AndroidJNI.FindClass("java/io/File"); 58 | IntPtr method_getAbsolutePath = AndroidJNIHelper.GetMethodID(obj_file, "getAbsolutePath", "()Ljava/lang/String;"); 59 | 60 | path = AndroidJNI.CallStringMethod(file, method_getAbsolutePath, new jvalue[0]); 61 | 62 | if (path != null) 63 | { 64 | path += "/Android/data/" + GetPackageName() + "/files"; 65 | } 66 | else 67 | { 68 | path = ""; 69 | } 70 | } 71 | catch (Exception e) 72 | { 73 | Debug.Log(e.ToString()); 74 | } 75 | return path; 76 | } 77 | 78 | private static string GetPackageName() 79 | { 80 | string packageName = ""; 81 | try 82 | { 83 | using (AndroidJavaClass cls_UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) 84 | { 85 | using (AndroidJavaObject obj_Activity = cls_UnityPlayer.GetStatic("currentActivity")) 86 | { 87 | IntPtr obj_context = AndroidJNI.FindClass("android/content/ContextWrapper"); 88 | IntPtr method_getPackageName = AndroidJNIHelper.GetMethodID(obj_context, "getPackageName", "()Ljava/lang/String;"); 89 | packageName = AndroidJNI.CallStringMethod(obj_Activity.GetRawObject(), method_getPackageName, new jvalue[0]); 90 | } 91 | } 92 | } 93 | catch (Exception e) 94 | { 95 | Debug.Log(e.ToString()); 96 | } 97 | return packageName; 98 | } 99 | #endif 100 | } -------------------------------------------------------------------------------- /u3d/Assets/Core/CMisc.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a198c4be1d42420fb27abacf064972a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /u3d/Assets/Core/CPropertyValue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 57bebca62c1f941829708e8a3f8c2135 3 | timeCreated: 1536472189 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/CRandom.cs: -------------------------------------------------------------------------------- 1 | 2 | using UnityEngine; 3 | 4 | // CRandom.cs 5 | // Author: Lu Zexi 6 | // 2014-12-07 7 | 8 | 9 | 10 | //random 11 | public class CRandom 12 | { 13 | /// 14 | /// 由概率集得到1次随机落在何处 15 | /// 16 | /// 17 | /// 18 | public static int BET(params float[] perLst) 19 | { 20 | return RANDOM_BET(1, perLst)[0]; 21 | } 22 | 23 | /// 24 | /// 由指定概率集得到N次随机落在何处 25 | /// 26 | /// 27 | /// 28 | /// 29 | public static int[] BET(int num, params float[] perLst) 30 | { 31 | return RANDOM_BET(num, perLst); 32 | } 33 | 34 | /// 35 | /// 由指定概率集得到N次随机落在何处 36 | /// 37 | /// 38 | /// 39 | /// 40 | public static int[] RANDOM_BET(int num, float[] perLst) 41 | { 42 | if (perLst == null || num <= 0) 43 | return null; 44 | 45 | int typeNum = perLst.Length; 46 | int[] selectPos = new int[num]; 47 | float[] vecRandom = new float[num]; 48 | 49 | for (int i = 0; i < num; i++) 50 | { 51 | selectPos[i] = -1; 52 | vecRandom[i] = UnityEngine.Random.Range(0,1f); 53 | } 54 | 55 | for (int i = 0; i < num; i++) 56 | { 57 | float sumPos = 0; 58 | for (int j = (int)UnityEngine.Random.Range(0,typeNum) , k = 0; k < perLst.Length; k++, j++) 59 | { 60 | sumPos += perLst[j % typeNum]; 61 | //Debug.Log("sum + " + sumPos + " -- " + perLst[j % typeNum] + " -- " + vecRandom[i]); 62 | if (sumPos >= vecRandom[i]) 63 | { 64 | selectPos[i] = j % typeNum; 65 | break; 66 | } 67 | } 68 | 69 | } 70 | 71 | return selectPos; 72 | } 73 | } -------------------------------------------------------------------------------- /u3d/Assets/Core/CRandom.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1fa1e205849e64320b9f534634d420ce 3 | timeCreated: 1536472189 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/CSingleton.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | 4 | //Sigleton 5 | public class CSingleton : ResetInterface 6 | where T : ResetInterface , new() 7 | { 8 | public bool CanBeReset = true; 9 | 10 | private static T m_sInstance; 11 | public static T instance 12 | { 13 | get 14 | { 15 | if(m_sInstance == null) 16 | { 17 | m_sInstance = new T(); 18 | ResetClass.sAllSingle.Add(m_sInstance); 19 | } 20 | return m_sInstance; 21 | } 22 | } 23 | 24 | public static void ResetAll() 25 | { 26 | for(int i = 0 ; i sAllSingle = new List(); 55 | public static List sAllSingleMono = new List(); 56 | } -------------------------------------------------------------------------------- /u3d/Assets/Core/CSingleton.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f6535f4255f344403a956132e4b35999 3 | timeCreated: 1536472189 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/CSingletonMono.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | 6 | //Sigleton with Mono code 7 | public class CSingletonMono : MonoBehaviour , ResetInterface 8 | where T : MonoBehaviour , ResetInterface 9 | { 10 | public bool CanBeReset = true; 11 | 12 | private static T m_sInstance; 13 | public static T instance 14 | { 15 | get 16 | { 17 | if (m_sInstance == null) 18 | { 19 | m_sInstance = (T)FindObjectOfType (typeof(T)); 20 | 21 | if (m_sInstance == null) 22 | { 23 | GameObject obj = new GameObject(typeof(T).Name); 24 | m_sInstance = obj.AddComponent(); 25 | DontDestroyOnLoad(obj); 26 | } 27 | ResetClass.sAllSingleMono.Add(m_sInstance); 28 | } 29 | 30 | return m_sInstance; 31 | } 32 | } 33 | 34 | public static void ResetAll() 35 | { 36 | for(int i = 0 ; i withoutExtensions = new List() { ".prefab"}; 22 | string[] files = Directory.GetFiles(dataPath, "*.*", SearchOption.AllDirectories) 23 | .Where(s => withoutExtensions.Contains(Path.GetExtension(s).ToLower())).ToArray(); 24 | int startIndex = 0; 25 | 26 | EditorApplication.update = delegate() 27 | { 28 | string file = files[startIndex]; 29 | 30 | bool isCancel = EditorUtility.DisplayCancelableProgressBar("匹配资源中", file, (float)startIndex / (float)files.Length); 31 | 32 | DeleteNullScript(file); 33 | 34 | startIndex++; 35 | if (isCancel || startIndex >= files.Length) 36 | { 37 | EditorUtility.ClearProgressBar(); 38 | EditorApplication.update = null; 39 | startIndex = 0; 40 | Debug.Log("匹配结束"); 41 | } 42 | 43 | }; 44 | 45 | 46 | // EditorSettings.serializationMode = SerializationMode.ForceText; 47 | // string path = AssetDatabase.GetAssetPath(Selection.activeObject); 48 | // if(string.IsNullOrEmpty(path)) 49 | // { 50 | // Debug.LogError("请选择目标prefab"); 51 | // return; 52 | // } 53 | 54 | // DeleteNullScript(path); 55 | 56 | // AssetDatabase.SaveAssets(); 57 | // Debug.Log("ClearMissingScripts Success"); 58 | } 59 | 60 | 61 | private static void DeleteNullScript(string path) 62 | { 63 | bool isNull = false; 64 | string s = File.ReadAllText(path); 65 | 66 | Regex regBlock = new Regex("MonoBehaviour"); 67 | 68 | // 以"---"划分组件 69 | string[] strArray = s.Split(new string[] { "---" }, StringSplitOptions.RemoveEmptyEntries); 70 | 71 | for (int i = 0; i < strArray.Length; i++) 72 | { 73 | string blockStr = strArray[i]; 74 | 75 | if (regBlock.IsMatch(blockStr)) 76 | { 77 | // 模块是 MonoBehavior 78 | // Match guidMatch = Regex.Match(blockStr, "m_Script: {fileID: (.*), guid: (?.*?), type:"); 79 | Match guidMatch = Regex.Match(blockStr, "m_Script: {fileID: (?.*?)}"); 80 | if (guidMatch.Success) 81 | { 82 | // 获取 MonoBehavior的guid 83 | string fileID = guidMatch.Groups["FileID"].Value; 84 | //Debug.Log("Guid:" + guid); 85 | 86 | // string _path = AssetDatabase.GUIDToAssetPath(guid); 87 | // if (string.IsNullOrEmpty(_path)) 88 | if(fileID == "0") 89 | { 90 | // 工程中无此脚本 空脚本!!! 91 | Debug.Log(path+" 有空脚本"); 92 | isNull = true; 93 | 94 | // 删除操作 95 | 96 | // 删除MonoScript 97 | s = s.Replace("---" + blockStr, ""); 98 | 99 | Match idMatch = Regex.Match(blockStr, "!u!(.*) &(?.*?)\r"); 100 | if (idMatch.Success) 101 | { 102 | // 获取 MonoBehavior的guid 103 | string id = idMatch.Groups["idValue"].Value; 104 | 105 | // 删除MonoScript的引用 106 | Regex quote = new Regex(" - (.*): {fileID: " + id + "}"); 107 | s = quote.Replace(s, ""); 108 | } 109 | 110 | } 111 | 112 | } 113 | 114 | } 115 | 116 | 117 | } 118 | 119 | if (isNull) 120 | { 121 | // 有空脚本 写回prefab 122 | File.WriteAllText(path, s); 123 | 124 | // 打印Log 125 | Debug.Log(path); 126 | } 127 | } 128 | 129 | 130 | /// 131 | /// 删除预设上面丢失的脚本 132 | /// 133 | // static void ClearMissingScripts() 134 | // { 135 | // //测试一个 136 | // List prefabList = new List(Selection.gameObjects);//GetAllUIPrefab(); 137 | // //List prefabList = GetAllGameObjects(FindItemType.FindObj); 138 | 139 | // int prefabCount = prefabList.Count; 140 | // Debug.Log("prefabCount = " + prefabCount); 141 | 142 | // for (int i = prefabCount - 1; i >= 0; i--) 143 | // { 144 | // DeleteMissingScripts(prefabList[i]); 145 | // } 146 | 147 | // AssetDatabase.SaveAssets(); 148 | // Debug.Log("ClearMissingScripts Success"); 149 | // } 150 | 151 | // static void DeleteMissingScripts(GameObject obj) 152 | // { 153 | // Debug.Log("name is :" + obj.name); 154 | // Regex guidRegex = new Regex("m_Script: {fileID: (.*), guid: (?.*?), type:"); 155 | // Regex fileRegex = new Regex("--- !u!(?.*?) &(?.*?)\r\n"); 156 | // int fileStrLenght = 30; 157 | // string filePath = AssetDatabase.GetAssetPath(obj); 158 | // string s = File.ReadAllText(filePath); 159 | // string groupSpilChar = "---"; 160 | // string fileStr = ""; 161 | // bool isChange = false; 162 | // MatchCollection matchList = guidRegex.Matches(s); 163 | // if (matchList != null) 164 | // { 165 | // for (int i = matchList.Count - 1; i >= 0; i--) 166 | // { 167 | 168 | // string guid = matchList[i].Groups["GuidValue"].Value; 169 | // if (AssetDatabase.GUIDToAssetPath(guid) == "") 170 | // { 171 | // isChange = true; 172 | // int startIndex = s.LastIndexOf(groupSpilChar, matchList[i].Index); 173 | // int endIndex = s.IndexOf(groupSpilChar, matchList[i].Index); 174 | 175 | // Match fileMatch = fileRegex.Match(s.Substring(startIndex, fileStrLenght)); 176 | // fileStr = "- " + fileMatch.Groups["groupNum"].Value + ": {fileID: " + fileMatch.Groups["fileID"].Value + "}\r\n "; 177 | 178 | // s = s.Replace(s.Substring(startIndex, endIndex - startIndex), ""); 179 | // s = s.Replace(fileStr, ""); 180 | // } 181 | // } 182 | // } 183 | // if (isChange) 184 | // { 185 | // File.WriteAllText(filePath, s); 186 | // Debug.Log(obj.name + " missing scripts destory success!"); 187 | // } 188 | // } 189 | 190 | // [MenuItem("Assets/ClearMissingScripts", true)] 191 | // static private bool VFind() 192 | // { 193 | // string path = AssetDatabase.GetAssetPath(Selection.activeObject); 194 | // return (!string.IsNullOrEmpty(path)); 195 | // } 196 | 197 | } -------------------------------------------------------------------------------- /u3d/Assets/Core/Editor/ClearMissComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 25a1442014c5d434d81821ebaea494d5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /u3d/Assets/Core/Editor/FindMissComponent.cs: -------------------------------------------------------------------------------- 1 | 2 | using UnityEngine; 3 | using System.Collections; 4 | using UnityEditor; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Text.RegularExpressions; 9 | using System.Collections.Generic; 10 | 11 | public class FindMissComponent 12 | { 13 | [MenuItem("Assets/FindMissComponent",false,100)] 14 | static private void Find() 15 | { 16 | EditorSettings.serializationMode = SerializationMode.ForceText; 17 | string path = AssetDatabase.GetAssetPath(Selection.activeObject); 18 | if(string.IsNullOrEmpty(path)) 19 | { 20 | Debug.LogError("请选择目标prefab"); 21 | return; 22 | } 23 | 24 | string dataPath = Application.dataPath; 25 | Debug.Log("开始查找:"); 26 | if(!string.IsNullOrEmpty(path)) 27 | { 28 | GameObject obj = AssetDatabase.LoadAssetAtPath(path); 29 | if(obj!=null) 30 | { 31 | Component[] cps = obj.GetComponentsInChildren(true); 32 | for(int i=0;i withoutExtensions = new List() {".cs" }; 24 | //从选择的文件夹中拿到所有文件 25 | string[] files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories) 26 | .Where(s => withoutExtensions.Contains(Path.GetExtension(s).ToLower())).ToArray(); 27 | int startIndex = 0; 28 | 29 | if(files.Length == 0) 30 | { 31 | Debug.Log("没有需要处理的文件!"); 32 | return; 33 | } 34 | 35 | EditorApplication.update = delegate() 36 | { 37 | string file = files[startIndex]; 38 | bool isCancel = EditorUtility.DisplayCancelableProgressBar("清除Debug.Log...代码中。。。", file, (float)startIndex / (float)files.Length); 39 | 40 | if(!Regex.IsMatch(file,scriptsFile)) 41 | { 42 | //scripts以外的文件不处理 43 | Debug.Log("scripts以外的文件不处理"); 44 | } 45 | else if(Regex.IsMatch(file,whiteFile)) 46 | { 47 | //白名单不处理 48 | Debug.Log("DebugWrap.cs 白名单不处理"); 49 | } 50 | else if(NoteDebugLog(file)) 51 | { 52 | Debug.Log(file, AssetDatabase.LoadAssetAtPath(GetRelativeAssetsPath(file), typeof(Object))); 53 | } 54 | 55 | startIndex++; 56 | if (isCancel || startIndex >= files.Length) 57 | { 58 | EditorUtility.ClearProgressBar(); 59 | EditorApplication.update = null; 60 | startIndex = 0; 61 | Debug.Log("匹配结束"); 62 | } 63 | }; 64 | } 65 | } 66 | 67 | // [MenuItem("Assets/Remove Debug Log", true)] 68 | // static private bool VFind() 69 | // { 70 | // string path = AssetDatabase.GetAssetPath(Selection.activeObject); 71 | // return (!string.IsNullOrEmpty(path) && Directory.Exists(path)); 72 | // } 73 | 74 | static private string GetRelativeAssetsPath(string path) 75 | { 76 | return "Assets" + Path.GetFullPath(path).Replace(Path.GetFullPath(Application.dataPath), "").Replace('\\', '/'); 77 | } 78 | 79 | static private bool DeleteDebugLog(string file) 80 | { 81 | string fileContent = ""; 82 | string[] fileLines = File.ReadAllLines(file); 83 | bool hasWrite = false; 84 | 85 | StringBuilder sBuilder = new StringBuilder(); 86 | 87 | for(int i=0;i where T : struct 18 | { 19 | public class GameState 20 | { 21 | public T m_stateName = default(T);//"DefaultStateName"; 22 | 23 | //It is the FSM the state inside 24 | public GameStateMachine m_fsm = null; 25 | 26 | //Time based variables 27 | public bool m_isTimeBased = false; 28 | public GameState m_nextState = null; 29 | protected float m_stateDuration = 0; 30 | protected float m_curTime = 0; 31 | 32 | //Events 33 | public event OnEnterHandler OnEnter; 34 | public event OnUpdateHandler OnUpdate; 35 | public event OnExitHandler OnExit; 36 | 37 | public GameState() 38 | { 39 | m_isTimeBased = false; 40 | m_stateDuration = 0; 41 | m_curTime = 0; 42 | m_nextState = null; 43 | } 44 | 45 | public GameState(GameStateMachine stateMachine, T stateName) 46 | { 47 | m_fsm = stateMachine; 48 | m_stateName = stateName; 49 | m_isTimeBased = false; 50 | m_stateDuration = 0; 51 | m_curTime = 0; 52 | m_nextState = null; 53 | } 54 | 55 | public void SetInfo(GameStateMachine stateMachine, T stateName) 56 | { 57 | m_fsm = stateMachine; 58 | m_stateName = stateName; 59 | } 60 | 61 | public virtual void Enter() { } 62 | public virtual void Update() { } 63 | public virtual void Exit() { } 64 | 65 | public virtual void EnterState() 66 | { 67 | m_curTime = 0; 68 | 69 | if (OnEnter != null) 70 | { 71 | OnEnter(); 72 | } 73 | Enter(); 74 | } 75 | 76 | public virtual void Execute() 77 | { 78 | m_curTime += Time.deltaTime; 79 | if (m_isTimeBased && m_curTime >= m_stateDuration) 80 | { 81 | if (m_nextState != null) 82 | { 83 | m_fsm.ChangeState(m_nextState.m_stateName); 84 | } 85 | return; 86 | } 87 | 88 | if (OnUpdate != null) 89 | { 90 | OnUpdate(); 91 | } 92 | Update(); 93 | } 94 | 95 | public virtual void ExitState() 96 | { 97 | if (OnExit != null) 98 | { 99 | OnExit(); 100 | } 101 | Exit(); 102 | } 103 | } 104 | 105 | public Dictionary m_stateList = new Dictionary(); 106 | 107 | public GameState m_curState { get; private set; } 108 | public GameState m_preState { get; private set; } 109 | 110 | public GameState this[T stateName] 111 | { 112 | get 113 | { 114 | if (!m_stateList.ContainsKey(stateName)) 115 | return null; 116 | 117 | return m_stateList[stateName]; 118 | } 119 | set 120 | { 121 | m_stateList[stateName] = value; 122 | } 123 | } 124 | 125 | public GameStateMachine() 126 | { 127 | // if (!typeof(T).IsEnum) 128 | // { 129 | // throw new ArgumentException("T must be an enumerated type"); 130 | // } 131 | } 132 | 133 | public void AddState(T stateName) 134 | { 135 | m_stateList.Add(stateName, new GameState(this, stateName)); 136 | } 137 | public void AddState(T stateName, GameState state) 138 | { 139 | state.m_fsm = this; 140 | state.m_stateName = stateName; 141 | m_stateList.Add(stateName, state); 142 | } 143 | 144 | public void ChangeState(T newStateName) 145 | { 146 | if (!m_stateList.ContainsKey(newStateName)) 147 | { 148 | #if UNITY_EDITOR 149 | Debug.Log("Error! No State named :" +newStateName.ToString()); 150 | throw new UnityException(); 151 | #endif 152 | return; 153 | } 154 | 155 | GameState newState = m_stateList[newStateName]; 156 | if (newState == null) 157 | Debug.LogError("FSM Error could not change to state:" + newStateName); 158 | 159 | if (newState == null) return; 160 | 161 | //set fsm to state 162 | newState.m_fsm = this; 163 | 164 | //Exit current state first 165 | if (m_curState != null) m_curState.ExitState(); 166 | 167 | //record previous state 168 | m_preState = m_curState; 169 | 170 | //Change currnet state 171 | m_curState = newState; 172 | 173 | //Entry new state 174 | m_curState.EnterState(); 175 | } 176 | 177 | public T GetCurrentStateName() 178 | { 179 | return m_curState.m_stateName; 180 | } 181 | 182 | public GameState GetCurrentState() 183 | { 184 | if(m_curState == null) return null; 185 | 186 | return m_stateList[m_curState.m_stateName]; 187 | } 188 | 189 | public bool IsInState(GameState checkState) 190 | { 191 | return m_curState == checkState; 192 | } 193 | 194 | public virtual void Update() 195 | { 196 | if (m_curState == null) return; 197 | 198 | //excute current state 199 | m_curState.Execute(); 200 | } 201 | } 202 | //} 203 | #endregion 204 | #region stepmachine 205 | class GameStepMachine 206 | { 207 | System.Action m_callback = null; 208 | List m_steps = new List(); 209 | int m_curStep = 0; 210 | 211 | public GameStepMachine() 212 | { 213 | } 214 | public void AddStep(GameStep _step) 215 | { 216 | m_steps.Add(_step); 217 | } 218 | public void Start(System.Action _callback = null) 219 | { 220 | m_callback = _callback; 221 | 222 | m_curStep = 0; 223 | 224 | if (m_curStep < m_steps.Count) 225 | { 226 | m_steps[m_curStep].EnterStep(); 227 | } 228 | } 229 | public void Update() 230 | { 231 | if (m_steps != null && m_curStep < m_steps.Count) 232 | { 233 | GameStep.UpdateStepResult result = m_steps[m_curStep].UpdateStep(); 234 | if (result == GameStep.UpdateStepResult.Next) 235 | { 236 | m_steps[m_curStep].ExitStep(); 237 | ++m_curStep; 238 | if (m_curStep < m_steps.Count) 239 | { 240 | m_steps[m_curStep].EnterStep(); 241 | } 242 | else if (m_callback != null) 243 | { 244 | m_callback(); 245 | } 246 | } 247 | } 248 | } 249 | } 250 | abstract class GameStep 251 | { 252 | public enum UpdateStepResult 253 | { 254 | Stay, 255 | Next, 256 | } 257 | public abstract void EnterStep(); 258 | public abstract UpdateStepResult UpdateStep(); 259 | public abstract void ExitStep(); 260 | 261 | } 262 | #endregion -------------------------------------------------------------------------------- /u3d/Assets/Core/GameStateMachine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bbbd2f167dcd51e48ad7e63d4af61b00 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /u3d/Assets/Core/LineMesh.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Events; 5 | using UnityEngine.EventSystems; 6 | 7 | 8 | public class LineMesh 9 | { 10 | public class MeshData 11 | { 12 | public Vector3[] mVertices = new Vector3[4]; 13 | public int[] mTriangles = new int[6]; // 2 triangle and 3 vertex 14 | } 15 | 16 | public class LineData 17 | { 18 | public Vector3 mStartPos; 19 | public Vector3 mEndPos; 20 | public float mWidth; 21 | } 22 | 23 | public static Mesh MakeMeshLine(List _lstLine) 24 | { 25 | List lstMeshdata = new List(_lstLine.Count); 26 | for(int i = 0 ; i<_lstLine.Count ; i++) 27 | { 28 | MeshData _meshdata = MakeMeshData(_lstLine[i].mStartPos, _lstLine[i].mEndPos, _lstLine[i].mWidth); 29 | lstMeshdata.Add(_meshdata); 30 | } 31 | return CombineMeshData(lstMeshdata); 32 | } 33 | 34 | public static MeshData MakeMeshData(Vector3 _startPos, Vector3 _endPos, float _width) 35 | { 36 | MeshData m = new MeshData(); 37 | 38 | Vector3 _forward = (_endPos - _startPos).normalized; 39 | Vector3 _right = Vector3.Cross(_forward, new Vector3(0,0,1)); 40 | 41 | m.mVertices[0] = _startPos + _right * _width; 42 | m.mVertices[1] = _startPos + _right * _width * -1; 43 | m.mVertices[2] = _endPos + _right * _width; 44 | m.mVertices[3] = _endPos + _right * _width * -1; 45 | 46 | m.mTriangles[0] = 0; 47 | m.mTriangles[1] = 1; 48 | m.mTriangles[2] = 2; 49 | 50 | m.mTriangles[3] = 1; 51 | m.mTriangles[4] = 3; 52 | m.mTriangles[5] = 2; 53 | 54 | return m; 55 | } 56 | 57 | public static Mesh CombineMeshData(List lst) 58 | { 59 | Vector3[] _vertices = new Vector3[lst.Count * 4]; 60 | int[] _triangles = new int[lst.Count * 6]; 61 | Color[] _colors = new Color[_vertices.Length]; 62 | 63 | for(int i = 0 ; i("currentActivity")) 48 | { 49 | AndroidJavaClass cls_OpenNotificationAnd = new AndroidJavaClass("com.sd.glb.OpenNotification"); 50 | if(title == null) 51 | { 52 | cls_OpenNotificationAnd.CallStatic("NotifyText",obj_Activity, time, _content); 53 | } 54 | else 55 | { 56 | cls_OpenNotificationAnd.CallStatic("NotifyText",obj_Activity, time, title, _content); 57 | } 58 | } 59 | } 60 | #endif 61 | } 62 | 63 | public void CancelAllNotification() 64 | { 65 | #if UNITY_IPHONE 66 | UnityEngine.iOS.NotificationServices.CancelAllLocalNotifications(); 67 | #endif 68 | #if UNITY_ANDROID && !UNITY_EDITOR 69 | count = 0; 70 | using (AndroidJavaClass cls_UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) 71 | { 72 | using (AndroidJavaObject obj_Activity = cls_UnityPlayer.GetStatic("currentActivity")) 73 | { 74 | AndroidJavaClass cls_OpenNotificationAnd = new AndroidJavaClass("com.sd.glb.OpenNotification"); 75 | cls_OpenNotificationAnd.CallStatic("Clear"); 76 | } 77 | } 78 | #endif 79 | } 80 | 81 | public void AddClearNotification() 82 | { 83 | if (!Enabled) return; 84 | #if UNITY_IPHONE 85 | UnityEngine.iOS.LocalNotification notify = new UnityEngine.iOS.LocalNotification(); 86 | notify.fireDate = System.DateTime.Now; 87 | notify.applicationIconBadgeNumber = -1; 88 | notify.hasAction = false; 89 | UnityEngine.iOS.NotificationServices.ScheduleLocalNotification(notify); 90 | #endif 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /u3d/Assets/Core/LocalNotificationManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 54278763c2fe047c9adba3805456954a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /u3d/Assets/Core/MeshGenerate.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 23d73adb0f04d41418fd79cec6f5668d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /u3d/Assets/Core/MeshGenerate/MeshCreator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78323a081c0a44205839aae79f810c0a 3 | timeCreated: 1536472189 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/MeshGenerate/UILineMesh.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Events; 5 | using UnityEngine.EventSystems; 6 | 7 | 8 | public class UILineMesh 9 | { 10 | public class MeshData 11 | { 12 | public Vector3[] mVertices = new Vector3[4]; 13 | public int[] mTriangles = new int[6]; // 2 triangle and 3 vertex 14 | } 15 | 16 | public class LineData 17 | { 18 | public Vector3 mStartPos; 19 | public Vector3 mEndPos; 20 | public float mWidth; 21 | } 22 | 23 | public static Mesh MakeMeshLine(List _lstLine) 24 | { 25 | List lstMeshdata = new List(_lstLine.Count); 26 | for(int i = 0 ; i<_lstLine.Count ; i++) 27 | { 28 | MeshData _meshdata = MakeMeshData(_lstLine[i].mStartPos, _lstLine[i].mEndPos, _lstLine[i].mWidth); 29 | lstMeshdata.Add(_meshdata); 30 | } 31 | return CombineMeshData(lstMeshdata); 32 | } 33 | 34 | public static MeshData MakeMeshData(Vector3 _startPos, Vector3 _endPos, float _width) 35 | { 36 | MeshData m = new MeshData(); 37 | 38 | Vector3 _forward = (_endPos - _startPos).normalized; 39 | Vector3 _right = Vector3.Cross(_forward, new Vector3(0,0,1)); 40 | 41 | m.mVertices[0] = _startPos + _right * _width; 42 | m.mVertices[1] = _startPos + _right * _width * -1; 43 | m.mVertices[2] = _endPos + _right * _width; 44 | m.mVertices[3] = _endPos + _right * _width * -1; 45 | 46 | m.mTriangles[0] = 0; 47 | m.mTriangles[1] = 1; 48 | m.mTriangles[2] = 2; 49 | 50 | m.mTriangles[3] = 1; 51 | m.mTriangles[4] = 3; 52 | m.mTriangles[5] = 2; 53 | 54 | return m; 55 | } 56 | 57 | public static Mesh CombineMeshData(List lst) 58 | { 59 | Vector3[] _vertices = new Vector3[lst.Count * 4]; 60 | int[] _triangles = new int[lst.Count * 6]; 61 | Color[] _colors = new Color[_vertices.Length]; 62 | 63 | for(int i = 0 ; i("currentActivity"); 32 | 33 | return sAndroidJavaClass; 34 | } 35 | #endif 36 | 37 | //获取DeviceID 38 | public static string getDeviceUniqueId() 39 | { 40 | if(sDeviceId != null) return sDeviceId; 41 | 42 | #if UNITY_EDITOR 43 | sDeviceId = SystemInfo.deviceUniqueIdentifier; 44 | #endif 45 | #if UNITY_ANDROID 46 | AndroidJavaClass deviceUtils = new AndroidJavaClass("com.sdo.qihang.lib.DeviceUtils"); 47 | sDeviceId = deviceUtils.CallStatic ("getUniqueId"); 48 | #endif 49 | #if UNITY_IPHONE 50 | sDeviceId = SystemInfo.deviceUniqueIdentifier; 51 | #endif 52 | return sDeviceId; 53 | } 54 | 55 | public static string GetString(byte[] _data) 56 | { 57 | // Create a new Stringbuilder to collect the bytes 58 | // and create a string. 59 | StringBuilder sBuilder = new StringBuilder(); 60 | 61 | // Loop through each byte of the hashed data 62 | // and format each one as a hexadecimal string. 63 | for (int i = 0; i < _data.Length; i++) 64 | { 65 | sBuilder.Append(_data[i].ToString("x2")); 66 | } 67 | 68 | // Return the hexadecimal string. 69 | return sBuilder.ToString(); 70 | } 71 | 72 | public static string GetMd5Hash(byte[] _data) 73 | { 74 | #if !UNITY_METRO && !UNITY_WP8 75 | // Create a new instance of the MD5CryptoServiceProvider object. 76 | MD5 md5Hasher = MD5.Create(); 77 | 78 | byte[] data = md5Hasher.ComputeHash(_data); 79 | #else 80 | byte[] data = Crypto.ComputeMD5Hash(_data); 81 | #endif 82 | 83 | return GetString(data); 84 | } 85 | 86 | public static string GetMd5Hash(string input) 87 | { 88 | #if !UNITY_METRO && !UNITY_WP8 89 | // Create a new instance of the MD5CryptoServiceProvider object. 90 | MD5 md5Hasher = MD5.Create(); 91 | 92 | // Convert the input string to a byte array and compute the hash. 93 | byte[] data = md5Hasher.ComputeHash(Encoding.UTF8.GetBytes(input)); 94 | #else 95 | byte[] data = Crypto.ComputeMD5Hash(Encoding.UTF8.GetBytes(input)); 96 | #endif 97 | 98 | return GetString(data); 99 | } 100 | 101 | //get save path which file can write or save 102 | private static string GetSavePath() 103 | { 104 | if(sSavePath != null) return sSavePath; 105 | 106 | string pathTemp = string.Empty; 107 | #if UNITY_EDITOR || !UNITY_METRO 108 | if(Application.platform == RuntimePlatform.IPhonePlayer) 109 | { 110 | //string path = Application.dataPath.Substring(0,Application.dataPath.Length - 5); 111 | //path = path.Substring(0,path.LastIndexOf('/')); 112 | 113 | //pathTemp = path + "/Documents/"; 114 | pathTemp = Application.persistentDataPath; 115 | if (!pathTemp.EndsWith("/")) 116 | pathTemp += "/"; 117 | } 118 | else if(Application.platform == RuntimePlatform.Android) 119 | { 120 | string path = Application.persistentDataPath; 121 | pathTemp = path + "/Saves"; 122 | if ((pathTemp.Length > 0) && (!System.IO.Directory.Exists(pathTemp))) 123 | { 124 | System.IO.Directory.CreateDirectory(pathTemp); 125 | } 126 | } 127 | else 128 | { 129 | pathTemp = Application.dataPath+"/Saves"; 130 | if ((pathTemp.Length > 0) && (!System.IO.Directory.Exists(pathTemp))) 131 | { 132 | System.IO.Directory.CreateDirectory(pathTemp); 133 | } 134 | } 135 | #endif 136 | sSavePath = pathTemp; 137 | return sSavePath; 138 | } 139 | 140 | public static bool IsKindleDevice() 141 | { 142 | if (SystemInfo.deviceModel == "Amazon KFOT" || SystemInfo.deviceModel == "Amazon KFTT" || SystemInfo.deviceModel == "Amazon KFJWA" || SystemInfo.deviceModel == "Amazon KFJWI" 143 | || SystemInfo.deviceModel == "Amazon KFSOWI" || SystemInfo.deviceModel == "Amazon KFTHWA" || SystemInfo.deviceModel == "Amazon KFHWI" || SystemInfo.deviceModel == "Amazon KFAPWA" 144 | || SystemInfo.deviceModel == "Amazon KFAPWI") 145 | return true; 146 | else 147 | return false; 148 | } 149 | } -------------------------------------------------------------------------------- /u3d/Assets/Core/MixUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 357528d4ad1bc42448e69ab7faa13451 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /u3d/Assets/Core/ObjectPool.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 760f7e562e4ce40fd8af03bebf34be91 3 | folderAsset: yes 4 | timeCreated: 1536472189 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /u3d/Assets/Core/ObjectPool/GameObjectPool.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | 6 | public class GameObjectPool 7 | where T : MonoBehaviour 8 | { 9 | // Object pool to avoid allocations. 10 | protected ObjectPool sGameObjectPool = new ObjectPool(OnGet, OnRelease); 11 | protected GameObject sRoot = null; 12 | 13 | public GameObjectPool() 14 | { 15 | SetCreateFunction(GenerateAsset); 16 | } 17 | 18 | public T Get() 19 | { 20 | T obj = sGameObjectPool.Get(); 21 | obj.transform.parent = null; 22 | return obj; 23 | } 24 | 25 | public void Release(T toRelease) 26 | { 27 | if(sRoot == null) 28 | { 29 | sRoot = new GameObject("GameObjPool-" + this.GetType().ToString()); 30 | } 31 | toRelease.transform.parent = sRoot.transform; 32 | sGameObjectPool.Release(toRelease); 33 | } 34 | 35 | protected virtual T GenerateAsset() 36 | { 37 | return default(T); 38 | } 39 | 40 | protected void SetCreateFunction(ObjectPool.CreateT _create_function) 41 | { 42 | sGameObjectPool.m_ActionOnCreate = _create_function; 43 | } 44 | 45 | private static void OnGet(T obj) 46 | { 47 | obj.gameObject.SetActive(true); 48 | } 49 | 50 | public static void OnRelease(T obj) 51 | { 52 | obj.gameObject.SetActive(false); 53 | } 54 | } 55 | 56 | 57 | -------------------------------------------------------------------------------- /u3d/Assets/Core/ObjectPool/GameObjectPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac53424b4494991499ce6d89ad3b5016 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /u3d/Assets/Core/ObjectPool/GameObjectPoolAutoDestroy.cs: -------------------------------------------------------------------------------- 1 | // using UnityEngine; 2 | // using System.Collections; 3 | // using System.Collections.Generic; 4 | 5 | 6 | // public class GameObjectPoolAutoDestroy : MonoBehaviour 7 | // { 8 | // public float Destroy_Time = 1; 9 | // private bool mStart = false; 10 | // private float mStartTime = 0; 11 | 12 | // void OnEnable() 13 | // { 14 | // mStartTime = Time.time; 15 | // mStart = true; 16 | // } 17 | 18 | // void Update() 19 | // { 20 | // if(!mStart) 21 | // return; 22 | // float difTime = Time.time - mStartTime; 23 | // if(difTime > Destroy_Time) 24 | // { 25 | // mStart = false; 26 | // GameObjectPool.Release(this.gameObject); 27 | // } 28 | // } 29 | // } 30 | 31 | -------------------------------------------------------------------------------- /u3d/Assets/Core/ObjectPool/GameObjectPoolAutoDestroy.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5bbaa14eb2649ca43b2c38654f93a963 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /u3d/Assets/Core/ObjectPool/ListPool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | 6 | public static class ListPool 7 | { 8 | // Object pool to avoid allocations. 9 | private static readonly ObjectPool> s_ListPool = new ObjectPool>(null, l => l.Clear()); 10 | 11 | public static List Get() 12 | { 13 | return s_ListPool.Get(); 14 | } 15 | 16 | public static void Release(List toRelease) 17 | { 18 | s_ListPool.Release(toRelease); 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /u3d/Assets/Core/ObjectPool/ListPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 628963930a1c9a74e80e1b223af60d8a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /u3d/Assets/Core/ObjectPool/ObjectPool.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine.Events; 3 | 4 | 5 | public class ObjectPool 6 | { 7 | private readonly Stack m_Stack = new Stack(); 8 | private readonly UnityAction m_ActionOnGet; 9 | private readonly UnityAction m_ActionOnRelease; 10 | public delegate T CreateT(); 11 | public CreateT m_ActionOnCreate; 12 | 13 | public int countAll { get; private set; } 14 | public int countActive { get { return countAll - countInactive; } } 15 | public int countInactive { get { return m_Stack.Count; } } 16 | 17 | public ObjectPool(UnityAction actionOnGet, UnityAction actionOnRelease) 18 | { 19 | m_ActionOnGet = actionOnGet; 20 | m_ActionOnRelease = actionOnRelease; 21 | } 22 | 23 | public T Get() 24 | { 25 | T element = default(T); 26 | if (m_Stack.Count == 0) 27 | { 28 | if(m_ActionOnCreate != null) 29 | { 30 | element = m_ActionOnCreate(); 31 | } 32 | countAll++; 33 | } 34 | else 35 | { 36 | element = m_Stack.Pop(); 37 | } 38 | if (m_ActionOnGet != null) 39 | m_ActionOnGet(element); 40 | return element; 41 | } 42 | 43 | public void Release(T element) 44 | { 45 | if (m_Stack.Count > 0 && ReferenceEquals(m_Stack.Peek(), element)) 46 | Debug.LogError("Internal error. Trying to destroy object that is already released to pool."); 47 | if (m_ActionOnRelease != null) 48 | m_ActionOnRelease(element); 49 | m_Stack.Push(element); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /u3d/Assets/Core/ObjectPool/ObjectPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 98920f4dd93dd274a9aac2f5d4f4a361 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /u3d/Assets/Core/Polar.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | 5 | // Polar.cs 6 | // Author: Lu Zexi 7 | // 2014-12-20 8 | 9 | 10 | //Polar coordinates can use in camera to move like sphere. 11 | //A distance , an angle of the y-axis and an angle of the xz-axis to y-axis can make a point. 12 | //So Polar can convert by position or direction x,y,z. 13 | [System.Serializable] 14 | public class Polar : System.ICloneable 15 | { 16 | public float d; //distance 17 | public float v; //the angle of the x&z-axis to y-axis in PI 18 | public float h; //the angle of the y-axis in PI 19 | public Polar() { } 20 | 21 | public Polar( float d_, float v_, float h_ ) 22 | { 23 | d = d_; 24 | v = v_; 25 | h = h_; 26 | } 27 | 28 | //convert from position to polar 29 | public Polar(Vector3 pos) 30 | { 31 | d = pos.magnitude; 32 | v = Mathf.Atan2(Mathf.Sqrt(pos.x * pos.x + pos.z * pos.z), pos.y) * Mathf.Rad2Deg; 33 | h = Mathf.Atan2(pos.z, pos.x) * Mathf.Rad2Deg; 34 | } 35 | 36 | //clone 37 | public object Clone() 38 | { 39 | var ret = new Polar(); 40 | ret.d = d; 41 | ret.h = h; 42 | ret.v = v; 43 | return ret; 44 | } 45 | 46 | //convert this position to polar 47 | public Vector3 GetPos() 48 | { 49 | return Direction * d; 50 | } 51 | 52 | //lerp polar 53 | public static Polar Lerp( Polar a, Polar b, float rate ) 54 | { 55 | return new Polar( 56 | Mathf.Lerp( a.d, b.d, rate ), 57 | Mathf.LerpAngle( a.v, b.v, rate ), 58 | Mathf.LerpAngle( a.h, b.h, rate ) 59 | ); 60 | } 61 | 62 | //get direction in polar 63 | public Vector3 Direction{ get{ 64 | return new Vector3( Mathf.Sin(Mathf.Deg2Rad * v) * Mathf.Cos(Mathf.Deg2Rad * h), 65 | Mathf.Cos(Mathf.Deg2Rad * v), 66 | Mathf.Sin(Mathf.Deg2Rad * v) * Mathf.Sin(Mathf.Deg2Rad * h)); 67 | }} 68 | } 69 | 70 | -------------------------------------------------------------------------------- /u3d/Assets/Core/Polar.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4afe02245521b44b1946f5569f4f6576 3 | timeCreated: 1536472189 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/PrefabLightmapData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c7b19d2b7a0b741deb4923fa1fe3bef3 3 | timeCreated: 1536472189 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/SecureNumber.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Text; 3 | 4 | public struct SecureString 5 | { 6 | string m_value; 7 | int m_code; 8 | 9 | public SecureString(string _str) 10 | { 11 | if (_str == null) 12 | { 13 | m_value = null; 14 | m_code = 0; 15 | return; 16 | } 17 | byte[] b = Encoding.UTF8.GetBytes(_str); 18 | m_value = System.Convert.ToBase64String(b); 19 | m_code = _str.GetHashCode(); 20 | } 21 | static SecureString NormalToSecure(string _str) 22 | { 23 | return new SecureString(_str); 24 | } 25 | static string SecureToNormal(SecureString _str) 26 | { 27 | if (_str.m_value == null) 28 | return null; 29 | byte[] b = System.Convert.FromBase64String(_str.m_value); 30 | string result = Encoding.UTF8.GetString(b, 0, b.Length); 31 | if (_str.m_code != result.GetHashCode()) 32 | { 33 | Application.Quit(); 34 | throw new UnityException("s problem"); 35 | } 36 | return result; 37 | } 38 | public static implicit operator SecureString(string _str) 39 | { 40 | return NormalToSecure(_str); 41 | } 42 | public static implicit operator string(SecureString _str) 43 | { 44 | return SecureToNormal(_str); 45 | } 46 | public override string ToString() 47 | { 48 | return SecureToNormal(this); 49 | } 50 | public char[] ToCharArray() 51 | { 52 | return SecureToNormal(this).ToCharArray(); 53 | } 54 | 55 | public static bool operator !=(SecureString _left, SecureString _right) 56 | { 57 | return _left.m_value != _right.m_value; 58 | } 59 | public static bool operator ==(SecureString _left, SecureString _right) 60 | { 61 | return _left.m_value == _right.m_value; 62 | } 63 | } 64 | 65 | public struct SecureFloat 66 | { 67 | SecureInt m_value; 68 | 69 | public SecureFloat(float _float) 70 | { 71 | byte[] bs = System.BitConverter.GetBytes(_float); 72 | int i = System.BitConverter.ToInt32(bs, 0); 73 | m_value = new SecureInt(i); 74 | } 75 | static SecureFloat NormalToSecure(float _f) 76 | { 77 | return new SecureFloat(_f); 78 | } 79 | static float SecureToNormal(SecureFloat _f) 80 | { 81 | int i = _f.m_value; 82 | byte[] bs = System.BitConverter.GetBytes(i); 83 | return System.BitConverter.ToSingle(bs, 0); 84 | } 85 | public static implicit operator SecureFloat(float _f) 86 | { 87 | return NormalToSecure(_f); 88 | } 89 | public static implicit operator float(SecureFloat _f) 90 | { 91 | return SecureToNormal(_f); 92 | } 93 | public override string ToString() 94 | { 95 | return SecureToNormal(this).ToString(); 96 | } 97 | } 98 | 99 | public struct SecureInt 100 | { 101 | static class SecureIntRandom 102 | { 103 | static uint seed = (uint)(System.DateTime.Now.Millisecond % 0xffffff); 104 | static uint m_w = seed; /* must not be zero, nor 0x464fffff */ 105 | static uint m_z = ~seed; /* must not be zero, nor 0x9068ffff */ 106 | 107 | static uint get_random() 108 | { 109 | //if (seed == 0) 110 | //{ 111 | // seed = 112 | // m_w = seed; 113 | // m_z = ~seed; 114 | //} 115 | m_z = 36969 * (m_z & 65535) + (m_z >> 16); 116 | m_w = 18000 * (m_w & 65535) + (m_w >> 16); 117 | uint result = (m_z << 16) + m_w; /* 32-bit result */ 118 | return result; 119 | } 120 | public static int Int(int min, int max) 121 | { 122 | if (max <= min) return min; 123 | 124 | int random = (int)get_random(); 125 | random = random < 0 ? -random : random; 126 | return min + random % (max - min); 127 | } 128 | 129 | } 130 | 131 | 132 | const int UPPER = 65536 * 1024; 133 | const int LOWER = 65536; 134 | static int R = SecureIntRandom.Int(UPPER / 3, UPPER * 2 / 3); 135 | 136 | long m_value; 137 | int m_random; 138 | 139 | int V 140 | { 141 | get 142 | { 143 | int random = ~m_random - R; 144 | //#if UNITY_EDITOR 145 | if (m_value % random != 0) 146 | { 147 | Application.Quit(); 148 | throw new UnityException("si 0 problem"); 149 | } 150 | //Debug.LogError("SecureInt problem"); 151 | //#endif 152 | return (int)(m_value / random); 153 | } 154 | set 155 | { 156 | m_value = value; 157 | int random = SecureIntRandom.Int(LOWER, UPPER); 158 | m_value *= random; 159 | m_random = ~(random + R); 160 | } 161 | } 162 | public int CompareTo(SecureInt _s) 163 | { 164 | return V.CompareTo(_s.V); 165 | } 166 | public SecureInt(int _init) 167 | { 168 | m_value = 0; 169 | m_random = SecureIntRandom.Int(LOWER, UPPER); 170 | V = _init; 171 | } 172 | public static implicit operator SecureInt(int _value) 173 | { 174 | return new SecureInt(_value); 175 | } 176 | public static implicit operator int(SecureInt _value) 177 | { 178 | return _value.V; 179 | } 180 | 181 | // public static implicit operator EBuildingType(SecureInt _value) 182 | // { 183 | // return (EBuildingType)_value.V; 184 | // } 185 | // public static implicit operator ResType(SecureInt _value) 186 | // { 187 | // return (ResType)_value.V; 188 | // } 189 | // public static implicit operator UnitManager.UnitID(SecureInt _value) 190 | // { 191 | // return (UnitManager.UnitID)_value.V; 192 | // } 193 | // public static implicit operator InuDefine.EInuSkill(SecureInt _value) 194 | // { 195 | // return (InuDefine.EInuSkill)_value.V; 196 | // } 197 | // public static implicit operator HeroManager.HeroUnlockType(SecureInt _value) 198 | // { 199 | // return (HeroManager.HeroUnlockType)_value.V; 200 | // } 201 | // public static implicit operator HeroManager.HeroID(SecureInt _value) 202 | // { 203 | // return (HeroManager.HeroID)_value.V; 204 | // } 205 | 206 | 207 | 208 | public static int operator /(SecureInt _left, int _right) 209 | { 210 | return _left.V / _right; 211 | } 212 | public static int operator /(int _left, SecureInt _right) 213 | { 214 | return _left / _right.V; 215 | } 216 | public static int operator /(SecureInt _left, SecureInt _right) 217 | { 218 | return _left.V / _right.V; 219 | } 220 | //public static bool operator >(long _left, SecureInt right) 221 | //{ 222 | // return _left > right.V; 223 | //} 224 | //public static bool operator <(long _left, SecureInt right) 225 | //{ 226 | // return _left < right.V; 227 | //} 228 | public static bool operator >(SecureInt _left, SecureInt right) 229 | { 230 | return _left.V > right.V; 231 | } 232 | public static bool operator >(int _left, SecureInt right) 233 | { 234 | return _left > right.V; 235 | } 236 | public static bool operator <(int _left, SecureInt right) 237 | { 238 | return _left < right.V; 239 | } 240 | public static bool operator <(SecureInt _left, SecureInt right) 241 | { 242 | return _left.V < right.V; 243 | } 244 | public static bool operator >(SecureInt _left, int right) 245 | { 246 | return _left.V > right; 247 | } 248 | public static bool operator <(SecureInt _left, int right) 249 | { 250 | return _left.V < right; 251 | } 252 | 253 | public static bool operator >=(int _left, SecureInt right) 254 | { 255 | return _left >= right.V; 256 | } 257 | public static bool operator <=(int _left, SecureInt right) 258 | { 259 | return _left <= right.V; 260 | } 261 | public static bool operator >=(SecureInt _left, int right) 262 | { 263 | return _left.V >= right; 264 | } 265 | public static bool operator <=(SecureInt _left, int right) 266 | { 267 | return _left.V <= right; 268 | } 269 | public static bool operator >=(SecureInt _left, SecureInt right) 270 | { 271 | return _left.V >= right.V; 272 | } 273 | public static bool operator <=(SecureInt _left, SecureInt right) 274 | { 275 | return _left.V <= right.V; 276 | } 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | public static int operator +(int _left, SecureInt _right) 285 | { 286 | return _left + _right.V; 287 | } 288 | public static int operator +(SecureInt _left, int _right) 289 | { 290 | return _left.V + _right; 291 | } 292 | public static int operator +(SecureInt _left, SecureInt _right) 293 | { 294 | return _left.V + _right.V; 295 | } 296 | 297 | public static int operator -(int _left, SecureInt _right) 298 | { 299 | return _left - _right.V; 300 | } 301 | public static int operator -(SecureInt _left, SecureInt _right) 302 | { 303 | return _left.V - _right.V; 304 | } 305 | public static int operator -(SecureInt _left, int _right) 306 | { 307 | return _left.V - _right; 308 | } 309 | public static bool operator ==(SecureInt _left, int _right) 310 | { 311 | return _left.V == _right; 312 | } 313 | public static bool operator ==(SecureInt _left, SecureInt _right) 314 | { 315 | return _left.V == _right.V; 316 | } 317 | public static bool operator !=(SecureInt _left, int _right) 318 | { 319 | return _left.V != _right; 320 | } 321 | public static bool operator !=(SecureInt _left, SecureInt _right) 322 | { 323 | return _left.V != _right.V; 324 | } 325 | 326 | public static int operator *(SecureInt _left, int _right) 327 | { 328 | return _left.V * _right; 329 | } 330 | public static int operator *(int _left, SecureInt _right) 331 | { 332 | return _left * _right.V; 333 | } 334 | public static int operator *(SecureInt _left, SecureInt _right) 335 | { 336 | return _left.V * _right.V; 337 | } 338 | 339 | public static SecureInt operator ++(SecureInt _s) 340 | { 341 | return new SecureInt(_s.V + 1); 342 | } 343 | public static SecureInt operator --(SecureInt _s) 344 | { 345 | return new SecureInt(_s.V - 1); 346 | } 347 | 348 | 349 | public override string ToString() 350 | { 351 | return V.ToString(); 352 | } 353 | } -------------------------------------------------------------------------------- /u3d/Assets/Core/SecureNumber.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aa91eb8f56f354c9b8876e6b51cc55ef 3 | timeCreated: 1536472189 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/SoundEffect.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | public class SoundEffect : MonoBehaviour 6 | { 7 | public AudioSource mAudioSource; 8 | public AudioSource mBgmAudioSource; 9 | 10 | //===== bgm 11 | // private float lastTime = 0; 12 | // private int updateCount = 0; 13 | // private const int updateInterval = 30; 14 | private float mBgmVol = 0; 15 | public float BgmVol 16 | { 17 | get 18 | { 19 | return mBgmVol; 20 | } 21 | } 22 | // private int trackIndex = 0; 23 | // private float muteTime = 30; 24 | private const float MAX_VOLUME = 1; 25 | private const float FADE_SPEED = 0.3f; 26 | private float mCurFadeSpeed = 0.3f; 27 | private bool mIsFading = false; 28 | private AudioClip mNextClip; 29 | //======= 30 | 31 | private bool mEnableSfx = true; 32 | public bool EnableSfx 33 | { 34 | get 35 | { 36 | return mEnableSfx; 37 | } 38 | set 39 | { 40 | mEnableSfx = value; 41 | } 42 | } 43 | private bool mEnableBgm = true; 44 | public bool EnableBgm 45 | { 46 | get 47 | { 48 | return mEnableBgm; 49 | } 50 | set 51 | { 52 | mEnableBgm = value; 53 | } 54 | } 55 | 56 | private Dictionary mSfxs = new Dictionary(); 57 | private Dictionary mBgms = new Dictionary(); 58 | 59 | void Awake() 60 | { 61 | if(mAudioSource == null) 62 | mAudioSource = GetComponent(); 63 | } 64 | 65 | void Update() 66 | { 67 | if (mIsFading) 68 | { 69 | mBgmVol += Time.deltaTime * mCurFadeSpeed; 70 | 71 | if(mCurFadeSpeed > 0) 72 | { 73 | if (mBgmVol > MAX_VOLUME) 74 | { 75 | mBgmVol = MAX_VOLUME; 76 | mIsFading = false; 77 | } 78 | } 79 | else 80 | { 81 | if (mBgmVol < 0) 82 | { 83 | mBgmVol = 0; 84 | mIsFading = false; 85 | } 86 | } 87 | mBgmAudioSource.volume = mBgmVol; 88 | if(mBgmVol <= 0) 89 | { 90 | StopBgm(); 91 | } 92 | } 93 | else 94 | { 95 | if(mNextClip != null) 96 | { 97 | FadeIn(mNextClip); 98 | mNextClip = null; 99 | } 100 | } 101 | } 102 | 103 | //================================= sfx 104 | public void ClearSfx() 105 | { 106 | mSfxs.Clear(); 107 | } 108 | 109 | public void StopSfx() 110 | { 111 | if(mAudioSource != null) 112 | { 113 | mAudioSource.Stop(); 114 | } 115 | } 116 | 117 | public void PlaySfx(string _clipFileName) 118 | { 119 | AudioClip clip; 120 | if(!mSfxs.TryGetValue(_clipFileName, out clip)) 121 | { 122 | clip = Resources.Load("sound/"+_clipFileName) as AudioClip; 123 | mSfxs.Add(_clipFileName, clip); 124 | } 125 | PlaySfx(clip); 126 | } 127 | 128 | public void PlaySfx(int _clipId) 129 | { 130 | // TableSoundInfo.Data data = ClientTableDataManager.Instance.GetSoundData((int)_clipId); 131 | } 132 | 133 | public void PlaySfx(AudioClip _clip) 134 | { 135 | // Debug.LogError("error clip name " + _clip.name); 136 | // return; 137 | if (mAudioSource && _clip && mEnableSfx) 138 | { 139 | mAudioSource.PlayOneShot(_clip); 140 | } 141 | } 142 | 143 | //======================= bgm 144 | public void PlayBgm(string _filename) 145 | { 146 | AudioClip clip; 147 | 148 | if(!mBgms.TryGetValue(_filename, out clip)) 149 | { 150 | clip = Resources.Load("sound/"+_filename) as AudioClip; 151 | mBgms.Add(_filename,clip); 152 | } 153 | FadeIn(clip); 154 | } 155 | 156 | public void PlayBgmFadeOutIn(string _filename) 157 | { 158 | AudioClip clip; 159 | 160 | if(!mBgms.TryGetValue(_filename, out clip)) 161 | { 162 | clip = Resources.Load("sound/"+_filename) as AudioClip; 163 | mBgms.Add(_filename,clip); 164 | } 165 | FadeOutIn(clip); 166 | } 167 | 168 | public void ClearBgm() 169 | { 170 | mBgms.Clear(); 171 | } 172 | 173 | public void StopBgm() 174 | { 175 | if(mBgmAudioSource != null) 176 | { 177 | mBgmAudioSource.Stop(); 178 | } 179 | } 180 | 181 | public void FadeIn(AudioClip _clip) 182 | { 183 | if (_clip && mEnableBgm) 184 | { 185 | mBgmVol = 0; 186 | mBgmAudioSource.volume = mBgmVol; 187 | mBgmAudioSource.loop = true; 188 | mBgmAudioSource.clip = _clip; 189 | mBgmAudioSource.Play(); 190 | 191 | mIsFading = true; 192 | mCurFadeSpeed = FADE_SPEED; 193 | } 194 | } 195 | 196 | public void FadeOutIn(AudioClip _clip) 197 | { 198 | FadeOut(); 199 | mNextClip = _clip; 200 | } 201 | 202 | public void FadeOut() 203 | { 204 | mIsFading = true; 205 | mCurFadeSpeed = FADE_SPEED * -1f; 206 | } 207 | } 208 | 209 | -------------------------------------------------------------------------------- /u3d/Assets/Core/SoundEffect.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4577098b1581d479cab2eb1f9010d033 3 | timeCreated: 1536472189 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/TextureTileAnimationWholeMesh.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class TextureTileAnimationWholeMesh : MonoBehaviour 5 | { 6 | 7 | public int XTile = 1; 8 | public int YTile = 1; 9 | public float interval = 0.05F; 10 | public bool loop = true; 11 | public KeyCode key = KeyCode.F; 12 | 13 | float m_timer = 0; 14 | int index = 0; 15 | int tileCount = 1; 16 | Material _mat; 17 | // Use this for initialization 18 | void Start() 19 | { 20 | tileCount = XTile * YTile; 21 | } 22 | 23 | void OnEnable() 24 | { 25 | index = 0; 26 | m_timer = interval; 27 | } 28 | 29 | void OnDestroy() 30 | { 31 | if (_mat != null) 32 | { 33 | GameObject.DestroyImmediate(_mat); 34 | } 35 | } 36 | 37 | // Update is called once per frame 38 | Vector2 tileOffset = new Vector2(); 39 | void Update() 40 | { 41 | /*if (renderer.enabled == false) 42 | { 43 | if (Input.GetKeyDown(key)) 44 | { 45 | index = 0; 46 | renderer.enabled = true; 47 | } 48 | } 49 | else*/ 50 | { 51 | m_timer -= Time.deltaTime; 52 | // 53 | if (m_timer < 0) 54 | { 55 | while (m_timer < 0) 56 | { 57 | if (index < (tileCount - 1)) 58 | { 59 | index++; 60 | } 61 | else 62 | { 63 | if (loop) 64 | { 65 | index = 0; 66 | } 67 | else 68 | { 69 | GetComponent().enabled = false; 70 | } 71 | } 72 | m_timer += interval; 73 | } 74 | int x = index % XTile; 75 | int y = index / XTile; 76 | tileOffset.x = x / (float)XTile; 77 | tileOffset.y = -y / (float)YTile; 78 | GetComponent().material.mainTextureOffset = tileOffset; 79 | _mat = GetComponent().material; 80 | //m_timer = interval; 81 | } 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /u3d/Assets/Core/TextureTileAnimationWholeMesh.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b75e649570a864733ac1772c349958d2 3 | timeCreated: 1536472189 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/TimeConvert.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | using UnityEngine; 4 | 5 | 6 | //time convert 7 | public class TimeConvert 8 | { 9 | public const long TICKS_TO_SECOND = 10000000L; 10 | public static long sSeverTime = 0; 11 | public static float sServerStartTime = 0; 12 | 13 | public static long GetSeverTime() 14 | { 15 | return sSeverTime + (long)((Time.realtimeSinceStartup - sServerStartTime)*1000f); 16 | } 17 | 18 | //convert from unix time to string date time 19 | public static string UNIXTimeToDateTimeString(long time) 20 | { 21 | DateTime date = UNIXTimeToDateTime(time); 22 | return date.ToString("yyyy/MM/dd hh:mm:ss"); 23 | } 24 | 25 | //convert from unix time to string date 26 | public static string UNIXTimeToDateString(long time) 27 | { 28 | DateTime date = UNIXTimeToDateTime(time); 29 | return date.ToString("yyyy-MM-dd"); 30 | } 31 | 32 | //convert form unix time to c# time 33 | public static DateTime UNIXTimeToDateTime(long time) 34 | { 35 | long timeL = time * 10000000 + (new DateTime(1970, 1, 1, 8, 0, 0).Ticks); 36 | 37 | DateTime date = new DateTime(timeL); 38 | return date; 39 | } 40 | 41 | //c# date time convert to unix time 42 | public static long DateTimeToUNIXTime( DateTime dt ) 43 | { 44 | long timeL = (dt.Ticks - (new DateTime(1970, 1, 1, 8, 0, 0).Ticks)) / 10000000L; 45 | return timeL; 46 | } 47 | 48 | // Show "22m 22.351s" 49 | public static string MilSecToString(long _milSec) 50 | { 51 | int inSec = (int)(_milSec / 1000); 52 | 53 | int minute = inSec / 60; 54 | int second = inSec % 60; 55 | int msecond = (int)(_milSec % 1000); 56 | 57 | string result = " "; 58 | if (minute > 0) 59 | result = minute + "m"; 60 | 61 | if (second != 0 || msecond != 0) 62 | result = result + " " + second + "." + msecond + "s"; 63 | 64 | return result; 65 | } 66 | 67 | // Show "22d 22h" or "22m 22s" or "22h 22m" 68 | public static string SecondToString(int second) 69 | { 70 | string dd = "d"; 71 | string hh = "h"; 72 | string mm = "m"; 73 | string ss = "s"; 74 | 75 | string str = string.Empty; 76 | if (second <= 0) 77 | return "0" + ss; 78 | 79 | int day = second / 86400; 80 | int hour = (second - day * 86400) / 3600; 81 | int minute = (second - day * 86400 - hour * 3600) / 60; 82 | second = second - day * 86400 - hour * 3600 - minute * 60; 83 | if (day > 0) 84 | { 85 | str = str + day + dd; 86 | if (hour > 0) str = str + " "; 87 | } 88 | if (hour > 0) 89 | { 90 | if (hour < 10) 91 | str = str + " " + hour + hh; 92 | else 93 | str = str + hour + hh; 94 | if (day == 0 && minute > 0) str = str + " "; 95 | } 96 | // max show two time segments 5d 20h 97 | if (day == 0) 98 | { 99 | if (minute > 0) 100 | { 101 | if (minute < 10) 102 | str = str + " " + minute + mm; 103 | else 104 | str = str + minute + mm; 105 | if (hour == 0 && second > 0) str = str + " "; 106 | } 107 | // max show two time segments 20h 43m 108 | if (hour == 0) 109 | { 110 | if (second > 0) 111 | { 112 | if (second < 10) 113 | str = str + " " + second + ss; 114 | else 115 | str = str + second + ss; 116 | } 117 | } 118 | } 119 | return str; 120 | } 121 | 122 | 123 | 124 | // Show "22:22:22" 125 | public static string SecondToString2(int second) 126 | { 127 | string str = string.Empty; 128 | int hour = second / 3600; 129 | int minute = (second - hour * 3600) / 60; 130 | second = second - hour * 3600 - minute * 60; 131 | if (hour != 0) 132 | { 133 | if (hour < 10) 134 | str = str + "0" + hour + ":"; 135 | else 136 | str = str + hour + ":"; 137 | } 138 | if (minute < 10) 139 | str = str + "0" + minute + ":"; 140 | else 141 | str = str + minute + ":"; 142 | if (second < 10) 143 | str = str + "0" + second; 144 | else 145 | str = str + second; 146 | return str; 147 | } 148 | } -------------------------------------------------------------------------------- /u3d/Assets/Core/TimeConvert.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b514c8fc290c24a919a0a87ebb474db1 3 | timeCreated: 1536472189 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/Vector3_Extensions.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | 5 | public static class Vector3_Extensions 6 | { 7 | public static Vector2 xy(this Vector3 this_) 8 | { 9 | return new UnityEngine.Vector2( this_.x, this_.y); 10 | } 11 | 12 | public static Vector2 xz(this Vector3 this_) 13 | { 14 | return new UnityEngine.Vector2( this_.x, this_.z); 15 | } 16 | 17 | public static Vector2 yz(this Vector3 this_) 18 | { 19 | return new UnityEngine.Vector2( this_.y, this_.z); 20 | } 21 | 22 | public static Vector2 yx(this Vector3 this_) 23 | { 24 | return new UnityEngine.Vector2( this_.y, this_.x); 25 | } 26 | 27 | public static Vector2 zx(this Vector3 this_) 28 | { 29 | return new UnityEngine.Vector2( this_.z, this_.x); 30 | } 31 | 32 | public static Vector2 zy(this Vector3 this_) 33 | { 34 | return new UnityEngine.Vector2( this_.z, this_.y); 35 | } 36 | } -------------------------------------------------------------------------------- /u3d/Assets/Core/Vector3_Extensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea016318d73a44639a3100cc0f155f7a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /u3d/Assets/Core/batchRender.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eca908e890a5b4bc8b992313076e391e 3 | folderAsset: yes 4 | timeCreated: 1536472189 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /u3d/Assets/Core/batchRender/BatchRenderer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections.Generic; 3 | 4 | public class BatchRenderer : MonoBehaviour 5 | { 6 | private int updateCounter = 0; 7 | public MeshRenderer m_meshRenderer = null; 8 | public MeshFilter m_meshFilter = null; 9 | 10 | Vector3 m_position = new Vector3(); 11 | Quaternion m_rotation = new Quaternion(); 12 | Vector2 m_texOffset = new Vector2(); 13 | public int m_stablePeriod = 1; 14 | 15 | public enum BatchState 16 | { 17 | None, 18 | AddBatch, 19 | RemoveBatch, 20 | } 21 | float mRenderStartTime = 0; 22 | bool mInitRender = false; 23 | public BatchState mState = BatchState.None; 24 | bool mDelayBatch = false; 25 | 26 | public static void DelayBatch(GameObject _go) 27 | { 28 | BatchRenderer[] batch_renders = _go.GetComponentsInChildren(); 29 | for(int i = 0 ; i(); 38 | for(int i = 0 ; i(); 52 | for (int i = 0; i < meshRenders.Length; ++i) 53 | { 54 | MeshRenderer meshR = meshRenders[i]; 55 | // if (meshR.gameObject.GetComponent() != null) 56 | // continue; 57 | // if (meshR.gameObject.GetComponent() != null) 58 | // continue; 59 | BatchRenderer br = meshR.gameObject.GetComponent(); 60 | if (br == null) 61 | { 62 | if (meshR.sharedMaterials.Length > 1) 63 | { 64 | Debug.LogError("More than one material: " + meshR.gameObject.name); 65 | } 66 | if (meshR.sharedMaterial != null) 67 | { 68 | MeshFilter meshF = meshR.gameObject.GetComponent(); 69 | if (meshF.sharedMesh != null) 70 | { 71 | if (meshF.sharedMesh.subMeshCount > 1) 72 | { 73 | Debug.LogError("More than one subMesh: " + meshF.gameObject.name); 74 | } 75 | br = meshF.gameObject.AddComponent(); 76 | br.m_stablePeriod = _stablePeriod; 77 | } 78 | } 79 | } 80 | else 81 | { 82 | br.m_stablePeriod = _stablePeriod; 83 | } 84 | } 85 | } 86 | 87 | public static void LoopEachBatch(Transform _transform) 88 | { 89 | for(int i = 0 ; i<_transform.childCount ; i++) 90 | { 91 | Transform child = _transform.GetChild(i); 92 | if(child.GetComponent() != null) 93 | { 94 | continue; 95 | } 96 | if(child.GetComponent() != null) 97 | { 98 | PlanAddBatchRenderer(child.gameObject,10); 99 | continue; 100 | } 101 | LoopEachBatch(child); 102 | } 103 | } 104 | 105 | //will be change when be attack destroy, 106 | //drag to move, build cancel remove, 107 | //remove trash, upgrade finished 108 | //cancel move, cancel mutil walls move 109 | //edit base switch, edit base remove all 110 | //edit base drag, edit base release, edit base cancel 111 | //edit base erase mode remove building 112 | //edit switch to home 113 | //edit base exit 114 | //edit base add new building quickly 115 | public static void BatchRemoveNow(GameObject go) 116 | { 117 | BatchRenderer[] batchs = go.GetComponentsInChildren(); 118 | // batchs._Update(); 119 | for(int i = 0 ; i(); 132 | // batchs._Update(); 133 | for(int i = 0 ; i(); 153 | } 154 | if (m_meshRenderer.sharedMaterials.Length > 1) 155 | { 156 | Debug.LogError("More than one material: " + m_meshRenderer.gameObject.name); 157 | } 158 | if (m_meshRenderer.sharedMaterial != null) 159 | { 160 | MeshFilter meshF = m_meshRenderer.gameObject.GetComponent(); 161 | if (meshF != null) 162 | { 163 | m_meshFilter = meshF; 164 | } 165 | } 166 | mRenderStartTime = Time.time; 167 | } 168 | 169 | void OnDestroy() 170 | { 171 | OnDisable(); 172 | } 173 | 174 | public void OnDisable() 175 | { 176 | if (BatchRendererManager.Instance != null && BatchRendererManager.Instance.enabled) 177 | BatchRendererManager.Instance.RemoveRenderer(this); 178 | } 179 | 180 | public void OnEnable() 181 | { 182 | if(mInitRender) 183 | { 184 | if (BatchRendererManager.Instance != null && BatchRendererManager.Instance.enabled) 185 | { 186 | BatchRendererManager.Instance.AddRenderer(this); 187 | } 188 | } 189 | } 190 | 191 | public void DisableBatch() 192 | { 193 | if (BatchRendererManager.Instance != null && BatchRendererManager.Instance.enabled) 194 | BatchRendererManager.Instance.RemoveRenderer(this); 195 | } 196 | 197 | void Update() 198 | { 199 | if(mDelayBatch) return; 200 | if(mInitRender) return; 201 | if (Time.time - mRenderStartTime > 0.3f) 202 | { 203 | mInitRender = true; 204 | 205 | if (m_meshRenderer != null && m_meshFilter != null && m_meshFilter.sharedMesh != null && BatchRendererManager.Instance != null) 206 | { 207 | Vector3 curPosition = transform.position; 208 | Quaternion curRotation = transform.rotation; 209 | Vector2 curTexOffset = Vector2.zero; 210 | // if (m_meshRenderer.material != null) 211 | // curTexOffset = m_meshRenderer.material.GetTextureOffset("_MainTex"); 212 | // //if ((curPosition - m_position).sqrMagnitude > 0.00001f) // moving 213 | // if (curPosition != m_position || curRotation != m_rotation || curTexOffset != m_texOffset) 214 | // { 215 | // if (m_stableCount > m_stablePeriod && m_stablePeriod > 0) // if period is 0, it will be added in this frame, no need to remove 216 | // { 217 | // BatchRendererManager.Instance.RemoveRenderer(this); 218 | // } 219 | // m_stableCount = 0; 220 | // } 221 | m_position = curPosition; 222 | m_rotation = curRotation; 223 | m_texOffset = curTexOffset; 224 | 225 | BatchRendererManager.Instance.AddRenderer(this, m_stablePeriod); 226 | mState = BatchState.AddBatch; 227 | } 228 | 229 | } 230 | } 231 | } 232 | -------------------------------------------------------------------------------- /u3d/Assets/Core/batchRender/BatchRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 361ecda029d784157a6569102f3c4b23 3 | timeCreated: 1536472189 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/batchRender/BatchRendererManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 60bbb033dc6a0487daacbd120e972734 3 | timeCreated: 1536472189 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/eppzGeometry.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 54676f49ed3e74a809fb0ddd097fbf99 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /u3d/Assets/Core/eppzGeometry/Clipper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 715f72d2519bba24fb873180d86e7d46 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /u3d/Assets/Core/eppzGeometry/Edge.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2017 Geri Borbás http://www.twitter.com/_eppz 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 7 | // 8 | using UnityEngine; 9 | using System.Collections; 10 | 11 | 12 | namespace EPPZ.Geometry.Model 13 | { 14 | 15 | 16 | public class Edge : Segment 17 | { 18 | 19 | 20 | private int _index; 21 | public int index { get { return _index; } } // Readonly 22 | public Polygon polygon { get { return vertexA.polygon; } } // Readonly 23 | 24 | public Vertex vertexA; 25 | public Vertex vertexB; 26 | 27 | 28 | #region Factory 29 | 30 | public static Edge EdgeAtIndexWithVertices(int index, Vertex vertexA, Vertex vertexB) 31 | { 32 | Edge instance = new Edge(); 33 | instance._index = index; 34 | instance.vertexA = vertexA; 35 | instance.vertexB = vertexB; 36 | return instance; 37 | } 38 | 39 | #endregion 40 | 41 | 42 | #region Override segment point accessors (perefencing polygon points directly). 43 | 44 | public override Vector2 a 45 | { 46 | get { return polygon.points[vertexA.index]; } 47 | set { polygon.points[vertexA.index] = value; } 48 | } 49 | 50 | public override Vector2 b 51 | { 52 | get { return polygon.points[vertexB.index]; } 53 | set { polygon.points[vertexB.index] = value; } 54 | } 55 | 56 | #endregion 57 | 58 | 59 | #region Accessors 60 | 61 | public Edge _previousEdge; 62 | public virtual Edge previousEdge { get { return _previousEdge; } } // Readonly 63 | public void SetPreviousEdge(Edge edge) { _previousEdge = edge; } // Explicit setter (injected at creation time) 64 | 65 | public Edge _nextEdge; 66 | public virtual Edge nextEdge { get { return _nextEdge; } } // Readonly 67 | public void SetNextEdge(Edge edge) { _nextEdge = edge; } // Explicit setter (injected at creation time) 68 | 69 | #endregion 70 | 71 | 72 | #region Polygon features 73 | 74 | public bool ForwardIntersection(out Edge intersectingEdge, out Vector2 intersectionPoint, bool checkEntirePolygonLoop) 75 | { 76 | // Default. 77 | intersectingEdge = null; 78 | intersectionPoint = Vector2.zero; 79 | bool intersecting = false; 80 | 81 | // Only if there are edges enough to test. 82 | if (this.polygon.edges.Length <= 3) return false; 83 | 84 | Edge testEdge = this.nextEdge.nextEdge; // Skip next neighbour 85 | while(true) 86 | { 87 | intersecting = this.IntersectionWithSegment(testEdge, out intersectionPoint); 88 | if (intersecting) 89 | { 90 | intersectingEdge = testEdge; 91 | break; 92 | } 93 | 94 | // Step. 95 | testEdge = testEdge.nextEdge; 96 | 97 | // End conditions. 98 | bool end; 99 | if (checkEntirePolygonLoop) 100 | { 101 | end = (testEdge == this.previousEdge.previousEdge); // Only up till the previous neighbour 102 | } 103 | else 104 | { 105 | end = (testEdge == this.polygon.edges[0].previousEdge); // Only up till the end of the polygon loop 106 | } 107 | if (end) break; 108 | } 109 | 110 | return intersecting; 111 | } 112 | 113 | #endregion 114 | 115 | 116 | } 117 | } -------------------------------------------------------------------------------- /u3d/Assets/Core/eppzGeometry/Edge.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8f04e7f419e0481e89a4855c1afe48d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /u3d/Assets/Core/eppzGeometry/Geometry.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2017 Geri Borbás http://www.twitter.com/_eppz 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 7 | // 8 | using UnityEngine; 9 | using System.Collections; 10 | using System.Collections.Generic; 11 | 12 | 13 | namespace EPPZ.Geometry 14 | { 15 | 16 | 17 | using Model; // For `Polygon` region only 18 | 19 | 20 | public static class Geometry 21 | { 22 | 23 | 24 | #region Point 25 | 26 | // Determine if points are equal with a given accuracy. 27 | public static bool ArePointsEqualWithAccuracy(Vector2 a, Vector2 b, float accuracy) 28 | { 29 | return Vector2.Distance(a, b) <= accuracy; 30 | } 31 | 32 | // Determine winding direction of three points. 33 | public static bool ArePointsCCW(Vector2 a, Vector2 b, Vector2 c) 34 | { 35 | return ((c.y - a.y) * (b.x - a.x) > (b.y - a.y) * (c.x - a.x)); 36 | } 37 | 38 | #endregion 39 | 40 | 41 | #region Rect / Bounds 42 | 43 | // Determine if `rect2.size` fits into `rect1`. 44 | public static bool IsRectContainsRectSizeWithAccuracy(Rect rect1, Rect rect2) // Compare sizes only 45 | { 46 | return Geometry.IsRectContainsRectSizeWithAccuracy(rect1, rect2, 0.0f); 47 | } 48 | 49 | // Determine if `rect2.size` fits into `rect1` with a given accuracy. 50 | public static bool IsRectContainsRectSizeWithAccuracy(Rect rect1, Rect rect2, float accuracy) // Compare sizes only 51 | { 52 | return ( 53 | Mathf.Abs(rect1.width + accuracy * 2.0f) >= Mathf.Abs(rect2.width)) && 54 | (Mathf.Abs(rect1.height + accuracy * 2.0f) >= Mathf.Abs(rect2.height) 55 | ); 56 | } 57 | 58 | // Determine if `rect2` is contained by `rect1` (even if permiters are touching). 59 | public static bool IsRectContainsRectWithAccuracy(Rect rect1, Rect rect2) 60 | { return Geometry.IsRectContainsRectWithAccuracy(rect1, rect2, 0.0f); } 61 | 62 | // Determine if `rect2` is contained by `rect1` (even if permiters are touching) with a given accuracy. 63 | public static bool IsRectContainsRectWithAccuracy(Rect rect1, Rect rect2, float accuracy) 64 | { 65 | bool xMin = (rect1.xMin - accuracy <= rect2.xMin); 66 | bool xMax = (rect1.xMax + accuracy >= rect2.xMax); 67 | bool yMin = (rect1.yMin - accuracy <= rect2.yMin); 68 | bool yMax = (rect1.yMax + accuracy >= rect2.yMax); 69 | return xMin && xMax && yMin && yMax; 70 | } 71 | 72 | #endregion 73 | 74 | 75 | #region Line 76 | 77 | /// 78 | /// Returns intersection point of two lines (defined by segment endpoints). 79 | /// Returns zero, when segments have common points, or when a segment point lies on other. 80 | /// 81 | public static Vector2 IntersectionPointOfLines(Vector2 segment1_a, Vector2 segment1_b, Vector2 segment2_a, Vector2 segment2_b) 82 | { 83 | float crossProduct = (segment1_a.x - segment1_b.x) * (segment2_a.y - segment2_b.y) - (segment1_a.y - segment1_b.y) * (segment2_a.x - segment2_b.x); 84 | if (crossProduct == 0.0f) return Vector2.zero; 85 | 86 | float x = ((segment2_a.x - segment2_b.x) * (segment1_a.x * segment1_b.y - segment1_a.y * segment1_b.x) - (segment1_a.x - segment1_b.x) * (segment2_a.x * segment2_b.y - segment2_a.y * segment2_b.x)) / crossProduct; 87 | float y = ((segment2_a.y - segment2_b.y) * (segment1_a.x * segment1_b.y - segment1_a.y * segment1_b.x) - (segment1_a.y - segment1_b.y) * (segment2_a.x * segment2_b.y - segment2_a.y * segment2_b.x)) / crossProduct; 88 | 89 | // Skip segmental tests. 90 | // if (x < Mathf.Min(a1.x, b1.x) || x > Mathf.Max(a1.x, b1.x)) return Vector2.zero; 91 | // if (x < Mathf.Min(a2.x, b2.x) || x > Mathf.Max(a2.x, b2.x)) return Vector2.zero; 92 | 93 | return new Vector2(x, y); 94 | } 95 | 96 | // Determine point distance from line (defined by segment endpoints). 97 | public static float PointDistanceFromLine(Vector2 point, Vector2 segment_a, Vector2 segment_b) 98 | { 99 | float a_ = point.x - segment_a.x; 100 | float b_ = point.y - segment_a.y; 101 | float c_ = segment_b.x - segment_a.x; 102 | float d_ = segment_b.y - segment_a.y; 103 | return Mathf.Abs(a_ * d_ - c_ * b_) / Mathf.Sqrt(c_ * c_ + d_ * d_); 104 | } 105 | 106 | #endregion 107 | 108 | 109 | #region Segment 110 | 111 | // Determine if a given point lies on the left side of a segment (line beneath). 112 | public static bool PointIsLeftOfSegment(Vector2 point, Vector2 segment_a, Vector2 segment_b) 113 | { 114 | float crossProduct = (segment_b.x - segment_a.x) * (point.y - segment_a.y) - (segment_b.y - segment_a.y) * (point.x - segment_a.x); 115 | return (crossProduct > 0.0f); 116 | } 117 | 118 | // Determine if segments (defined by endpoints) are equal with a given accuracy. 119 | public static bool AreSegmentsEqualWithAccuracy(Vector2 segment1_a, Vector2 segment1_b, Vector2 segment2_a, Vector2 segment2_b, float accuracy) 120 | { 121 | return ( 122 | (ArePointsEqualWithAccuracy(segment1_a, segment2_a, accuracy) && ArePointsEqualWithAccuracy(segment1_b, segment2_b, accuracy)) || 123 | (ArePointsEqualWithAccuracy(segment1_a, segment2_b, accuracy) && ArePointsEqualWithAccuracy(segment1_b, segment2_a, accuracy)) 124 | ); 125 | } 126 | 127 | // Determine if segments (defined by endpoints) have common points with a given accuracy. 128 | public static bool HaveSegmentsCommonPointsWithAccuracy(Vector2 segment1_a, Vector2 segment1_b, Vector2 segment2_a, Vector2 segment2_b, float accuracy) 129 | { 130 | return ( 131 | ArePointsEqualWithAccuracy(segment1_a, segment2_a, accuracy) || 132 | ArePointsEqualWithAccuracy(segment1_a, segment2_b, accuracy) || 133 | ArePointsEqualWithAccuracy(segment1_b, segment2_a, accuracy) || 134 | ArePointsEqualWithAccuracy(segment1_b, segment2_b, accuracy) 135 | ); 136 | } 137 | 138 | /// 139 | /// Determine if two segments defined by endpoints are intersecting (defined by points). 140 | /// True when the two segments are intersecting. Not true when endpoints 141 | /// are equal, nor when a point is contained by other segment. 142 | /// From http://bryceboe.com/2006/10/23/line-segment-intersection-algorithm/ 143 | /// 144 | public static bool AreSegmentsIntersecting(Vector2 segment1_a, Vector2 segment1_b, Vector2 segment2_a, Vector2 segment2_b) 145 | { 146 | return ( 147 | (ArePointsCCW(segment1_a, segment2_a, segment2_b) != ArePointsCCW(segment1_b, segment2_a, segment2_b)) && 148 | (ArePointsCCW(segment1_a, segment1_b, segment2_a) != ArePointsCCW(segment1_a, segment1_b, segment2_b)) 149 | ); 150 | } 151 | 152 | #endregion 153 | 154 | 155 | #region Polygon 156 | 157 | /// 158 | /// Test if a polygon contains the given point (checks for sub-polygons recursive). 159 | /// Uses the same Bryce boe algorythm, so considerations are the same. 160 | /// From https://en.wikipedia.org/wiki/Point_in_polygon#Ray_casting_algorithm 161 | /// 162 | public static bool IsPolygonContainsPoint(Polygon polygon, Vector2 point) 163 | { 164 | // Winding ray left point. 165 | Vector2 left = new Vector2(polygon.bounds.xMin - polygon.bounds.width, point.y); 166 | 167 | // Enumerate polygon segments. 168 | int windingNumber = 0; 169 | polygon.EnumerateEdgesRecursive((Edge eachEdge) => 170 | { 171 | // Test winding ray against each polygon segment. 172 | if (AreSegmentsIntersecting(left, point, eachEdge.a, eachEdge.b)) 173 | { windingNumber++; } 174 | }); 175 | 176 | bool isOdd = (windingNumber % 2 != 0); // Odd winding number means point falls outside 177 | return isOdd; 178 | } 179 | 180 | public static Vector2 CentroidOfPolygons(Polygon[] polygons) 181 | { 182 | // From https://en.wikipedia.org/wiki/Centroid#By_geometric_decomposition 183 | float ΣxA = 0.0f; 184 | float ΣyA = 0.0f; 185 | float ΣA = 0.0f; 186 | foreach (Polygon eachPolygon in polygons) 187 | { 188 | // Get centroid. 189 | Vector2 eachCentroid = eachPolygon.centroid; 190 | 191 | // Sum weighted. 192 | ΣxA += eachCentroid.x * eachPolygon.area; 193 | ΣyA += eachCentroid.y * eachPolygon.area; 194 | ΣA += eachPolygon.area; 195 | } 196 | 197 | // "Remove" area. 198 | float x = ΣxA / ΣA; 199 | float y = ΣyA / ΣA; 200 | 201 | return new Vector2(x, y); 202 | } 203 | 204 | #endregion 205 | 206 | 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /u3d/Assets/Core/eppzGeometry/Geometry.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 324ba7aabd819ee40a6f888acb247494 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /u3d/Assets/Core/eppzGeometry/Polygon.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3024a1cbde06044dcafead4cd24f3951 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /u3d/Assets/Core/eppzGeometry/Segment.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 578ca8bb78e354a369b7aa397c854195 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /u3d/Assets/Core/eppzGeometry/Vector2.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2017 Geri Borbás http://www.twitter.com/_eppz 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 7 | // 8 | using System; 9 | using UnityEngine; 10 | 11 | 12 | namespace EPPZ.Geometry 13 | { 14 | 15 | 16 | public static class Vector2_Extensions 17 | { 18 | 19 | 20 | public static Vector2 Rotated(this Vector2 this_, float degrees) 21 | { 22 | // Checks. 23 | float radians = degrees * Mathf.Deg2Rad; 24 | if (radians == 0.0f) return this_; 25 | if (radians == (Mathf.PI * 2.0f)) return this_; 26 | 27 | float sin = Mathf.Sin(radians); 28 | float cos = Mathf.Cos(radians); 29 | 30 | Vector2 rotated = new Vector2( 31 | (cos * this_.x) - (sin * this_.y), 32 | (sin * this_.x) + (cos * this_.y) 33 | ); 34 | 35 | return rotated; 36 | } 37 | 38 | public static Vector2 RotatedAround(this Vector2 this_, Vector2 around, float degrees) 39 | { 40 | // Checks. 41 | float radians = degrees * Mathf.Deg2Rad; 42 | if (radians == 0.0f) return this_; 43 | if (radians == (Mathf.PI * 2.0f)) return this_; 44 | 45 | Vector2 τposition = this_ - around; 46 | τposition = τposition.Rotated(degrees); 47 | τposition = around + τposition; 48 | 49 | return τposition; 50 | } 51 | 52 | public static float AngleTo(this Vector2 this_, Vector3 to) 53 | { return this_.AngleTo((Vector2)to); } 54 | 55 | public static float AngleTo(this Vector2 this_, Vector2 to) 56 | { 57 | Vector2 direction = to - this_; 58 | float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; 59 | if (angle < 0.0f) angle += 360.0f; 60 | return angle; 61 | } 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /u3d/Assets/Core/eppzGeometry/Vector2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e41cdaf840e98404881ced34a836ba3f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /u3d/Assets/Core/eppzGeometry/Vector3.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2017 Geri Borbás http://www.twitter.com/_eppz 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 7 | // 8 | using System; 9 | using UnityEngine; 10 | 11 | 12 | namespace EPPZ.Geometry 13 | { 14 | 15 | 16 | public static class Vector3_Extensions 17 | { 18 | 19 | 20 | public static Vector2 xy(this Vector3 this_) 21 | { 22 | return new UnityEngine.Vector2( this_.x, this_.y); 23 | } 24 | 25 | public static Vector2 xz(this Vector3 this_) 26 | { 27 | return new UnityEngine.Vector2( this_.x, this_.z); 28 | } 29 | 30 | public static Vector2 yz(this Vector3 this_) 31 | { 32 | return new UnityEngine.Vector2( this_.y, this_.z); 33 | } 34 | 35 | public static Vector2 yx(this Vector3 this_) 36 | { 37 | return new UnityEngine.Vector2( this_.y, this_.x); 38 | } 39 | 40 | public static Vector2 zx(this Vector3 this_) 41 | { 42 | return new UnityEngine.Vector2( this_.z, this_.x); 43 | } 44 | 45 | public static Vector2 zy(this Vector3 this_) 46 | { 47 | return new UnityEngine.Vector2( this_.z, this_.y); 48 | } 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /u3d/Assets/Core/eppzGeometry/Vector3.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 26b6620df6d6b0a46962c0c0074dd04d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /u3d/Assets/Core/eppzGeometry/Vertex.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2017 Geri Borbás http://www.twitter.com/_eppz 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 7 | // 8 | using UnityEngine; 9 | using System.Collections; 10 | 11 | 12 | namespace EPPZ.Geometry.Model 13 | { 14 | 15 | 16 | public class Vertex 17 | { 18 | 19 | 20 | private int _index; 21 | public int index { get { return _index; } } // Readonly 22 | private Polygon _polygon; 23 | public Polygon polygon { get { return _polygon; } } // Readonly 24 | 25 | // If `alwaysCalculate` is on, every `normal` and `bisector` property access invokes recalculation of values based on actual topology. 26 | public bool alwaysCalculate = true; 27 | 28 | private Vector2 _normal; 29 | public Vector2 normal 30 | { 31 | get 32 | { 33 | if (_normal == Vector2.zero || alwaysCalculate) { CalculateNormal(); } // Lazy calculation or force calculate on every access 34 | return _normal; 35 | } 36 | 37 | set 38 | { _normal = value; } 39 | } 40 | 41 | // Bisector is simply the sum of the neighbouring edge normals (not normalized). 42 | public Vector2 _bisector; 43 | public Vector2 bisector 44 | { 45 | get 46 | { 47 | if (_bisector == Vector2.zero || alwaysCalculate) { CalculateBisector(); } // Lazy calculation or force calculate on every access 48 | return _bisector; 49 | } 50 | 51 | set 52 | { _bisector = value; } 53 | } 54 | 55 | public void CalculateNormal() 56 | { _normal = this.bisector.normalized; } 57 | 58 | public void CalculateBisector() 59 | { _bisector = previousEdge.normal + nextEdge.normal; } 60 | 61 | 62 | #region Factory 63 | 64 | public static Vertex VertexAtIndexInPolygon(int index, Polygon polygon) 65 | { 66 | Vertex instance = new Vertex(); 67 | instance._index = index; 68 | instance._polygon = polygon; 69 | return instance; 70 | } 71 | 72 | #endregion 73 | 74 | 75 | #region Accessors 76 | 77 | private Vertex _previousVertex; 78 | public virtual Vertex previousVertex { get { return _previousVertex; } } // Readonly 79 | public void SetPreviousVertex(Vertex vertex) { _previousVertex = vertex; } // Explicit setter (injected at creation time) 80 | 81 | private Vertex _nextVertex; 82 | public virtual Vertex nextVertex { get { return _nextVertex; } } // Readonly 83 | public void SetNextVertex(Vertex vertex) { _nextVertex = vertex; } // Explicit setter (injected at creation time) 84 | 85 | private Edge _previousEdge; 86 | public virtual Edge previousEdge { get { return _previousEdge; } } // Readonly 87 | public void SetPreviousEdge(Edge edge) { _previousEdge = edge; } // Explicit setter (injected at creation time) 88 | 89 | private Edge _nextEdge; 90 | public virtual Edge nextEdge { get { return _nextEdge; } } // Readonly 91 | public void SetNextEdge(Edge edge) { _nextEdge = edge; } // Explicit setter (injected at creation time) 92 | 93 | public virtual Vector2 point { get { return polygon.points[index]; } } // Readonly 94 | public float x { get { return point.x; } } // Readonly 95 | public float y { get { return point.y; } } // Readonly 96 | 97 | #endregion 98 | 99 | 100 | } 101 | } -------------------------------------------------------------------------------- /u3d/Assets/Core/eppzGeometry/Vertex.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb3b0c75aa3b7408dab5053d6c9a7c70 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /u3d/Assets/Core/pathFinder.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 181121a2fb9cf477b8b272d7a6bcaba6 3 | folderAsset: yes 4 | timeCreated: 1536472189 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /u3d/Assets/Core/pathFinder/IPathFinder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | interface IPathFinder 5 | { 6 | #region Properties 7 | bool Stopped 8 | { 9 | get; 10 | } 11 | 12 | HeuristicFormula Formula 13 | { 14 | get; 15 | set; 16 | } 17 | 18 | bool Diagonals 19 | { 20 | get; 21 | set; 22 | } 23 | 24 | bool HeavyDiagonals 25 | { 26 | get; 27 | set; 28 | } 29 | 30 | int HeuristicEstimate 31 | { 32 | get; 33 | set; 34 | } 35 | 36 | bool PunishChangeDirection 37 | { 38 | get; 39 | set; 40 | } 41 | 42 | bool TieBreaker 43 | { 44 | get; 45 | set; 46 | } 47 | 48 | int SearchLimit 49 | { 50 | get; 51 | set; 52 | } 53 | 54 | double CompletedTime 55 | { 56 | get; 57 | set; 58 | } 59 | 60 | #endregion 61 | 62 | #region Methods 63 | void FindPathStop(); 64 | List FindPath(Point start, Point end, bool _ignoreObstacle); 65 | #endregion 66 | 67 | } 68 | 69 | -------------------------------------------------------------------------------- /u3d/Assets/Core/pathFinder/IPathFinder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e6e402a471c4149d0a584d9b81ef6dc9 3 | timeCreated: 1536472189 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/pathFinder/PathFinder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29ee43a1aa62b40a2ac77e1a04d01965 3 | timeCreated: 1536472189 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/pathFinder/PathFinderFast.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7c89fd9bfee634b39bf8b1a182a3d84b 3 | timeCreated: 1536472189 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/pathFinder/PathManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | public class PathManager 7 | { 8 | private int sUniquePathId; 9 | public Dictionary mDicPathAll; 10 | private static PathManager _instance; 11 | 12 | public const byte GRID_VALUE_CANNOT = 0; 13 | public static byte GRID_VALUE_GOOD = 10; 14 | public static byte GRID_VALUE_WALL = 100; 15 | public static byte GRID_VALUE_WALL_TARGETED = 11; 16 | public static byte GRID_ADD_VALUE_DIAGONAL = 4; 17 | //public const byte GRID_VALUE_GOOD_DIAGONAL = 14; 18 | //public const byte GRID_VALUE_WALL_DIAGONAL = 104; 19 | //public const byte GRID_VALUE_WALL_TARGETED_DIAGONAL = 24; 20 | 21 | #if false 22 | public static void SetWall(byte[,] _pathArray, int _i, int _j, int hp) 23 | { 24 | int newHp = Mathf.Clamp(hp / 5, GRID_VALUE_WALL_TARGETED + 9, 255); 25 | _pathArray[_i, _j] = (byte)newHp; 26 | } 27 | 28 | public static bool IsWall(byte[,] _pathArray, int _i, int _j) 29 | { 30 | return _pathArray[_i, _j] >= GRID_VALUE_WALL_TARGETED; 31 | } 32 | #endif 33 | 34 | public static PathManager Instance 35 | { 36 | get 37 | { 38 | if (_instance == null) 39 | _instance = new PathManager(); 40 | return _instance; 41 | } 42 | } 43 | 44 | private PathManager() 45 | { 46 | mDicPathAll = new Dictionary(); 47 | sUniquePathId = 0; 48 | } 49 | 50 | 51 | public PathObject GetPathById(int _id) 52 | { 53 | if(!mDicPathAll.ContainsKey(_id)) 54 | return null; 55 | else 56 | return mDicPathAll[_id]; 57 | } 58 | 59 | // if "ignoreObstacle" is true, pathfinding will ignore all obstacles except GRID_VALUE_CANNOT, grid is only by GRID_VALUE_CANNOT or by GRID_VALUE_GOOD 60 | public int CaculatePath(int _startX, int _startY, int _endX, int _endY, bool _ignoreObstacle, byte[,] _pathMap,GameObject GObj) 61 | { 62 | if (_pathMap[_startX, _startY] == GRID_VALUE_CANNOT || 63 | _pathMap[_endX, _endY] == GRID_VALUE_CANNOT) 64 | { 65 | Debug.LogError("start point or end point is invalid when path finding."); 66 | return -1; 67 | } 68 | 69 | PathObject _path = new PathObject(_startX, _startY, _endX, _endY, _pathMap); 70 | bool Suc = _path.FindWalkPath(_ignoreObstacle,GObj); 71 | 72 | if(!Suc) 73 | { 74 | return -1; 75 | } 76 | else 77 | { 78 | return AddPath(_path); 79 | } 80 | } 81 | 82 | public int AddPath(PathObject _path) 83 | { 84 | int id = GetUniquePathId(); 85 | mDicPathAll.Add(id,_path); 86 | return id; 87 | } 88 | 89 | public void RemovePath(int id) 90 | { 91 | if(mDicPathAll.ContainsKey(id)) 92 | mDicPathAll.Remove(id); 93 | } 94 | 95 | public int GetUniquePathId() 96 | { 97 | int ret = sUniquePathId; 98 | sUniquePathId ++; 99 | return ret; 100 | } 101 | 102 | public int CurUniquepathId 103 | { 104 | get{return sUniquePathId;} 105 | set{sUniquePathId = value;} 106 | } 107 | 108 | /*public PathObject LoadOnePathFromData(int size,int[] _pathData) 109 | { 110 | Point[]data = new Point[size]; 111 | for(int i=0;i path = mPathFinder.FindPath(mStart, mEnd, _ignoreObstacle); 63 | 64 | if (path == null) 65 | { 66 | mPathFinder = null; 67 | mPathCondition = PathCondition.eNoWay; 68 | return false; 69 | } 70 | else 71 | { 72 | Point mFirstPoint = new Point(0,0); 73 | int pathCount = path.Count; 74 | mPathData = new Point[pathCount]; 75 | mPathCondition = PathCondition.eGood; 76 | for(int i=0;i() != null)) 107 | // {PathLineManager.instance.ClearAll();return;} 108 | 109 | Vector3[] PathVec3 = new Vector3[pathCount]; 110 | for(int x=0;x mFinishTimeList; 10 | private long mStartTime; 11 | //private int mCycleTimes; 12 | #endregion 13 | 14 | public void Awake() 15 | { 16 | } 17 | 18 | #region Function 19 | public void Start() 20 | { 21 | mStartTime = Decimal.ToInt64(Decimal.Divide(DateTime.UtcNow.Ticks - 621355968000000000, 10000)); 22 | } 23 | 24 | public void Record(int times) 25 | { 26 | //mCycleTimes = times; 27 | } 28 | 29 | public long End() 30 | { 31 | if(mFinishTimeList == null) 32 | { 33 | mFinishTimeList = new List(); 34 | } 35 | long costTime = Decimal.ToInt64(Decimal.Divide(DateTime.UtcNow.Ticks - 621355968000000000, 10000)) - mStartTime; 36 | mFinishTimeList.Add(costTime); 37 | //Debug.Log("cost "+costTime.ToString()+" mil seconds"); 38 | return costTime; 39 | } 40 | 41 | #endregion 42 | } -------------------------------------------------------------------------------- /u3d/Assets/Core/pathFinder/PerformanceWatcher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 90ad734b8475d4493a26e0a5f962b2f6 3 | timeCreated: 1536472189 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/pathFinder/Point.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class Point 5 | { 6 | #region Varibles Declaration 7 | private int mPosX; 8 | private int mPosY; 9 | #endregion 10 | 11 | #region Properties 12 | public int X 13 | { 14 | get{return mPosX;} 15 | set{mPosX = value;} 16 | } 17 | 18 | public int Y 19 | { 20 | get{return mPosY;} 21 | set{mPosY = value;} 22 | } 23 | #endregion 24 | 25 | #region Functions 26 | public Point(int _x, int _y) 27 | { 28 | X = _x; 29 | Y = _y; 30 | } 31 | #endregion 32 | } -------------------------------------------------------------------------------- /u3d/Assets/Core/pathFinder/Point.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c288b180f06ca4bfeb7d4a7882d0da80 3 | timeCreated: 1536472189 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Core/pathFinder/PriorityQueueB.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Diagnostics; 5 | 6 | #region Interfaces 7 | public interface IPriorityQueue 8 | { 9 | #region Methods 10 | int Push(T item); 11 | T Pop(); 12 | T Peek(); 13 | void Update(int i); 14 | #endregion 15 | } 16 | #endregion 17 | 18 | 19 | public class PriorityQueueB : IPriorityQueue 20 | { 21 | #region Variables Declaration 22 | protected List InnerList = new List(); 23 | protected IComparer mComparer; 24 | #endregion 25 | 26 | #region Contructors 27 | public PriorityQueueB() 28 | { 29 | mComparer = Comparer.Default; 30 | } 31 | 32 | public PriorityQueueB(IComparer comparer) 33 | { 34 | mComparer = comparer; 35 | } 36 | 37 | public PriorityQueueB(IComparer comparer, int capacity) 38 | { 39 | mComparer = comparer; 40 | InnerList.Capacity = capacity; 41 | } 42 | #endregion 43 | 44 | #region Methods 45 | protected void SwitchElements(int i, int j) 46 | { 47 | T h = InnerList[i]; 48 | InnerList[i] = InnerList[j]; 49 | InnerList[j] = h; 50 | } 51 | 52 | protected virtual int OnCompare(int i, int j) 53 | { 54 | return mComparer.Compare(InnerList[i],InnerList[j]); 55 | } 56 | 57 | /// 58 | /// Push an object onto the PQ 59 | /// 60 | /// The new object 61 | /// The index in the list where the object is _now_. This will change when objects are taken from or put onto the PQ. 62 | public int Push(T item) 63 | { 64 | int p = InnerList.Count,p2; 65 | InnerList.Add(item); // E[p] = O 66 | // int index = p-1; 67 | do 68 | { 69 | if(p==0) 70 | break; 71 | p2 = (p-1)/2; 72 | if(OnCompare(p,p2)<0) 73 | { 74 | SwitchElements(p,p2); 75 | p = p2; 76 | } 77 | else 78 | break; 79 | }while(true); 80 | return p; 81 | } 82 | 83 | /// 84 | /// Get the smallest object and remove it. 85 | /// 86 | /// The smallest object 87 | public T Pop() 88 | { 89 | T result = InnerList[0]; 90 | // InnerList.RemoveAt(0); 91 | int p = 0,p1,p2,pn; 92 | InnerList[0] = InnerList[InnerList.Count-1]; 93 | InnerList.RemoveAt(InnerList.Count-1); 94 | do 95 | { 96 | pn = p; 97 | p1 = 2*p+1; 98 | p2 = 2*p+2; 99 | if(InnerList.Count>p1 && OnCompare(p,p1)>0) // links kleiner 100 | p = p1; 101 | if(InnerList.Count>p2 && OnCompare(p,p2)>0) // rechts noch kleiner 102 | p = p2; 103 | 104 | if(p==pn) 105 | break; 106 | SwitchElements(p,pn); 107 | }while(true); 108 | 109 | return result; 110 | } 111 | 112 | /// 113 | /// Notify the PQ that the object at position i has changed 114 | /// and the PQ needs to restore order. 115 | /// Since you dont have access to any indexes (except by using the 116 | /// explicit IList.this) you should not call this function without knowing exactly 117 | /// what you do. 118 | /// 119 | /// The index of the changed object. 120 | public void Update(int i) 121 | { 122 | int p = i,pn; 123 | int p1,p2; 124 | do // aufsteigen 125 | { 126 | if(p==0) 127 | break; 128 | p2 = (p-1)/2; 129 | if(OnCompare(p,p2)<0) 130 | { 131 | SwitchElements(p,p2); 132 | p = p2; 133 | } 134 | else 135 | break; 136 | }while(true); 137 | if(pp1 && OnCompare(p,p1)>0) // links kleiner 145 | p = p1; 146 | if(InnerList.Count>p2 && OnCompare(p,p2)>0) // rechts noch kleiner 147 | p = p2; 148 | 149 | if(p==pn) 150 | break; 151 | SwitchElements(p,pn); 152 | }while(true); 153 | } 154 | 155 | /// 156 | /// Get the smallest object without removing it. 157 | /// 158 | /// The smallest object 159 | public T Peek() 160 | { 161 | if(InnerList.Count>0) 162 | return InnerList[0]; 163 | return default(T); 164 | } 165 | 166 | public void Clear() 167 | { 168 | InnerList.Clear(); 169 | } 170 | 171 | public int Count 172 | { 173 | get{ return InnerList.Count; } 174 | } 175 | 176 | public void RemoveLocation(T item) 177 | { 178 | int index = -1; 179 | for(int i=0; i : IPriorityQueue 8 | { 9 | #region Variables Declaration 10 | protected List InnerList = new List(); 11 | protected IComparer mComparer; 12 | #endregion 13 | 14 | #region Contructors 15 | public PriorityQueueC() 16 | { 17 | mComparer = Comparer.Default; 18 | } 19 | 20 | public PriorityQueueC(IComparer comparer) 21 | { 22 | mComparer = comparer; 23 | } 24 | 25 | public PriorityQueueC(IComparer comparer, int capacity) 26 | { 27 | mComparer = comparer; 28 | InnerList.Capacity = capacity; 29 | } 30 | #endregion 31 | 32 | #region Methods 33 | protected void SwitchElements(int i, int j) 34 | { 35 | T h = InnerList[i]; 36 | InnerList[i] = InnerList[j]; 37 | InnerList[j] = h; 38 | } 39 | 40 | protected virtual int OnCompare(int i, int j) 41 | { 42 | return mComparer.Compare(InnerList[i],InnerList[j]); 43 | } 44 | 45 | /// 46 | /// Push an object onto the PQ 47 | /// 48 | /// The new object 49 | /// The index in the list where the object is _now_. This will change when objects are taken from or put onto the PQ. 50 | public int Push(T item) 51 | { 52 | int p = InnerList.Count,p2; 53 | InnerList.Add(item); // E[p] = O 54 | // int index = p-1; 55 | do 56 | { 57 | if(p==0) 58 | break; 59 | p2 = (p-1)/2; 60 | if(OnCompare(p,p2)<0) 61 | { 62 | SwitchElements(p,p2); 63 | p = p2; 64 | } 65 | else 66 | break; 67 | }while(true); 68 | return p; 69 | } 70 | 71 | /// 72 | /// Get the smallest object and remove it. 73 | /// 74 | /// The smallest object 75 | public T Pop() 76 | { 77 | T result = InnerList[0]; 78 | // InnerList.RemoveAt(0); 79 | int p = 0,p1,p2,pn; 80 | InnerList[0] = InnerList[InnerList.Count-1]; 81 | InnerList.RemoveAt(InnerList.Count-1); 82 | do 83 | { 84 | pn = p; 85 | p1 = 2*p+1; 86 | p2 = 2*p+2; 87 | if(InnerList.Count>p1 && OnCompare(p,p1)>0) // links kleiner 88 | p = p1; 89 | if(InnerList.Count>p2 && OnCompare(p,p2)>0) // rechts noch kleiner 90 | p = p2; 91 | 92 | if(p==pn) 93 | break; 94 | SwitchElements(p,pn); 95 | }while(true); 96 | 97 | return result; 98 | } 99 | 100 | /// 101 | /// Notify the PQ that the object at position i has changed 102 | /// and the PQ needs to restore order. 103 | /// Since you dont have access to any indexes (except by using the 104 | /// explicit IList.this) you should not call this function without knowing exactly 105 | /// what you do. 106 | /// 107 | /// The index of the changed object. 108 | public void Update(int i) 109 | { 110 | int p = i,pn; 111 | int p1,p2; 112 | do // aufsteigen 113 | { 114 | if(p==0) 115 | break; 116 | p2 = (p-1)/2; 117 | if(OnCompare(p,p2)<0) 118 | { 119 | SwitchElements(p,p2); 120 | p = p2; 121 | } 122 | else 123 | break; 124 | }while(true); 125 | if(pp1 && OnCompare(p,p1)>0) // links kleiner 133 | p = p1; 134 | if(InnerList.Count>p2 && OnCompare(p,p2)>0) // rechts noch kleiner 135 | p = p2; 136 | 137 | if(p==pn) 138 | break; 139 | SwitchElements(p,pn); 140 | }while(true); 141 | } 142 | 143 | /// 144 | /// Get the smallest object without removing it. 145 | /// 146 | /// The smallest object 147 | public T Peek() 148 | { 149 | if(InnerList.Count>0) 150 | return InnerList[0]; 151 | return default(T); 152 | } 153 | 154 | public void Clear() 155 | { 156 | InnerList.Clear(); 157 | } 158 | 159 | public int Count 160 | { 161 | get{ return InnerList.Count; } 162 | } 163 | 164 | public void RemoveLocation(T item) 165 | { 166 | int index = -1; 167 | for(int i=0; i(T a, T b, params object[] args); 8 | 9 | // base on sort sequence find a object by binary sort 10 | public static int Search(List A,T v, CompareFunction _compareFunction, params object[] args) 11 | { 12 | int x,y,m; 13 | x = 0; 14 | y = A.Count; 15 | while(x < y) 16 | { 17 | m = x+(y-x)/2; 18 | if(_compareFunction(A[m], v, args) == 0) return m; 19 | else if(_compareFunction(A[m], v, args) > 0) y = m; 20 | else x = m+1; 21 | } 22 | return -1; 23 | } 24 | 25 | // base on sort sequence find a object by binary sort 26 | // if v is the biggest one, will return the count of list 27 | public static int SearchInsert(List A,T v, CompareFunction _compareFunction, params object[] args) 28 | { 29 | int x,y,m; 30 | x = 0; 31 | y = A.Count; 32 | while(x < y) 33 | { 34 | m = x+(y-x)/2; 35 | if(_compareFunction(A[m], v, args) == 0) return m; 36 | else if(_compareFunction(A[m], v, args) > 0) y = m; 37 | else x = m+1; 38 | } 39 | return y; 40 | } 41 | 42 | // quick one, make it in 3 parts , left one is smaller , middle one is equal , right one is bigger. 43 | public static void Sort(List arr, int low, int high, CompareFunction _compareFunction, params object[] args) 44 | { 45 | if(low >= high) 46 | return; 47 | 48 | int first = low ; 49 | int last = high ; 50 | 51 | if (high - low + 1 <= 8) 52 | { 53 | InsertSort(arr, low, high, _compareFunction, args); 54 | return; 55 | } 56 | 57 | T key = arr[low]; 58 | 59 | while(first < last) 60 | { 61 | while(first < last && _compareFunction(key, arr[last], args) <= 0) 62 | last--; 63 | arr[first] = arr[last]; 64 | while(first < last && _compareFunction(key, arr[first], args) >= 0) 65 | first++; 66 | arr[last] = arr[first]; 67 | } 68 | 69 | arr[first] = key; 70 | 71 | Sort(arr, low, first-1, _compareFunction, args); 72 | Sort(arr, first+1, high, _compareFunction, args); 73 | } 74 | 75 | // //三数中值+聚集相等元素 76 | // public static void Sort(List arr, int low,int high, CompareFunction _compareFunction, params object[] args) 77 | // { 78 | // int first = low; 79 | // int last = high; 80 | 81 | // int left = low; 82 | // int right = high; 83 | 84 | // int leftLen = 0; 85 | // int rightLen = 0; 86 | 87 | // if (high - low + 1 < 3) 88 | // { 89 | // InsertSort(arr, low, high, _compareFunction, args); 90 | // return; 91 | // } 92 | 93 | // //一次分割 94 | // T key = SelectMedian(arr,low,high);//使用三数取中法选择枢轴 95 | 96 | // while(low < high) 97 | // { 98 | // int diff = _compareFunction(arr[high], key, args); 99 | // while(high > low && diff >= 0) 100 | // { 101 | // if (diff == 0)//处理相等元素 102 | // { 103 | // swap(arr, right, high); 104 | // right--; 105 | // rightLen++; 106 | // } 107 | // high--; 108 | // } 109 | // arr[low] = arr[high]; 110 | // diff = _compareFunction(arr[low] , key, args); 111 | // while(high > low && diff <= 0) 112 | // { 113 | // if (diff == 0) 114 | // { 115 | // swap(arr, left, low); 116 | // left++; 117 | // leftLen++; 118 | // } 119 | // low++; 120 | // } 121 | // arr[high] = arr[low]; 122 | // } 123 | // arr[low] = key; 124 | 125 | // //一次快排结束 126 | // //把与枢轴key相同的元素移到枢轴最终位置周围 127 | // int i = low - 1; 128 | // int j = first; 129 | // // diff = _compareFunction(arr[i] , key, args) 130 | // while(j < left && _compareFunction(arr[i] , key, args) != 0) 131 | // { 132 | // swap(arr, i, j); 133 | // i--; 134 | // j++; 135 | // } 136 | // i = low + 1; 137 | // j = last; 138 | // while(j > right && _compareFunction(arr[i] , key, args) != 0) 139 | // { 140 | // swap(arr, i, j); 141 | // i++; 142 | // j--; 143 | // } 144 | // Sort(arr, first, low - 1 - leftLen); 145 | // Sort(arr, low + 1 + rightLen,last); 146 | // } 147 | 148 | static void InsertSort(List arr, int low,int high, CompareFunction _compareFunction, params object[] args) 149 | { 150 | for (int i = low + 1; i <= high; i++) 151 | { 152 | int j = i; 153 | T target = arr[i]; 154 | 155 | while (j > low && _compareFunction(target, arr[j-1]) < 0) 156 | { 157 | arr[j] = arr[j - 1]; 158 | j--; 159 | } 160 | 161 | arr[i] = target; 162 | } 163 | } 164 | 165 | // static void swap(List arr, int index1, int index2) 166 | // { 167 | // T tmp = arr[index1]; 168 | // arr[index1] = arr[index2]; 169 | // arr[index2] = tmp; 170 | // } 171 | 172 | // static T SelectMedian(List a, int left, int right, CompareFunction _compareFunction, params object[] args) 173 | // { 174 | // int midIndex = (left + right)>>1; 175 | 176 | // int diff = _compareFunction(a[left], a[midIndex], args); 177 | // if (diff > 0) 178 | // { 179 | // swap(a, left, midIndex); 180 | // } 181 | 182 | // diff = _compareFunction(a[left], a[right], args); 183 | // if (diff > 0) 184 | // { 185 | // swap(a, left, right); 186 | // } 187 | 188 | // diff = _compareFunction(a[midIndex], a[right], args); 189 | // if (diff > 0) 190 | // { 191 | // swap(a, midIndex, right); 192 | // } 193 | 194 | // swap(a, midIndex, right); 195 | 196 | // return a[right-1]; //返回中轴 197 | // } 198 | 199 | ////// test ////////////////////////// 200 | 201 | public static void test_find() 202 | { 203 | List arr = new List(10); 204 | arr.Add(2); 205 | arr.Add(9); 206 | arr.Add(4); 207 | arr.Add(5); 208 | arr.Add(3); 209 | arr.Add(2); 210 | arr.Add(8); 211 | arr.Add(1); 212 | arr.Add(7); 213 | 214 | CQuickSort.Sort(arr,0,arr.Count-1,test_compare_function); 215 | 216 | string out1 = ""; 217 | for(int i = 0 ; i(arr, 9, test_compare_function); 225 | 226 | //Debug.LogError("_index " + _index); 227 | } 228 | 229 | public static void test_search_insert() 230 | { 231 | List arr = new List(10); 232 | arr.Add(1); 233 | arr.Add(2); 234 | arr.Add(5); 235 | arr.Add(6); 236 | arr.Add(7); 237 | arr.Add(8); 238 | arr.Add(9); 239 | 240 | string out1 = ""; 241 | for(int i = 0 ; i(arr, search_insert_num, test_compare_function); 252 | //Debug.LogError("_index " + _index); 253 | 254 | search_insert_num = 3; 255 | //Debug.LogError("SearchInsert " + search_insert_num); 256 | _index = CQuickSort.SearchInsert(arr, search_insert_num, test_compare_function); 257 | //Debug.LogError("_index " + _index); 258 | 259 | search_insert_num = 10; 260 | //Debug.LogError("SearchInsert " + search_insert_num); 261 | _index = CQuickSort.SearchInsert(arr, search_insert_num, test_compare_function); 262 | //Debug.LogError("_index " + _index); 263 | 264 | search_insert_num = 9; 265 | //Debug.LogError("SearchInsert " + search_insert_num); 266 | _index = CQuickSort.SearchInsert(arr, search_insert_num, test_compare_function); 267 | //Debug.LogError("_index " + _index); 268 | 269 | search_insert_num = 7; 270 | //Debug.LogError("SearchInsert " + search_insert_num); 271 | _index = CQuickSort.SearchInsert(arr, search_insert_num, test_compare_function); 272 | //Debug.LogError("_index " + _index); 273 | } 274 | 275 | public static void test_sort() 276 | { 277 | List arr = new List(10); 278 | arr.Add(2); 279 | arr.Add(9); 280 | arr.Add(4); 281 | arr.Add(5); 282 | arr.Add(3); 283 | arr.Add(2); 284 | arr.Add(8); 285 | arr.Add(1); 286 | arr.Add(7); 287 | 288 | // List arr = new List(10); 289 | // arr.Add(2); 290 | // arr.Add(1); 291 | 292 | // List arr = new List(10); 293 | // arr.Add(2); 294 | // arr.Add(1); 295 | // arr.Add(4); 296 | 297 | // List arr = new List(10); 298 | // arr.Add(1); 299 | // arr.Add(2); 300 | // arr.Add(3); 301 | // arr.Add(4); 302 | // arr.Add(5); 303 | // arr.Add(6); 304 | // arr.Add(7); 305 | // arr.Add(8); 306 | 307 | // List arr = new List(10); 308 | // arr.Add(2); 309 | // arr.Add(2); 310 | // arr.Add(2); 311 | // arr.Add(2); 312 | // arr.Add(2); 313 | // arr.Add(2); 314 | // arr.Add(2); 315 | // arr.Add(2); 316 | 317 | string out1 = ""; 318 | 319 | out1 = ""; 320 | for(int i = 0 ; i(arr,0,arr.Count-1,test_compare_function); 327 | 328 | out1 = ""; 329 | for(int i = 0 ; i : DictionarySort 9 | { 10 | //compare function 11 | protected override int CompareFunction(int _a, int _b, params object[] args) 12 | { 13 | return _a - _b; 14 | } 15 | 16 | public static void test() 17 | { 18 | DictionaryInt dic_str = new DictionaryInt(); 19 | dic_str.Add(1,"ok1"); 20 | dic_str.Add(10,"ok10"); 21 | dic_str.Add(100,"ok100"); 22 | 23 | string v = dic_str[1]; 24 | Debug.LogError("v " + v); 25 | 26 | v = dic_str[10]; 27 | Debug.LogError("v " + v); 28 | 29 | v = dic_str[100]; 30 | Debug.LogError("v " + v); 31 | 32 | bool isexist = dic_str.ContainsKey(1); 33 | Debug.LogError("isexist " + isexist); 34 | 35 | isexist = dic_str.ContainsKey(2); 36 | Debug.LogError("isexist " + isexist); 37 | 38 | isexist = dic_str.ContainsKey(100); 39 | Debug.LogError("isexist " + isexist); 40 | 41 | bool is_remove = dic_str.Remove(10); 42 | Debug.LogError("is remove " + is_remove); 43 | 44 | isexist = dic_str.ContainsKey(10); 45 | Debug.LogError("isexist " + isexist); 46 | 47 | dic_str[99] = "ok99"; 48 | Debug.LogError(dic_str[99]); 49 | } 50 | 51 | // private List mListKey; 52 | // private List mListValue; 53 | 54 | // public DictionaryInt() 55 | // { 56 | // mListKey = new List(); 57 | // mListValue = new List(); 58 | // } 59 | 60 | // public DictionaryInt(int size) 61 | // { 62 | // mListKey = new List(size); 63 | // mListValue = new List(size); 64 | // } 65 | 66 | // //whether contain the key 67 | // public bool ContainsKey(int _key) 68 | // { 69 | // int index = CQuickSort.Search(mListKey, _key, CompareInt); 70 | // if(index >= 0) return true; 71 | // return false; 72 | // } 73 | 74 | // //try get value by key 75 | // public bool TryGet(int _key, out T _value) 76 | // { 77 | // int index = CQuickSort.Search(mListKey, _key, CompareInt); 78 | // if(index >= 0) 79 | // { 80 | // _value = mListValue[index]; 81 | // return true; 82 | // } 83 | // _value = default(T); 84 | // return false; 85 | // } 86 | 87 | // public T this[int index] 88 | // { 89 | // get 90 | // { 91 | // T obj; 92 | // if(TryGet(index, out obj)) 93 | // { 94 | // return obj; 95 | // } 96 | 97 | // return default(T); 98 | // } 99 | // set 100 | // { 101 | // Add(index,value); 102 | // } 103 | // } 104 | 105 | // //add by key and value 106 | // public bool Add(int _key, T _value) 107 | // { 108 | // int index = CQuickSort.Search(mListKey, _key, CompareInt); 109 | // if(index >= 0) 110 | // { 111 | // throw new Exception("already have key " +_key); 112 | // return false; 113 | // } 114 | 115 | // index = CQuickSort.SearchInsert(mListKey, _key, CompareInt); 116 | // if(index >= mListKey.Count) 117 | // { 118 | // mListKey.Insert(index, _key); 119 | // mListValue.Insert(index, _value); 120 | // } 121 | // else 122 | // { 123 | // mListKey.Add(_key); 124 | // mListValue.Add(_value); 125 | // } 126 | 127 | // return true; 128 | // } 129 | 130 | // //remove by key 131 | // public bool Remove(int _key) 132 | // { 133 | // int index = CQuickSort.Search(mListKey, _key, CompareInt); 134 | // if(index < 0) 135 | // { 136 | // throw new Exception("no key to remove, key:" + _key); 137 | // return false; 138 | // } 139 | 140 | // mListKey.RemoveAt(index); 141 | // mListValue.RemoveAt(index); 142 | 143 | // return true; 144 | // } 145 | 146 | // //compare function 147 | // private int CompareInt(int _a, int _b) 148 | // { 149 | // return _a - _b; 150 | // } 151 | 152 | } 153 | 154 | -------------------------------------------------------------------------------- /u3d/Assets/Core/sort/DictionaryInt.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fab9a9616352597499de93000ba6e1ef 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /u3d/Assets/Core/sort/DictionarySort.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using System; 5 | 6 | 7 | //dictionary for binary sort, faster then dictionary in big data. 8 | public class DictionarySort 9 | { 10 | private List mListKey; 11 | private List mListValue; 12 | 13 | public DictionarySort() 14 | { 15 | mListKey = new List(); 16 | mListValue = new List(); 17 | } 18 | 19 | public DictionarySort(int size) 20 | { 21 | mListKey = new List(size); 22 | mListValue = new List(size); 23 | } 24 | 25 | //whether contain the key 26 | public bool ContainsKey(K _key) 27 | { 28 | int index = CQuickSort.Search(mListKey, _key, CompareFunction); 29 | if(index >= 0) return true; 30 | return false; 31 | } 32 | 33 | //try get value by key 34 | public bool TryGet(K _key, out T _value) 35 | { 36 | int index = CQuickSort.Search(mListKey, _key, CompareFunction); 37 | if(index >= 0) 38 | { 39 | _value = mListValue[index]; 40 | return true; 41 | } 42 | _value = default(T); 43 | return false; 44 | } 45 | 46 | public T this[K _key] 47 | { 48 | get 49 | { 50 | T obj; 51 | if(TryGet(_key, out obj)) 52 | { 53 | return obj; 54 | } 55 | 56 | return default(T); 57 | } 58 | set 59 | { 60 | int index = CQuickSort.Search(mListKey, _key, CompareFunction); 61 | if(index < 0) 62 | { 63 | Add(_key,value); 64 | throw new Exception("Key not exist, key " +_key); 65 | } 66 | else 67 | { 68 | mListValue[index] = value; 69 | } 70 | } 71 | } 72 | 73 | //add by key and value 74 | public bool Add(K _key, T _value) 75 | { 76 | int index = CQuickSort.Search(mListKey, _key, CompareFunction); 77 | if(index >= 0) 78 | { 79 | throw new Exception("already have key " +_key); 80 | return false; 81 | } 82 | 83 | index = CQuickSort.SearchInsert(mListKey, _key, CompareFunction); 84 | if(index >= mListKey.Count) 85 | { 86 | mListKey.Add(_key); 87 | mListValue.Add(_value); 88 | } 89 | else 90 | { 91 | mListKey.Insert(index, _key); 92 | mListValue.Insert(index, _value); 93 | } 94 | 95 | return true; 96 | } 97 | 98 | //remove by key 99 | public bool Remove(K _key) 100 | { 101 | int index = CQuickSort.Search(mListKey, _key, CompareFunction); 102 | if(index < 0) 103 | { 104 | throw new Exception("no key to remove, key:" + _key); 105 | return false; 106 | } 107 | 108 | mListKey.RemoveAt(index); 109 | mListValue.RemoveAt(index); 110 | 111 | return true; 112 | } 113 | 114 | //compare function 115 | protected virtual int CompareFunction(K _a, K _b, params object[] args) 116 | { 117 | return 0; 118 | } 119 | 120 | } 121 | 122 | -------------------------------------------------------------------------------- /u3d/Assets/Core/sort/DictionarySort.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5557cb724798be04f8e51edcccdaed9b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /u3d/Assets/Core/sort/DictionaryStr.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using System; 5 | 6 | //dictionary for string key, faster then dictionary in big data. 7 | public class DictionaryStr : DictionarySort 8 | { 9 | //compare function 10 | protected override int CompareFunction(string _a, string _b, params object[] args) 11 | { 12 | return _a.CompareTo(_b); 13 | } 14 | 15 | public static void test() 16 | { 17 | DictionaryStr dic_str = new DictionaryStr(); 18 | dic_str.Add("1","ok1"); 19 | dic_str.Add("10","ok10"); 20 | dic_str.Add("100","ok100"); 21 | 22 | string v = dic_str["1"]; 23 | Debug.LogError("v " + v); 24 | 25 | v = dic_str["10"]; 26 | Debug.LogError("v " + v); 27 | 28 | v = dic_str["100"]; 29 | Debug.LogError("v " + v); 30 | 31 | bool isexist = dic_str.ContainsKey("1"); 32 | Debug.LogError("isexist " + isexist); 33 | 34 | isexist = dic_str.ContainsKey("2"); 35 | Debug.LogError("isexist " + isexist); 36 | 37 | isexist = dic_str.ContainsKey("100"); 38 | Debug.LogError("isexist " + isexist); 39 | 40 | bool is_remove = dic_str.Remove("10"); 41 | Debug.LogError("is remove " + is_remove); 42 | 43 | isexist = dic_str.ContainsKey("10"); 44 | Debug.LogError("isexist " + isexist); 45 | 46 | dic_str["99"] = "ok99"; 47 | Debug.LogError(dic_str["99"]); 48 | } 49 | 50 | // private List mListKey; 51 | // private List mListValue; 52 | 53 | // public DictionaryStr() 54 | // { 55 | // mListKey = new List(); 56 | // mListValue = new List(); 57 | // } 58 | 59 | // public DictionaryStr(int size) 60 | // { 61 | // mListKey = new List(size); 62 | // mListValue = new List(size); 63 | // } 64 | 65 | // //whether contain the key 66 | // public bool ContainsKey(string _key) 67 | // { 68 | // int index = CQuickSort.Search(mListKey, _key, CompareInt); 69 | // if(index >= 0) return true; 70 | // return false; 71 | // } 72 | 73 | // //try get value by key 74 | // public bool TryGet(string _key, out T _value) 75 | // { 76 | // int index = CQuickSort.Search(mListKey, _key, CompareInt); 77 | // if(index >= 0) 78 | // { 79 | // _value = mListValue[index]; 80 | // return true; 81 | // } 82 | 83 | // _value = default(T); 84 | // return false; 85 | // } 86 | 87 | // public T this[string index] 88 | // { 89 | // get 90 | // { 91 | // T obj; 92 | // if(TryGet(index, out obj)) 93 | // { 94 | // return obj; 95 | // } 96 | 97 | // return default(T); 98 | // } 99 | // set 100 | // { 101 | // Add(index, value); 102 | // } 103 | // } 104 | 105 | // //add by key and value 106 | // public bool Add(string _key, T _value) 107 | // { 108 | // int index = CQuickSort.Search(mListKey, _key, CompareInt); 109 | // if(index >= 0) 110 | // { 111 | // throw new Exception("already have key " +_key); 112 | // return false; 113 | // } 114 | 115 | // index = CQuickSort.SearchInsert(mListKey, _key, CompareInt); 116 | // if(index >= mListKey.Count) 117 | // { 118 | // mListKey.Insert(index, _key); 119 | // mListValue.Insert(index, _value); 120 | // } 121 | // else 122 | // { 123 | // mListKey.Add(_key); 124 | // mListValue.Add(_value); 125 | // } 126 | 127 | // return true; 128 | // } 129 | 130 | // //remove by key 131 | // public bool Remove(string _key) 132 | // { 133 | // int index = CQuickSort.Search(mListKey, _key, CompareInt); 134 | // if(index < 0) 135 | // { 136 | // throw new Exception("no key to remove, key:" + _key); 137 | // return false; 138 | // } 139 | 140 | // mListKey.RemoveAt(index); 141 | // mListValue.RemoveAt(index); 142 | 143 | // return true; 144 | // } 145 | 146 | 147 | 148 | // //compare function 149 | // private int CompareInt(string _a, string _b) 150 | // { 151 | // return _a.CompareTo(_b); 152 | // } 153 | 154 | } 155 | 156 | -------------------------------------------------------------------------------- /u3d/Assets/Core/sort/DictionaryStr.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e91e72185b5ec84c87fcca0b34fd351 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /u3d/Assets/Core/sort/Heap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class Heap where T : IComparable 5 | { 6 | public enum HeapType 7 | { 8 | Max, 9 | Min 10 | } 11 | 12 | internal delegate bool IndexComparor(int childIx, int parentIx); 13 | internal IndexComparor IsHigherPriorityThanParent; 14 | 15 | #region Constructors 16 | 17 | /// 18 | /// Constructs a new max heap. 19 | /// 20 | public Heap() : this(HeapType.Min) {} 21 | 22 | /// 23 | /// Constructs a new heap with the given type, allowing you to specify if this heap will be a min or a max heap. 24 | /// 25 | /// 26 | public Heap(HeapType type) 27 | { 28 | this.List = new List(); 29 | this.Init(type); 30 | } 31 | 32 | /// 33 | /// Constructs a new heap with the given type and initial capacity. 34 | /// 35 | /// The type of heap that determines if it will be a min or max heap. 36 | /// The initial capacity of the heap. 37 | public Heap(HeapType type, int capacity) 38 | { 39 | this.List = new List(capacity); 40 | this.Init(type); 41 | } 42 | 43 | /// 44 | /// Initializes some properties of the tree 45 | /// 46 | /// 47 | private void Init(HeapType type) 48 | { 49 | this.Type = type; 50 | 51 | if (type == HeapType.Max) 52 | this.IsHigherPriorityThanParent = this.IsLargerThan; 53 | else 54 | this.IsHigherPriorityThanParent = this.IsSmallerThanParent; 55 | } 56 | 57 | #endregion 58 | 59 | #region Properties 60 | 61 | /// 62 | /// Identifies the heap as either being a max heap or a min heap 63 | /// 64 | public HeapType Type { get; internal set; } 65 | 66 | internal List List { get; set; } 67 | 68 | /// 69 | /// Returns the number of items in the heap 70 | /// 71 | public int Count { get { return this.List.Count; } } 72 | 73 | #endregion 74 | 75 | #region Indexers 76 | 77 | /// 78 | /// Given an index of a node, this method returns the index of that node's parent 79 | /// 80 | internal static int ParentIndexOf(int ix) 81 | { 82 | if (ix == 0) 83 | throw new Exception("Resources.Errors.ParentOfRootDoesntExist"); 84 | else 85 | { 86 | return (int)Math.Floor((double)(ix - 1) / 2); 87 | } 88 | } 89 | 90 | /// 91 | /// Given an index of a node, this method returns the index of that node's left child 92 | /// 93 | internal static int LeftChildIndexOf(int ix) 94 | { 95 | return (2 * ix) + 1; 96 | } 97 | 98 | /// 99 | /// Given an index of a node, this method returns the index of that node's right child 100 | /// 101 | internal static int RightChildIndexOf(int ix) 102 | { 103 | return (2 * ix) + 2; 104 | } 105 | 106 | #endregion 107 | 108 | #region Heap Compare Functions 109 | 110 | /// 111 | /// Returns true if the value of the node at the first index is larger than the value of the node at the second index. 112 | /// 113 | /// The index of the first value 114 | /// The index of the second value 115 | internal bool IsLargerThan(int first, int second) 116 | { 117 | return this.List[first].CompareTo(this.List[second]) > 0; 118 | } 119 | 120 | /// 121 | /// Returns true if the value of the node at the first index is smaller than the value of the node at the second index. 122 | /// 123 | /// The index of the first value 124 | /// The index of the second value 125 | internal bool IsSmallerThanParent(int first, int second) 126 | { 127 | return this.List[first].CompareTo(this.List[second]) < 0; 128 | } 129 | 130 | #endregion 131 | 132 | #region Swap 133 | 134 | /// 135 | /// Swaps the value at index ix1 with the value at index ix2 136 | /// 137 | internal void Swap(int ix1, int ix2) 138 | { 139 | T temp = this.List[ix1]; 140 | this.List[ix1] = this.List[ix2]; 141 | this.List[ix2] = temp; 142 | } 143 | 144 | #endregion 145 | 146 | #region Insert 147 | 148 | /// 149 | /// Inserts the given value into the heap, maintaining the heap property as defined by Heap.HeapType 150 | /// 151 | public void Insert(T value) 152 | { 153 | int insertedAtIndex = this.List.Count; 154 | this.List.Add(value); 155 | this.HeapifyUp(insertedAtIndex); 156 | } 157 | 158 | /// 159 | /// Helper function that takes the node inserted at insertedIx and makes sure it is bubbled up to the correct place in the heap. 160 | /// 161 | internal void HeapifyUp(int insertedIx) 162 | { 163 | int currentIx = insertedIx; 164 | 165 | while (currentIx > 0) 166 | { 167 | int parentIx = ParentIndexOf(currentIx); 168 | if (this.IsHigherPriorityThanParent(currentIx, parentIx)) 169 | this.Swap(currentIx, parentIx); 170 | else 171 | break; 172 | 173 | currentIx = parentIx; 174 | } 175 | } 176 | 177 | #endregion 178 | 179 | #region Remove 180 | 181 | /// 182 | /// Removes the node at the top of the heap and returns its value. 183 | /// 184 | /// The largest node in the heap if the HeapType = Max, the smallest node in the heap if the HeapType = Min 185 | public T Remove() 186 | { 187 | int lastIx = this.List.Count - 1; 188 | T result = default(T); 189 | if (lastIx < 0) 190 | throw new Exception("Resources.Errors.CannotRemoveFromEmptyHeap"); 191 | else 192 | { 193 | result = this.List[0]; 194 | 195 | if (lastIx > 0) 196 | this.List[0] = this.List[lastIx]; 197 | 198 | this.List.RemoveAt(lastIx); 199 | this.HeapifyDown(); 200 | } 201 | 202 | return result; 203 | } 204 | 205 | /// 206 | /// Starting at the top of the heap, examines all nodes underneath it ensuring that the heap property is maintained at all nodes. 207 | /// 208 | internal void HeapifyDown() 209 | { 210 | int parentIx = 0; 211 | while (parentIx < this.Count) 212 | { 213 | int leftIx = LeftChildIndexOf(parentIx); 214 | int rightIx = RightChildIndexOf(parentIx); 215 | int largest = parentIx; 216 | 217 | if (leftIx < this.Count && this.IsHigherPriorityThanParent(leftIx, largest)) 218 | largest = leftIx; 219 | 220 | if (rightIx < this.Count && this.IsHigherPriorityThanParent(rightIx, largest)) 221 | largest = rightIx; 222 | 223 | if (largest != parentIx) 224 | { 225 | this.Swap(largest, parentIx); 226 | parentIx = largest; 227 | } 228 | else 229 | break; 230 | } 231 | } 232 | 233 | #endregion 234 | 235 | #region Peek 236 | 237 | /// 238 | /// Returns the value of the node at the top of the heap without removing it. 239 | /// 240 | public T Peek() 241 | { 242 | if (this.List.Count > 0) 243 | return this.List[0]; 244 | else 245 | throw new Exception("Resources.Errors.PeekEmptyTree"); 246 | } 247 | 248 | #endregion 249 | 250 | 251 | #region test 252 | ////// test ////////////////////////// 253 | 254 | class Testobj : IComparable 255 | { 256 | public int v; 257 | 258 | public Testobj(int _v) 259 | { 260 | v = _v; 261 | } 262 | 263 | public int CompareTo(Testobj b) 264 | { 265 | return this.v - b.v; 266 | } 267 | } 268 | 269 | public static void test_push() 270 | { 271 | 272 | Heap test_heap = new Heap(); 273 | test_heap.Insert(new Testobj(9)); 274 | test_heap.Insert(new Testobj(2)); 275 | test_heap.Insert(new Testobj(6)); 276 | test_heap.Insert(new Testobj(7)); 277 | test_heap.Insert(new Testobj(3)); 278 | test_heap.Insert(new Testobj(4)); 279 | 280 | Testobj t1 = test_heap.Remove(); 281 | Debug.LogError("" + t1.v); 282 | 283 | t1 = test_heap.Remove(); 284 | Debug.LogError("" + t1.v); 285 | 286 | t1 = test_heap.Remove(); 287 | Debug.LogError("" + t1.v); 288 | 289 | t1 = test_heap.Remove(); 290 | Debug.LogError("" + t1.v); 291 | 292 | t1 = test_heap.Remove(); 293 | Debug.LogError("" + t1.v); 294 | 295 | } 296 | 297 | #endregion 298 | } -------------------------------------------------------------------------------- /u3d/Assets/Core/sort/Heap.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 179ab8d67f28a42608a3ca2948f2f44d 3 | timeCreated: 1536472189 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Example.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ede04c013a6f94803832833b32507a8c 3 | folderAsset: yes 4 | timeCreated: 1536472091 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /u3d/Assets/Example/3D-InputControlAndCameraControl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 65cbcd77e8b33c84da0ecdc90d661e77 3 | folderAsset: yes 4 | timeCreated: 1536636304 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /u3d/Assets/Example/3D-InputControlAndCameraControl/example.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/Assets/Example/3D-InputControlAndCameraControl/example.unity -------------------------------------------------------------------------------- /u3d/Assets/Example/3D-InputControlAndCameraControl/example.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 85e0b3443da3c42469d6d14dfaa6b82f 3 | timeCreated: 1536636326 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /u3d/Assets/Example/SoundEffect.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef796b49ddba84b0e868c4fb8e221fd5 3 | folderAsset: yes 4 | timeCreated: 1536472112 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /u3d/Assets/Example/SoundEffect/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf0b53f0fc6634b1aa2e34cb5bdb398e 3 | folderAsset: yes 4 | timeCreated: 1536472276 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /u3d/Assets/Example/SoundEffect/Resources/sound.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8dea13185f7a454190f1d786d656ca8 3 | folderAsset: yes 4 | timeCreated: 1536472281 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /u3d/Assets/Example/SoundEffect/Resources/sound/Acquire_Quest.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/Assets/Example/SoundEffect/Resources/sound/Acquire_Quest.mp3 -------------------------------------------------------------------------------- /u3d/Assets/Example/SoundEffect/Resources/sound/Acquire_Quest.mp3.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d745e721b24854ef5854535c975d2d76 3 | timeCreated: 1536472616 4 | licenseType: Free 5 | AudioImporter: 6 | serializedVersion: 6 7 | defaultSettings: 8 | loadType: 0 9 | sampleRateSetting: 0 10 | sampleRateOverride: 44100 11 | compressionFormat: 1 12 | quality: 1 13 | conversionMode: 0 14 | platformSettingOverrides: {} 15 | forceToMono: 0 16 | normalize: 1 17 | preloadAudioData: 0 18 | loadInBackground: 0 19 | 3D: 1 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /u3d/Assets/Example/SoundEffect/Resources/sound/Master Menu Theme.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/Assets/Example/SoundEffect/Resources/sound/Master Menu Theme.mp3 -------------------------------------------------------------------------------- /u3d/Assets/Example/SoundEffect/Resources/sound/Master Menu Theme.mp3.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3cc17a4647c9a4120b8174eb4446ce42 3 | timeCreated: 1536472610 4 | licenseType: Free 5 | AudioImporter: 6 | serializedVersion: 6 7 | defaultSettings: 8 | loadType: 0 9 | sampleRateSetting: 0 10 | sampleRateOverride: 44100 11 | compressionFormat: 1 12 | quality: 1 13 | conversionMode: 0 14 | platformSettingOverrides: {} 15 | forceToMono: 0 16 | normalize: 1 17 | preloadAudioData: 0 18 | loadInBackground: 0 19 | 3D: 1 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /u3d/Assets/Example/SoundEffect/SoundTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class SoundTest : MonoBehaviour 6 | { 7 | public SoundEffect soundEffect; 8 | 9 | // Use this for initialization 10 | void Start () 11 | { 12 | } 13 | 14 | // Update is called once per frame 15 | void Update () 16 | { 17 | // 18 | } 19 | 20 | void OnGUI() 21 | { 22 | GUI.Label(new Rect(200, 10, 150, 40), "bgm vol " + soundEffect.BgmVol); 23 | 24 | if(GUI.Button(new Rect(10, 10, 150, 100), "play sfx")) 25 | { 26 | soundEffect.PlaySfx("Acquire_Quest"); 27 | } 28 | 29 | if (GUI.Button(new Rect(10, 110, 150, 100), "play bgm")) 30 | { 31 | soundEffect.PlayBgm("Master Menu Theme"); 32 | } 33 | 34 | if (GUI.Button(new Rect(10, 210, 150, 100), "play bgm next")) 35 | { 36 | Debug.LogError("bgm next"); 37 | soundEffect.PlayBgmFadeOutIn("Master Menu Theme"); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /u3d/Assets/Example/SoundEffect/SoundTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6729f3c7b1724b339358126e8c6e93b 3 | timeCreated: 1536472381 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /u3d/Assets/Example/SoundEffect/sound.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/Assets/Example/SoundEffect/sound.unity -------------------------------------------------------------------------------- /u3d/Assets/Example/SoundEffect/sound.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 36416021a4e7b4ee6a36bf30abe28152 3 | timeCreated: 1536472079 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /u3d/Assets/Example/sort.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92d3ebcdbb606f748bd6e3ba1a13324d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /u3d/Assets/Example/sort/example-sort.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/Assets/Example/sort/example-sort.unity -------------------------------------------------------------------------------- /u3d/Assets/Example/sort/example-sort.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f707011fb8727741970bd87fa032e3a 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /u3d/Assets/Example/sort/example_srot.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class example_srot : MonoBehaviour 6 | { 7 | // Use this for initialization 8 | void Start () 9 | { 10 | // CQuickSort.test_sort(); 11 | // CQuickSort.test_find(); 12 | // CQuickSort.test_search_insert(); 13 | 14 | // DictionaryInt.test(); 15 | DictionaryStr.test(); 16 | } 17 | 18 | // Update is called once per frame 19 | void Update () { 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /u3d/Assets/Example/sort/example_srot.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5eb5bc7d81091145a79761c35ec233b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /u3d/Assets/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f1ade128ffe9664ab4ed6fcdf8934b5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /u3d/Assets/Plugins/Android.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c9451cc19f245ff45863e4992e1bf0d6 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /u3d/Assets/Plugins/Android/libs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f5f3d94bec07d4145b28e2bc4dac3298 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /u3d/Assets/Plugins/Android/libs/DeviceIDLib.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/Assets/Plugins/Android/libs/DeviceIDLib.jar -------------------------------------------------------------------------------- /u3d/Assets/Plugins/Android/libs/DeviceIDLib.jar.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7e99ad8dac85be9478bcb5bb71d85e54 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | isPreloaded: 0 9 | isOverridable: 0 10 | platformData: 11 | - first: 12 | Android: Android 13 | second: 14 | enabled: 1 15 | settings: {} 16 | - first: 17 | Any: 18 | second: 19 | enabled: 0 20 | settings: {} 21 | - first: 22 | Editor: Editor 23 | second: 24 | enabled: 0 25 | settings: 26 | DefaultValueInitialized: true 27 | userData: 28 | assetBundleName: 29 | assetBundleVariant: 30 | -------------------------------------------------------------------------------- /u3d/Assets/Plugins/Android/libs/PushLib.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/Assets/Plugins/Android/libs/PushLib.jar -------------------------------------------------------------------------------- /u3d/Assets/Plugins/Android/libs/PushLib.jar.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c95bdbc7b69b64471ad5ff91ee0da1f6 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | platformData: 13 | - first: 14 | Android: Android 15 | second: 16 | enabled: 1 17 | settings: {} 18 | - first: 19 | Any: 20 | second: 21 | enabled: 0 22 | settings: {} 23 | - first: 24 | Editor: Editor 25 | second: 26 | enabled: 0 27 | settings: 28 | DefaultValueInitialized: true 29 | userData: 30 | assetBundleName: 31 | assetBundleVariant: 32 | -------------------------------------------------------------------------------- /u3d/Assets/Plugins/Android/libs/glb.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/Assets/Plugins/Android/libs/glb.zip -------------------------------------------------------------------------------- /u3d/Assets/Plugins/Android/libs/glb.zip.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4632a8e157e51b840b3e5a4c56d929a2 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /u3d/Assets/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4488f8a88eb024f1c89ac55d51474a99 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /u3d/Assets/Scripts/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/Assets/Scripts/.gitkeep -------------------------------------------------------------------------------- /u3d/Logs/Packages-Update.log: -------------------------------------------------------------------------------- 1 | 2 | === Tue Apr 9 10:38:49 2019 3 | 4 | Packages were changed. 5 | Update Mode: updateDependencies 6 | 7 | The following packages were added: 8 | com.unity.analytics@3.2.2 9 | com.unity.purchasing@2.0.3 10 | com.unity.ads@2.0.8 11 | com.unity.textmeshpro@1.3.0 12 | com.unity.package-manager-ui@2.0.3 13 | com.unity.collab-proxy@1.2.15 14 | com.unity.modules.ai@1.0.0 15 | com.unity.modules.animation@1.0.0 16 | com.unity.modules.assetbundle@1.0.0 17 | com.unity.modules.audio@1.0.0 18 | com.unity.modules.cloth@1.0.0 19 | com.unity.modules.director@1.0.0 20 | com.unity.modules.imageconversion@1.0.0 21 | com.unity.modules.imgui@1.0.0 22 | com.unity.modules.jsonserialize@1.0.0 23 | com.unity.modules.particlesystem@1.0.0 24 | com.unity.modules.physics@1.0.0 25 | com.unity.modules.physics2d@1.0.0 26 | com.unity.modules.screencapture@1.0.0 27 | com.unity.modules.terrain@1.0.0 28 | com.unity.modules.terrainphysics@1.0.0 29 | com.unity.modules.tilemap@1.0.0 30 | com.unity.modules.ui@1.0.0 31 | com.unity.modules.uielements@1.0.0 32 | com.unity.modules.umbra@1.0.0 33 | com.unity.modules.unityanalytics@1.0.0 34 | com.unity.modules.unitywebrequest@1.0.0 35 | com.unity.modules.unitywebrequestassetbundle@1.0.0 36 | com.unity.modules.unitywebrequestaudio@1.0.0 37 | com.unity.modules.unitywebrequesttexture@1.0.0 38 | com.unity.modules.unitywebrequestwww@1.0.0 39 | com.unity.modules.vehicles@1.0.0 40 | com.unity.modules.video@1.0.0 41 | com.unity.modules.vr@1.0.0 42 | com.unity.modules.wind@1.0.0 43 | com.unity.modules.xr@1.0.0 44 | -------------------------------------------------------------------------------- /u3d/Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.ads": "2.0.8", 4 | "com.unity.analytics": "3.2.2", 5 | "com.unity.collab-proxy": "1.2.15", 6 | "com.unity.package-manager-ui": "2.0.3", 7 | "com.unity.purchasing": "2.0.3", 8 | "com.unity.textmeshpro": "1.3.0", 9 | "com.unity.modules.ai": "1.0.0", 10 | "com.unity.modules.animation": "1.0.0", 11 | "com.unity.modules.assetbundle": "1.0.0", 12 | "com.unity.modules.audio": "1.0.0", 13 | "com.unity.modules.cloth": "1.0.0", 14 | "com.unity.modules.director": "1.0.0", 15 | "com.unity.modules.imageconversion": "1.0.0", 16 | "com.unity.modules.imgui": "1.0.0", 17 | "com.unity.modules.jsonserialize": "1.0.0", 18 | "com.unity.modules.particlesystem": "1.0.0", 19 | "com.unity.modules.physics": "1.0.0", 20 | "com.unity.modules.physics2d": "1.0.0", 21 | "com.unity.modules.screencapture": "1.0.0", 22 | "com.unity.modules.terrain": "1.0.0", 23 | "com.unity.modules.terrainphysics": "1.0.0", 24 | "com.unity.modules.tilemap": "1.0.0", 25 | "com.unity.modules.ui": "1.0.0", 26 | "com.unity.modules.uielements": "1.0.0", 27 | "com.unity.modules.umbra": "1.0.0", 28 | "com.unity.modules.unityanalytics": "1.0.0", 29 | "com.unity.modules.unitywebrequest": "1.0.0", 30 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 31 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 32 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 33 | "com.unity.modules.unitywebrequestwww": "1.0.0", 34 | "com.unity.modules.vehicles": "1.0.0", 35 | "com.unity.modules.video": "1.0.0", 36 | "com.unity.modules.vr": "1.0.0", 37 | "com.unity.modules.wind": "1.0.0", 38 | "com.unity.modules.xr": "1.0.0" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /u3d/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /u3d/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /u3d/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /u3d/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /u3d/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /u3d/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /u3d/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /u3d/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /u3d/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /u3d/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /u3d/ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/ProjectSettings/PresetManager.asset -------------------------------------------------------------------------------- /u3d/ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /u3d/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2018.3.5f1 2 | -------------------------------------------------------------------------------- /u3d/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /u3d/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /u3d/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /u3d/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /u3d/ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luzexi/Unity3DUtil/a58e33ccefda412d4fe66a1cf414e3e7652a6204/u3d/ProjectSettings/VFXManager.asset --------------------------------------------------------------------------------