├── .gitignore ├── .vsconfig ├── Assets ├── 3rd.meta ├── 3rd │ ├── CodeMonkey.meta │ └── CodeMonkey │ │ ├── Assets.cs │ │ ├── Assets.cs.meta │ │ ├── Assets.meta │ │ ├── Assets │ │ ├── Circle.png │ │ ├── Circle.png.meta │ │ ├── White_1x1.mat │ │ ├── White_1x1.mat.meta │ │ ├── White_1x1.png │ │ └── White_1x1.png.meta │ │ ├── CMDebug.cs │ │ ├── CMDebug.cs.meta │ │ ├── MonoBehaviours.meta │ │ ├── MonoBehaviours │ │ ├── CameraFollow.cs │ │ ├── CameraFollow.cs.meta │ │ ├── CameraFollowSetup.cs │ │ ├── CameraFollowSetup.cs.meta │ │ ├── ComponentActions.cs │ │ ├── ComponentActions.cs.meta │ │ ├── PositionRendererSorter.cs │ │ └── PositionRendererSorter.cs.meta │ │ ├── README.txt │ │ ├── README.txt.meta │ │ ├── Resources.meta │ │ ├── Resources │ │ ├── CodeMonkeyAssets.prefab │ │ └── CodeMonkeyAssets.prefab.meta │ │ ├── Utils.meta │ │ └── Utils │ │ ├── Button_Sprite.cs │ │ ├── Button_Sprite.cs.meta │ │ ├── Button_UI.cs │ │ ├── Button_UI.cs.meta │ │ ├── FunctionPeriodic.cs │ │ ├── FunctionPeriodic.cs.meta │ │ ├── FunctionTimer.cs │ │ ├── FunctionTimer.cs.meta │ │ ├── FunctionUpdater.cs │ │ ├── FunctionUpdater.cs.meta │ │ ├── UI_Bar.cs │ │ ├── UI_Bar.cs.meta │ │ ├── UI_BarMultiple.cs │ │ ├── UI_BarMultiple.cs.meta │ │ ├── UI_Sprite.cs │ │ ├── UI_Sprite.cs.meta │ │ ├── UI_TextComplex.cs │ │ ├── UI_TextComplex.cs.meta │ │ ├── UtilsClass.cs │ │ ├── UtilsClass.cs.meta │ │ ├── World_Bar.cs │ │ ├── World_Bar.cs.meta │ │ ├── World_Mesh.cs │ │ ├── World_Mesh.cs.meta │ │ ├── World_Sprite.cs │ │ └── World_Sprite.cs.meta ├── Materials.meta ├── Materials │ ├── AnchorMat.mat │ ├── AnchorMat.mat.meta │ ├── PreviewMaterial.mat │ └── PreviewMaterial.mat.meta ├── Plugins.meta ├── Plugins │ ├── Demigiant.meta │ └── Demigiant │ │ ├── DOTween.meta │ │ └── DOTween │ │ ├── DOTween.XML │ │ ├── DOTween.XML.meta │ │ ├── DOTween.dll │ │ ├── DOTween.dll.meta │ │ ├── Editor.meta │ │ ├── Editor │ │ ├── DOTweenEditor.XML │ │ ├── DOTweenEditor.XML.meta │ │ ├── DOTweenEditor.dll │ │ ├── DOTweenEditor.dll.meta │ │ ├── Imgs.meta │ │ └── Imgs │ │ │ ├── DOTweenIcon.png │ │ │ ├── DOTweenIcon.png.meta │ │ │ ├── Footer.png │ │ │ ├── Footer.png.meta │ │ │ ├── Footer_dark.png │ │ │ ├── Footer_dark.png.meta │ │ │ ├── Header.jpg │ │ │ └── Header.jpg.meta │ │ ├── Modules.meta │ │ ├── Modules │ │ ├── DOTweenModuleAudio.cs │ │ ├── DOTweenModuleAudio.cs.meta │ │ ├── DOTweenModulePhysics.cs │ │ ├── DOTweenModulePhysics.cs.meta │ │ ├── DOTweenModulePhysics2D.cs │ │ ├── DOTweenModulePhysics2D.cs.meta │ │ ├── DOTweenModuleSprite.cs │ │ ├── DOTweenModuleSprite.cs.meta │ │ ├── DOTweenModuleUI.cs │ │ ├── DOTweenModuleUI.cs.meta │ │ ├── DOTweenModuleUnityVersion.cs │ │ ├── DOTweenModuleUnityVersion.cs.meta │ │ ├── DOTweenModuleUtils.cs │ │ └── DOTweenModuleUtils.cs.meta │ │ ├── readme.txt │ │ └── readme.txt.meta ├── Prefabs.meta ├── Prefabs │ ├── Cube 1x1.prefab │ ├── Cube 1x1.prefab.meta │ ├── Cube 2x2.prefab │ └── Cube 2x2.prefab.meta ├── Resources.meta ├── Resources │ ├── DOTweenSettings.asset │ ├── DOTweenSettings.asset.meta │ ├── ScriptableObjects.meta │ └── ScriptableObjects │ │ ├── Cube 1x1_SO.asset │ │ ├── Cube 1x1_SO.asset.meta │ │ ├── Cube 2x2_SO.asset │ │ └── Cube 2x2_SO.asset.meta ├── Scenes.meta ├── Scenes │ ├── SampleScene.unity │ └── SampleScene.unity.meta ├── Scripts.meta ├── Scripts │ ├── Actor.meta │ ├── Actor │ │ ├── PathFindingMovementHandler.cs │ │ └── PathFindingMovementHandler.cs.meta │ ├── Building.meta │ ├── Building │ │ ├── BuildingPreview.cs │ │ ├── BuildingPreview.cs.meta │ │ ├── PlaceableObject.cs │ │ ├── PlaceableObject.cs.meta │ │ ├── PlaceableObjectSO.cs │ │ └── PlaceableObjectSO.cs.meta │ ├── Grid.meta │ ├── Grid │ │ ├── GridBuildingSystem.cs │ │ ├── GridBuildingSystem.cs.meta │ │ ├── GridObject.cs │ │ ├── GridObject.cs.meta │ │ ├── GridXZ.cs │ │ └── GridXZ.cs.meta │ ├── PathFinding.meta │ ├── PathFinding │ │ ├── GridPathFinding.cs │ │ └── GridPathFinding.cs.meta │ ├── Utils.meta │ └── Utils │ │ ├── MousePositionUtils.cs │ │ ├── MousePositionUtils.cs.meta │ │ ├── SaveSystem.cs │ │ ├── SaveSystem.cs.meta │ │ ├── Singleton.cs │ │ └── Singleton.cs.meta ├── Terrain.meta └── Terrain │ ├── New Terrain.asset │ └── New Terrain.asset.meta ├── Packages ├── manifest.json └── packages-lock.json ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── PackageManagerSettings.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityConnectSettings.asset ├── VFXManager.asset ├── VersionControlSettings.asset └── XRSettings.asset └── UserSettings └── EditorUserSettings.asset /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Mm]emoryCaptures/ 12 | 13 | # Asset meta data should only be ignored when the corresponding asset is also ignored 14 | !/[Aa]ssets/**/*.meta 15 | 16 | # Uncomment this line if you wish to ignore the asset store tools plugin 17 | # /[Aa]ssets/AssetStoreTools* 18 | 19 | # Autogenerated Jetbrains Rider plugin 20 | [Aa]ssets/Plugins/Editor/JetBrains* 21 | 22 | # Visual Studio cache directory 23 | .vs/ 24 | 25 | # Gradle cache directory 26 | .gradle/ 27 | 28 | # Autogenerated VS/MD/Consulo solution and project files 29 | ExportedObj/ 30 | .consulo/ 31 | *.csproj 32 | *.unityproj 33 | *.sln 34 | *.suo 35 | *.tmp 36 | *.user 37 | *.userprefs 38 | *.pidb 39 | *.booproj 40 | *.svd 41 | *.pdb 42 | *.mdb 43 | *.opendb 44 | *.VC.db 45 | 46 | # Unity3D generated meta files 47 | *.pidb.meta 48 | *.pdb.meta 49 | *.mdb.meta 50 | 51 | # Unity3D generated file on crash reports 52 | sysinfo.txt 53 | 54 | # Builds 55 | *.apk 56 | *.unitypackage 57 | 58 | # Crashlytics generated file 59 | crashlytics-build.properties 60 | 61 | -------------------------------------------------------------------------------- /.vsconfig: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "components": [ 4 | "Microsoft.VisualStudio.Workload.ManagedGame" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /Assets/3rd.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f5efa0fa0b17a14ba440ef745bd8ef6 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 16b451a71f8c5644886a3d83a5a80de7 3 | folderAsset: yes 4 | timeCreated: 1523804043 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Assets.cs: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------- Code Monkey ------------------- 3 | 4 | Thank you for downloading the Code Monkey Utilities 5 | I hope you find them useful in your projects 6 | If you have any questions use the contact form 7 | Cheers! 8 | 9 | unitycodemonkey.com 10 | -------------------------------------------------- 11 | */ 12 | 13 | using System.Collections; 14 | using System.Collections.Generic; 15 | using UnityEngine; 16 | 17 | namespace CodeMonkey { 18 | 19 | /* 20 | * Global Asset references 21 | * Edit Asset references in the prefab CodeMonkey/Resources/CodeMonkeyAssets 22 | * */ 23 | public class Assets : MonoBehaviour { 24 | 25 | // Internal instance reference 26 | private static Assets _i; 27 | 28 | // Instance reference 29 | public static Assets i { 30 | get { 31 | if (_i == null) _i = Instantiate(Resources.Load("CodeMonkeyAssets")); 32 | return _i; 33 | } 34 | } 35 | 36 | 37 | // All references 38 | 39 | public Sprite s_White; 40 | public Sprite s_Circle; 41 | 42 | public Material m_White; 43 | 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Assets.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eda7ff5f6e8175c4da119ea9ed256f6d 3 | timeCreated: 1524393850 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Assets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87d70cfb1e610ac4dadb3551cb1dc28b 3 | folderAsset: yes 4 | timeCreated: 1524395615 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Assets/Circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moecia/UnityGridBuildingSystem/7916aecb67e5aab6dce5870e67b28ab95d2ad425/Assets/3rd/CodeMonkey/Assets/Circle.png -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Assets/Circle.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a0e35f6b808bb7447826cc6c69ffe448 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: 1 40 | nPOTScale: 0 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 1 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 8 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 2048 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | spriteSheet: 75 | serializedVersion: 2 76 | sprites: [] 77 | outline: [] 78 | physicsShape: [] 79 | bones: [] 80 | spriteID: 5e97eb03825dee720800000000000000 81 | internalID: 0 82 | vertices: [] 83 | indices: 84 | edges: [] 85 | weights: [] 86 | secondaryTextures: [] 87 | spritePackingTag: 88 | pSDRemoveMatte: 0 89 | pSDShowRemoveMatteOption: 0 90 | userData: 91 | assetBundleName: 92 | assetBundleVariant: 93 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Assets/White_1x1.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: White_1x1 11 | m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 2800000, guid: 170577bce7cbda144b82578f81308d23, type: 3} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 1, g: 1, b: 1, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Assets/White_1x1.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7d5e8e2c082a4c44a9abd7d650cf0a15 3 | timeCreated: 1527582754 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | externalObjects: {} 7 | mainObjectFileID: 2100000 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Assets/White_1x1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moecia/UnityGridBuildingSystem/7916aecb67e5aab6dce5870e67b28ab95d2ad425/Assets/3rd/CodeMonkey/Assets/White_1x1.png -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Assets/White_1x1.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 170577bce7cbda144b82578f81308d23 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: 1 40 | nPOTScale: 0 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 1 44 | spriteExtrude: 0 45 | spriteMeshType: 0 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 1 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 8 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 2048 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | - serializedVersion: 3 75 | buildTarget: Standalone 76 | maxTextureSize: 2048 77 | resizeAlgorithm: 0 78 | textureFormat: -1 79 | textureCompression: 1 80 | compressionQuality: 50 81 | crunchedCompression: 0 82 | allowsAlphaSplitting: 0 83 | overridden: 0 84 | androidETC2FallbackOverride: 0 85 | forceMaximumCompressionQuality_BC6H_BC7: 0 86 | spriteSheet: 87 | serializedVersion: 2 88 | sprites: [] 89 | outline: [] 90 | physicsShape: [] 91 | bones: [] 92 | spriteID: 5e97eb03825dee720800000000000000 93 | internalID: 0 94 | vertices: [] 95 | indices: 96 | edges: [] 97 | weights: [] 98 | secondaryTextures: [] 99 | spritePackingTag: 100 | pSDRemoveMatte: 0 101 | pSDShowRemoveMatteOption: 0 102 | userData: 103 | assetBundleName: 104 | assetBundleVariant: 105 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/CMDebug.cs: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------- Code Monkey ------------------- 3 | 4 | Thank you for downloading the Code Monkey Utilities 5 | I hope you find them useful in your projects 6 | If you have any questions use the contact form 7 | Cheers! 8 | 9 | unitycodemonkey.com 10 | -------------------------------------------------- 11 | */ 12 | 13 | using System; 14 | using UnityEngine; 15 | using CodeMonkey.Utils; 16 | 17 | namespace CodeMonkey { 18 | 19 | /* 20 | * Debug Class with various helper functions to quickly create buttons, text, etc 21 | * */ 22 | public static class CMDebug { 23 | 24 | // Creates a Button in the World 25 | public static World_Sprite Button(Transform parent, Vector3 localPosition, string text, System.Action ClickFunc, int fontSize = 30, float paddingX = 5, float paddingY = 5) { 26 | return World_Sprite.CreateDebugButton(parent, localPosition, text, ClickFunc, fontSize, paddingX, paddingY); 27 | } 28 | 29 | // Creates a Button in the UI 30 | public static UI_Sprite ButtonUI(Vector2 anchoredPosition, string text, Action ClickFunc) { 31 | return UI_Sprite.CreateDebugButton(anchoredPosition, text, ClickFunc); 32 | } 33 | 34 | public static UI_Sprite ButtonUI(Transform parent, Vector2 anchoredPosition, string text, Action ClickFunc) { 35 | return UI_Sprite.CreateDebugButton(parent, anchoredPosition, text, ClickFunc); 36 | } 37 | 38 | // Creates a World Text object at the world position 39 | public static void Text(string text, Vector3 localPosition = default(Vector3), Transform parent = null, int fontSize = 40, Color? color = null, TextAnchor textAnchor = TextAnchor.UpperLeft, TextAlignment textAlignment = TextAlignment.Left, int sortingOrder = UtilsClass.sortingOrderDefault) { 40 | UtilsClass.CreateWorldText(text, parent, localPosition, fontSize, color, textAnchor, textAlignment, sortingOrder); 41 | } 42 | 43 | // World text pop up at mouse position 44 | public static void TextPopupMouse(string text, Vector3? offset = null) { 45 | if (offset == null) { 46 | offset = Vector3.one; 47 | } 48 | UtilsClass.CreateWorldTextPopup(text, UtilsClass.GetMouseWorldPosition() + (Vector3)offset); 49 | } 50 | 51 | // World text pop up at mouse position 52 | public static void TextPopupMouse(object obj, Vector3? offset = null) { 53 | TextPopupMouse(obj.ToString(), offset); 54 | } 55 | 56 | // Creates a Text pop up at the world position 57 | public static void TextPopup(string text, Vector3 position, float popupTime = 1f) { 58 | UtilsClass.CreateWorldTextPopup(text, position, popupTime); 59 | } 60 | 61 | // Text Updater in World, (parent == null) = world position 62 | public static FunctionUpdater TextUpdater(Func GetTextFunc, Vector3 localPosition, Transform parent = null, int fontSize = 40, Color? color = null, TextAnchor textAnchor = TextAnchor.UpperLeft, TextAlignment textAlignment = TextAlignment.Left, int sortingOrder = UtilsClass.sortingOrderDefault) { 63 | return UtilsClass.CreateWorldTextUpdater(GetTextFunc, localPosition, parent, fontSize, color, textAnchor, textAlignment, sortingOrder); 64 | } 65 | 66 | // Text Updater in UI 67 | public static FunctionUpdater TextUpdaterUI(Func GetTextFunc, Vector2 anchoredPosition) { 68 | return UtilsClass.CreateUITextUpdater(GetTextFunc, anchoredPosition); 69 | } 70 | 71 | // Text Updater always following mouse 72 | public static void MouseTextUpdater(Func GetTextFunc, Vector3 positionOffset = default(Vector3)) { 73 | GameObject gameObject = new GameObject(); 74 | FunctionUpdater.Create(() => { 75 | gameObject.transform.position = UtilsClass.GetMouseWorldPosition() + positionOffset; 76 | return false; 77 | }); 78 | TextUpdater(GetTextFunc, Vector3.zero, gameObject.transform); 79 | } 80 | 81 | // Trigger Action on Key 82 | public static FunctionUpdater KeyCodeAction(KeyCode keyCode, Action onKeyDown) { 83 | return UtilsClass.CreateKeyCodeAction(keyCode, onKeyDown); 84 | } 85 | 86 | 87 | 88 | // Debug DrawLine to draw a projectile, turn Gizmos On 89 | public static void DebugProjectile(Vector3 from, Vector3 to, float speed, float projectileSize) { 90 | Vector3 dir = (to - from).normalized; 91 | Vector3 pos = from; 92 | FunctionUpdater.Create(() => { 93 | Debug.DrawLine(pos, pos + dir * projectileSize); 94 | float distanceBefore = Vector3.Distance(pos, to); 95 | pos += dir * speed * Time.deltaTime; 96 | float distanceAfter = Vector3.Distance(pos, to); 97 | if (distanceBefore < distanceAfter) { 98 | return true; 99 | } 100 | return false; 101 | }); 102 | } 103 | 104 | 105 | 106 | public static void SpritePopupMouse(Sprite sprite, float scale = 1f) { 107 | SpritePopup(UtilsClass.GetMouseWorldPosition(), sprite, scale); 108 | } 109 | 110 | 111 | public static void SpritePopup(Vector3 position, Sprite sprite, float scale) { 112 | float popupTime = 1f; 113 | GameObject gameObject = DrawSpriteTimedAlpha(position, sprite, scale, popupTime); 114 | 115 | Vector3 finalPopupPosition = position + new Vector3(0, 1, 0) * 20f; 116 | Transform transform = gameObject.transform; 117 | Vector3 moveAmount = (finalPopupPosition - position) / popupTime; 118 | 119 | FunctionUpdater.Create(delegate () { 120 | if (gameObject == null) { 121 | return true; 122 | } 123 | transform.position += moveAmount * Time.unscaledDeltaTime; 124 | return false; 125 | }, "SpritePopup"); 126 | } 127 | 128 | public static GameObject DrawSpriteTimed(Sprite sprite, float scale, float timer) { 129 | return DrawSpriteTimed(UtilsClass.GetMouseWorldPosition(), sprite, scale, timer); 130 | } 131 | 132 | public static GameObject DrawSpriteTimed(Vector3 position, Sprite sprite, float scale, float timer) { 133 | GameObject gameObject = new GameObject("SpriteTimed", typeof(SpriteRenderer)); 134 | gameObject.transform.position = position; 135 | gameObject.transform.localScale = Vector3.one * scale; 136 | gameObject.GetComponent().sprite = sprite; 137 | 138 | GameObject.Destroy(gameObject, timer); 139 | 140 | return gameObject; 141 | } 142 | 143 | public static GameObject DrawSpriteTimedAlpha(Sprite sprite, float scale, float timer, float startDecayTimeNormalized = .8f) { 144 | return DrawSpriteTimedAlpha(UtilsClass.GetMouseWorldPosition(), sprite, scale, timer, startDecayTimeNormalized); 145 | } 146 | 147 | public static GameObject DrawSpriteTimedAlpha(Vector3 position, Sprite sprite, float scale, float timer, float startDecayTimeNormalized = .8f) { 148 | GameObject gameObject = DrawSpriteTimed(position, sprite, scale, timer); 149 | 150 | SpriteRenderer spriteRenderer = gameObject.GetComponent(); 151 | 152 | float startAlphaDecayTime = timer * startDecayTimeNormalized; 153 | float totalAlphaDecayTime = timer - startAlphaDecayTime; 154 | float currentTime = 0f; 155 | 156 | FunctionUpdater.Create(() => { 157 | if (gameObject == null) { 158 | return true; 159 | } 160 | currentTime += Time.unscaledDeltaTime; 161 | if (currentTime >= startAlphaDecayTime) { 162 | spriteRenderer.color = new Color(1, 1, 1, Mathf.Lerp(1f, 0f, 1 - ((timer - currentTime) / totalAlphaDecayTime))); 163 | } 164 | return false; 165 | }); 166 | 167 | return gameObject; 168 | } 169 | 170 | 171 | } 172 | 173 | } -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/CMDebug.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6005648898e7f647ad2202fe256c311 3 | timeCreated: 1524945727 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/MonoBehaviours.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5abf4c77cbf61d94995a40be42eeaee0 3 | folderAsset: yes 4 | timeCreated: 1527582733 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/MonoBehaviours/CameraFollow.cs: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------- Code Monkey ------------------- 3 | 4 | Thank you for downloading the Code Monkey Utilities 5 | I hope you find them useful in your projects 6 | If you have any questions use the contact form 7 | Cheers! 8 | 9 | unitycodemonkey.com 10 | -------------------------------------------------- 11 | */ 12 | 13 | using System; 14 | using System.Collections.Generic; 15 | using UnityEngine; 16 | 17 | namespace CodeMonkey.MonoBehaviours { 18 | 19 | /* 20 | * Script to handle Camera Movement and Zoom 21 | * Place on Camera GameObject 22 | * */ 23 | public class CameraFollow : MonoBehaviour { 24 | 25 | public static CameraFollow Instance { get; private set; } 26 | 27 | private Camera myCamera; 28 | private Func GetCameraFollowPositionFunc; 29 | private Func GetCameraZoomFunc; 30 | 31 | public void Setup(Func GetCameraFollowPositionFunc, Func GetCameraZoomFunc, bool teleportToFollowPosition, bool instantZoom) { 32 | this.GetCameraFollowPositionFunc = GetCameraFollowPositionFunc; 33 | this.GetCameraZoomFunc = GetCameraZoomFunc; 34 | 35 | if (teleportToFollowPosition) { 36 | Vector3 cameraFollowPosition = GetCameraFollowPositionFunc(); 37 | cameraFollowPosition.z = transform.position.z; 38 | transform.position = cameraFollowPosition; 39 | } 40 | 41 | if (instantZoom) { 42 | myCamera.orthographicSize = GetCameraZoomFunc(); 43 | } 44 | } 45 | 46 | private void Awake() { 47 | Instance = this; 48 | myCamera = transform.GetComponent(); 49 | } 50 | 51 | public void SetCameraFollowPosition(Vector3 cameraFollowPosition) { 52 | SetGetCameraFollowPositionFunc(() => cameraFollowPosition); 53 | } 54 | 55 | public void SetGetCameraFollowPositionFunc(Func GetCameraFollowPositionFunc) { 56 | this.GetCameraFollowPositionFunc = GetCameraFollowPositionFunc; 57 | } 58 | 59 | public void SetCameraZoom(float cameraZoom) { 60 | SetGetCameraZoomFunc(() => cameraZoom); 61 | } 62 | 63 | public void SetGetCameraZoomFunc(Func GetCameraZoomFunc) { 64 | this.GetCameraZoomFunc = GetCameraZoomFunc; 65 | } 66 | 67 | 68 | private void Update() { 69 | HandleMovement(); 70 | HandleZoom(); 71 | } 72 | 73 | private void HandleMovement() { 74 | if (GetCameraFollowPositionFunc == null) return; 75 | Vector3 cameraFollowPosition = GetCameraFollowPositionFunc(); 76 | cameraFollowPosition.z = transform.position.z; 77 | 78 | Vector3 cameraMoveDir = (cameraFollowPosition - transform.position).normalized; 79 | float distance = Vector3.Distance(cameraFollowPosition, transform.position); 80 | float cameraMoveSpeed = 3f; 81 | 82 | if (distance > 0) { 83 | Vector3 newCameraPosition = transform.position + cameraMoveDir * distance * cameraMoveSpeed * Time.deltaTime; 84 | 85 | float distanceAfterMoving = Vector3.Distance(newCameraPosition, cameraFollowPosition); 86 | 87 | if (distanceAfterMoving > distance) { 88 | // Overshot the target 89 | newCameraPosition = cameraFollowPosition; 90 | } 91 | 92 | transform.position = newCameraPosition; 93 | } 94 | } 95 | 96 | private void HandleZoom() { 97 | if (GetCameraZoomFunc == null) return; 98 | float cameraZoom = GetCameraZoomFunc(); 99 | 100 | float cameraZoomDifference = cameraZoom - myCamera.orthographicSize; 101 | float cameraZoomSpeed = 1f; 102 | 103 | myCamera.orthographicSize += cameraZoomDifference * cameraZoomSpeed * Time.deltaTime; 104 | 105 | if (cameraZoomDifference > 0) { 106 | if (myCamera.orthographicSize > cameraZoom) { 107 | myCamera.orthographicSize = cameraZoom; 108 | } 109 | } else { 110 | if (myCamera.orthographicSize < cameraZoom) { 111 | myCamera.orthographicSize = cameraZoom; 112 | } 113 | } 114 | } 115 | } 116 | 117 | } -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/MonoBehaviours/CameraFollow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f73a3eab49f30d344a207d7d3d931d98 3 | timeCreated: 1527867131 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/MonoBehaviours/CameraFollowSetup.cs: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------- Code Monkey ------------------- 3 | 4 | Thank you for downloading the Code Monkey Utilities 5 | I hope you find them useful in your projects 6 | If you have any questions use the contact form 7 | Cheers! 8 | 9 | unitycodemonkey.com 10 | -------------------------------------------------- 11 | */ 12 | 13 | using System.Collections.Generic; 14 | using UnityEngine; 15 | 16 | namespace CodeMonkey.MonoBehaviours { 17 | 18 | /* 19 | * Easy set up for CameraFollow, it will follow the transform with zoom 20 | * */ 21 | public class CameraFollowSetup : MonoBehaviour { 22 | 23 | [SerializeField] private CameraFollow cameraFollow = null; 24 | [SerializeField] private Transform followTransform = null; 25 | [SerializeField] private float zoom = 50f; 26 | 27 | private void Start() { 28 | if (followTransform == null) { 29 | Debug.LogError("followTransform is null! Intended?"); 30 | cameraFollow.Setup(() => Vector3.zero, () => zoom, true, true); 31 | } else { 32 | cameraFollow.Setup(() => followTransform.position, () => zoom, true, true); 33 | } 34 | } 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/MonoBehaviours/CameraFollowSetup.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 31e947e7eb3216d40b72c592fa6847a3 3 | timeCreated: 1527867131 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/MonoBehaviours/ComponentActions.cs: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------- Code Monkey ------------------- 3 | 4 | Thank you for downloading the Code Monkey Utilities 5 | I hope you find them useful in your projects 6 | If you have any questions use the contact form 7 | Cheers! 8 | 9 | unitycodemonkey.com 10 | -------------------------------------------------- 11 | */ 12 | 13 | using System; 14 | using UnityEngine; 15 | 16 | namespace CodeMonkey.MonoBehaviours { 17 | 18 | /* 19 | * Trigger Actions on MonoBehaviour Component events 20 | * */ 21 | public class ComponentActions : MonoBehaviour { 22 | 23 | public Action OnDestroyFunc; 24 | public Action OnEnableFunc; 25 | public Action OnDisableFunc; 26 | public Action OnUpdate; 27 | 28 | private void OnDestroy() { 29 | if (OnDestroyFunc != null) OnDestroyFunc(); 30 | } 31 | 32 | private void OnEnable() { 33 | if (OnEnableFunc != null) OnEnableFunc(); 34 | } 35 | 36 | private void OnDisable() { 37 | if (OnDisableFunc != null) OnDisableFunc(); 38 | } 39 | 40 | private void Update() { 41 | if (OnUpdate != null) OnUpdate(); 42 | } 43 | 44 | 45 | public static void CreateComponent(Action OnDestroyFunc = null, Action OnEnableFunc = null, Action OnDisableFunc = null, Action OnUpdate = null) { 46 | GameObject gameObject = new GameObject("ComponentActions"); 47 | AddComponent(gameObject, OnDestroyFunc, OnEnableFunc, OnDisableFunc, OnUpdate); 48 | } 49 | 50 | public static void AddComponent(GameObject gameObject, Action OnDestroyFunc = null, Action OnEnableFunc = null, Action OnDisableFunc = null, Action OnUpdate = null) { 51 | ComponentActions componentFuncs = gameObject.AddComponent(); 52 | componentFuncs.OnDestroyFunc = OnDestroyFunc; 53 | componentFuncs.OnEnableFunc = OnEnableFunc; 54 | componentFuncs.OnDisableFunc = OnDisableFunc; 55 | componentFuncs.OnUpdate = OnUpdate; 56 | } 57 | 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/MonoBehaviours/ComponentActions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb3e855e7fda2944b91078893f9e8fd8 3 | timeCreated: 1511794191 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/MonoBehaviours/PositionRendererSorter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------- Code Monkey ------------------- 3 | 4 | Thank you for downloading the Code Monkey Utilities 5 | I hope you find them useful in your projects 6 | If you have any questions use the contact form 7 | Cheers! 8 | 9 | unitycodemonkey.com 10 | -------------------------------------------------- 11 | */ 12 | 13 | using UnityEngine; 14 | 15 | namespace CodeMonkey.MonoBehaviours { 16 | 17 | /* 18 | * Automatically sort a Renderer (SpriteRenderer, MeshRenderer) based on his Y position 19 | * */ 20 | public class PositionRendererSorter : MonoBehaviour { 21 | 22 | [SerializeField] private int sortingOrderBase = 5000; // This number should be higher than what any of your sprites will be on the position.y 23 | [SerializeField] private int offset = 0; 24 | [SerializeField] private bool runOnlyOnce = false; 25 | 26 | private float timer; 27 | private float timerMax = .1f; 28 | private Renderer myRenderer; 29 | 30 | private void Awake() { 31 | myRenderer = gameObject.GetComponent(); 32 | } 33 | 34 | private void LateUpdate() { 35 | timer -= Time.deltaTime; 36 | if (timer <= 0f) { 37 | timer = timerMax; 38 | myRenderer.sortingOrder = (int)(sortingOrderBase - transform.position.y - offset); 39 | if (runOnlyOnce) { 40 | Destroy(this); 41 | } 42 | } 43 | } 44 | 45 | public void SetOffset(int offset) { 46 | this.offset = offset; 47 | } 48 | 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/MonoBehaviours/PositionRendererSorter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b330b302c69005c4f98a928f7d71b877 3 | timeCreated: 1526502963 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/README.txt: -------------------------------------------------------------------------------- 1 | ------------------- Code Monkey ------------------- 2 | 3 | Thank you for downloading the Code Monkey Utilities 4 | I hope you find them useful in your projects 5 | If you have any questions use the contact form 6 | Cheers! 7 | 8 | unitycodemonkey.com 9 | -------------------------------------------------- 10 | 11 | Version: 1.03 12 | Date: 06-02-2021 13 | 14 | Version: 1.02 15 | Date: 01-06-2018 -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/README.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f59bf2b41588bd44780fc5218f7864e1 3 | timeCreated: 1526276062 4 | licenseType: Pro 5 | TextScriptImporter: 6 | externalObjects: {} 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c480003fd87d3548ae91e921a89a579 3 | folderAsset: yes 4 | timeCreated: 1524394058 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Resources/CodeMonkeyAssets.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &1010336202903800 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 4240258222200348} 12 | - component: {fileID: 114165315123428144} 13 | m_Layer: 0 14 | m_Name: CodeMonkeyAssets 15 | m_TagString: Untagged 16 | m_Icon: {fileID: 0} 17 | m_NavMeshLayer: 0 18 | m_StaticEditorFlags: 0 19 | m_IsActive: 1 20 | --- !u!4 &4240258222200348 21 | Transform: 22 | m_ObjectHideFlags: 0 23 | m_CorrespondingSourceObject: {fileID: 0} 24 | m_PrefabInstance: {fileID: 0} 25 | m_PrefabAsset: {fileID: 0} 26 | m_GameObject: {fileID: 1010336202903800} 27 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 28 | m_LocalPosition: {x: 991.20996, y: 137.51582, z: 149.5} 29 | m_LocalScale: {x: 1, y: 1, z: 1} 30 | m_Children: [] 31 | m_Father: {fileID: 0} 32 | m_RootOrder: 0 33 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 34 | --- !u!114 &114165315123428144 35 | MonoBehaviour: 36 | m_ObjectHideFlags: 0 37 | m_CorrespondingSourceObject: {fileID: 0} 38 | m_PrefabInstance: {fileID: 0} 39 | m_PrefabAsset: {fileID: 0} 40 | m_GameObject: {fileID: 1010336202903800} 41 | m_Enabled: 1 42 | m_EditorHideFlags: 0 43 | m_Script: {fileID: 11500000, guid: eda7ff5f6e8175c4da119ea9ed256f6d, type: 3} 44 | m_Name: 45 | m_EditorClassIdentifier: 46 | s_White: {fileID: 21300000, guid: 170577bce7cbda144b82578f81308d23, type: 3} 47 | s_Circle: {fileID: 21300000, guid: a0e35f6b808bb7447826cc6c69ffe448, type: 3} 48 | m_White: {fileID: 2100000, guid: 7d5e8e2c082a4c44a9abd7d650cf0a15, type: 2} 49 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Resources/CodeMonkeyAssets.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6cb9ffb1fe7e89d4a890b91c62fa7e8b 3 | timeCreated: 1524393897 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | externalObjects: {} 7 | mainObjectFileID: 100100000 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d900c58c01968cd42bb98e37d8e4d05c 3 | folderAsset: yes 4 | timeCreated: 1524300187 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/Button_Sprite.cs: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------- Code Monkey ------------------- 3 | 4 | Thank you for downloading the Code Monkey Utilities 5 | I hope you find them useful in your projects 6 | If you have any questions use the contact form 7 | Cheers! 8 | 9 | unitycodemonkey.com 10 | -------------------------------------------------- 11 | */ 12 | 13 | //#define SOUND_MANAGER // Has Sound_Manager in project 14 | //#define CURSOR_MANAGER // Has Cursor_Manager in project 15 | 16 | using System; 17 | using UnityEngine; 18 | using System.Collections.Generic; 19 | using UnityEngine.EventSystems; 20 | 21 | namespace CodeMonkey.Utils { 22 | 23 | /* 24 | * Button Actions on a World BoxCollider 25 | * */ 26 | public class Button_Sprite : MonoBehaviour { 27 | 28 | private static Func GetWorldCamera; 29 | 30 | public static void SetGetWorldCamera(Func GetWorldCamera) { 31 | Button_Sprite.GetWorldCamera = GetWorldCamera; 32 | } 33 | 34 | 35 | 36 | 37 | 38 | public Action ClickFunc = null; 39 | public Action MouseRightDownOnceFunc = null; 40 | public Action MouseRightDownFunc = null; 41 | public Action MouseRightUpFunc = null; 42 | public Action MouseDownOnceFunc = null; 43 | public Action MouseUpOnceFunc = null; 44 | public Action MouseOverOnceFunc = null; 45 | public Action MouseOutOnceFunc = null; 46 | public Action MouseOverOnceTooltipFunc = null; 47 | public Action MouseOutOnceTooltipFunc = null; 48 | 49 | private bool draggingMouseRight; 50 | private Vector3 mouseRightDragStart; 51 | public Action MouseRightDragFunc = null; 52 | public Action MouseRightDragUpdateFunc = null; 53 | public bool triggerMouseRightDragOnEnter = false; 54 | 55 | public enum HoverBehaviour { 56 | Custom, 57 | Change_Color, 58 | Change_Image, 59 | Change_SetActive, 60 | } 61 | public HoverBehaviour hoverBehaviourType = HoverBehaviour.Custom; 62 | private Action hoverBehaviourFunc_Enter, hoverBehaviourFunc_Exit; 63 | 64 | public Color hoverBehaviour_Color_Enter = new Color(1, 1, 1, 1), hoverBehaviour_Color_Exit = new Color(1, 1, 1, 1); 65 | public SpriteRenderer hoverBehaviour_Image; 66 | public Sprite hoverBehaviour_Sprite_Exit, hoverBehaviour_Sprite_Enter; 67 | public bool hoverBehaviour_Move = false; 68 | public Vector2 hoverBehaviour_Move_Amount = Vector2.zero; 69 | private Vector3 posExit, posEnter; 70 | public bool triggerMouseOutFuncOnClick = false; 71 | public bool clickThroughUI = false; 72 | 73 | private Action internalOnMouseDownFunc = null, internalOnMouseEnterFunc = null, internalOnMouseExitFunc = null; 74 | 75 | #if SOUND_MANAGER 76 | public Sound_Manager.Sound mouseOverSound, mouseClickSound; 77 | #endif 78 | #if CURSOR_MANAGER 79 | public CursorManager.CursorType cursorMouseOver, cursorMouseOut; 80 | #endif 81 | 82 | 83 | 84 | 85 | public void SetHoverBehaviourChangeColor(Color colorOver, Color colorOut) { 86 | hoverBehaviourType = HoverBehaviour.Change_Color; 87 | hoverBehaviour_Color_Enter = colorOver; 88 | hoverBehaviour_Color_Exit = colorOut; 89 | if (hoverBehaviour_Image == null) hoverBehaviour_Image = transform.GetComponent(); 90 | hoverBehaviour_Image.color = hoverBehaviour_Color_Exit; 91 | SetupHoverBehaviour(); 92 | } 93 | void OnMouseDown() { 94 | if (!clickThroughUI && IsPointerOverUI()) return; // Over UI! 95 | 96 | if (internalOnMouseDownFunc != null) internalOnMouseDownFunc(); 97 | if (ClickFunc != null) ClickFunc(); 98 | if (MouseDownOnceFunc != null) MouseDownOnceFunc(); 99 | if (triggerMouseOutFuncOnClick) OnMouseExit(); 100 | } 101 | public void Manual_OnMouseExit() { 102 | OnMouseExit(); 103 | } 104 | void OnMouseUp() { 105 | if (MouseUpOnceFunc != null) MouseUpOnceFunc(); 106 | } 107 | void OnMouseEnter() { 108 | if (!clickThroughUI && IsPointerOverUI()) return; // Over UI! 109 | 110 | if (internalOnMouseEnterFunc != null) internalOnMouseEnterFunc(); 111 | if (hoverBehaviour_Move) transform.localPosition = posEnter; 112 | if (hoverBehaviourFunc_Enter != null) hoverBehaviourFunc_Enter(); 113 | if (MouseOverOnceFunc != null) MouseOverOnceFunc(); 114 | if (MouseOverOnceTooltipFunc != null) MouseOverOnceTooltipFunc(); 115 | } 116 | void OnMouseExit() { 117 | if (internalOnMouseExitFunc != null) internalOnMouseExitFunc(); 118 | if (hoverBehaviour_Move) transform.localPosition = posExit; 119 | if (hoverBehaviourFunc_Exit != null) hoverBehaviourFunc_Exit(); 120 | if (MouseOutOnceFunc != null) MouseOutOnceFunc(); 121 | if (MouseOutOnceTooltipFunc != null) MouseOutOnceTooltipFunc(); 122 | } 123 | 124 | void OnMouseOver() { 125 | if (!clickThroughUI && IsPointerOverUI()) return; // Over UI! 126 | 127 | if (Input.GetMouseButton(1)) { 128 | if (MouseRightDownFunc != null) MouseRightDownFunc(); 129 | if (!draggingMouseRight && triggerMouseRightDragOnEnter) { 130 | draggingMouseRight = true; 131 | mouseRightDragStart = GetWorldPositionFromUI(); 132 | } 133 | } 134 | if (Input.GetMouseButtonDown(1)) { 135 | draggingMouseRight = true; 136 | mouseRightDragStart = GetWorldPositionFromUI(); 137 | if (MouseRightDownOnceFunc != null) MouseRightDownOnceFunc(); 138 | } 139 | } 140 | void Update() { 141 | if (draggingMouseRight) { 142 | if (MouseRightDragUpdateFunc != null) MouseRightDragUpdateFunc(mouseRightDragStart, GetWorldPositionFromUI()); 143 | } 144 | if (Input.GetMouseButtonUp(1)) { 145 | if (draggingMouseRight) { 146 | draggingMouseRight = false; 147 | if (MouseRightDragFunc != null) MouseRightDragFunc(mouseRightDragStart, GetWorldPositionFromUI()); 148 | } 149 | if (MouseRightUpFunc != null) MouseRightUpFunc(); 150 | } 151 | } 152 | 153 | 154 | void Awake() { 155 | if (GetWorldCamera == null) SetGetWorldCamera(() => Camera.main); // Set default World Camera 156 | posExit = transform.localPosition; 157 | posEnter = transform.localPosition + (Vector3)hoverBehaviour_Move_Amount; 158 | SetupHoverBehaviour(); 159 | 160 | #if SOUND_MANAGER 161 | // Sound Manager 162 | internalOnMouseDownFunc += () => { if (mouseClickSound != Sound_Manager.Sound.None) Sound_Manager.PlaySound(mouseClickSound); }; 163 | internalOnMouseEnterFunc += () => { if (mouseOverSound != Sound_Manager.Sound.None) Sound_Manager.PlaySound(mouseOverSound); }; 164 | #endif 165 | 166 | #if CURSOR_MANAGER 167 | // Cursor Manager 168 | internalOnMouseExitFunc += () => { if (cursorMouseOut != CursorManager.CursorType.None) CursorManager.SetCursor(cursorMouseOut); }; 169 | internalOnMouseEnterFunc += () => { if (cursorMouseOver != CursorManager.CursorType.None) CursorManager.SetCursor(cursorMouseOver); }; 170 | #endif 171 | } 172 | private void SetupHoverBehaviour() { 173 | switch (hoverBehaviourType) { 174 | case HoverBehaviour.Change_Color: 175 | hoverBehaviourFunc_Enter = delegate () { hoverBehaviour_Image.color = hoverBehaviour_Color_Enter; }; 176 | hoverBehaviourFunc_Exit = delegate () { hoverBehaviour_Image.color = hoverBehaviour_Color_Exit; }; 177 | break; 178 | case HoverBehaviour.Change_Image: 179 | hoverBehaviourFunc_Enter = delegate () { hoverBehaviour_Image.sprite = hoverBehaviour_Sprite_Enter; }; 180 | hoverBehaviourFunc_Exit = delegate () { hoverBehaviour_Image.sprite = hoverBehaviour_Sprite_Exit; }; 181 | break; 182 | case HoverBehaviour.Change_SetActive: 183 | hoverBehaviourFunc_Enter = delegate () { hoverBehaviour_Image.gameObject.SetActive(true); }; 184 | hoverBehaviourFunc_Exit = delegate () { hoverBehaviour_Image.gameObject.SetActive(false); }; 185 | break; 186 | } 187 | } 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | private static Vector3 GetWorldPositionFromUI() { 196 | Vector3 worldPosition = GetWorldCamera().ScreenToWorldPoint(Input.mousePosition); 197 | return worldPosition; 198 | } 199 | private static bool IsPointerOverUI() { 200 | if (EventSystem.current.IsPointerOverGameObject()) { 201 | return true; 202 | } else { 203 | PointerEventData pe = new PointerEventData(EventSystem.current); 204 | pe.position = Input.mousePosition; 205 | List hits = new List(); 206 | EventSystem.current.RaycastAll(pe, hits); 207 | return hits.Count > 0; 208 | } 209 | } 210 | } 211 | 212 | } -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/Button_Sprite.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4771330f098d1db4898ad07204154d04 3 | timeCreated: 1513255758 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/Button_UI.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 602f74cbbbd80034b96f88091a8e7c1d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/FunctionPeriodic.cs: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------- Code Monkey ------------------- 3 | 4 | Thank you for downloading the Code Monkey Utilities 5 | I hope you find them useful in your projects 6 | If you have any questions use the contact form 7 | Cheers! 8 | 9 | unitycodemonkey.com 10 | -------------------------------------------------- 11 | */ 12 | 13 | using System; 14 | using System.Collections.Generic; 15 | using UnityEngine; 16 | 17 | namespace CodeMonkey.Utils { 18 | 19 | /* 20 | * Executes a Function periodically 21 | * */ 22 | public class FunctionPeriodic { 23 | 24 | /* 25 | * Class to hook Actions into MonoBehaviour 26 | * */ 27 | private class MonoBehaviourHook : MonoBehaviour { 28 | 29 | public Action OnUpdate; 30 | 31 | private void Update() { 32 | if (OnUpdate != null) OnUpdate(); 33 | } 34 | 35 | } 36 | 37 | 38 | private static List funcList; // Holds a reference to all active timers 39 | private static GameObject initGameObject; // Global game object used for initializing class, is destroyed on scene change 40 | 41 | private static void InitIfNeeded() { 42 | if (initGameObject == null) { 43 | initGameObject = new GameObject("FunctionPeriodic_Global"); 44 | funcList = new List(); 45 | } 46 | } 47 | 48 | 49 | 50 | // Persist through scene loads 51 | public static FunctionPeriodic Create_Global(Action action, Func testDestroy, float timer) { 52 | FunctionPeriodic functionPeriodic = Create(action, testDestroy, timer, "", false, false, false); 53 | MonoBehaviour.DontDestroyOnLoad(functionPeriodic.gameObject); 54 | return functionPeriodic; 55 | } 56 | 57 | 58 | // Trigger [action] every [timer], execute [testDestroy] after triggering action, destroy if returns true 59 | public static FunctionPeriodic Create(Action action, Func testDestroy, float timer) { 60 | return Create(action, testDestroy, timer, "", false); 61 | } 62 | 63 | public static FunctionPeriodic Create(Action action, float timer) { 64 | return Create(action, null, timer, "", false, false, false); 65 | } 66 | 67 | public static FunctionPeriodic Create(Action action, float timer, string functionName) { 68 | return Create(action, null, timer, functionName, false, false, false); 69 | } 70 | 71 | public static FunctionPeriodic Create(Action callback, Func testDestroy, float timer, string functionName, bool stopAllWithSameName) { 72 | return Create(callback, testDestroy, timer, functionName, false, false, stopAllWithSameName); 73 | } 74 | 75 | public static FunctionPeriodic Create(Action action, Func testDestroy, float timer, string functionName, bool useUnscaledDeltaTime, bool triggerImmediately, bool stopAllWithSameName) { 76 | InitIfNeeded(); 77 | 78 | if (stopAllWithSameName) { 79 | StopAllFunc(functionName); 80 | } 81 | 82 | GameObject gameObject = new GameObject("FunctionPeriodic Object " + functionName, typeof(MonoBehaviourHook)); 83 | FunctionPeriodic functionPeriodic = new FunctionPeriodic(gameObject, action, timer, testDestroy, functionName, useUnscaledDeltaTime); 84 | gameObject.GetComponent().OnUpdate = functionPeriodic.Update; 85 | 86 | funcList.Add(functionPeriodic); 87 | 88 | if (triggerImmediately) action(); 89 | 90 | return functionPeriodic; 91 | } 92 | 93 | 94 | 95 | 96 | public static void RemoveTimer(FunctionPeriodic funcTimer) { 97 | InitIfNeeded(); 98 | funcList.Remove(funcTimer); 99 | } 100 | public static void StopTimer(string _name) { 101 | InitIfNeeded(); 102 | for (int i = 0; i < funcList.Count; i++) { 103 | if (funcList[i].functionName == _name) { 104 | funcList[i].DestroySelf(); 105 | return; 106 | } 107 | } 108 | } 109 | public static void StopAllFunc(string _name) { 110 | InitIfNeeded(); 111 | for (int i = 0; i < funcList.Count; i++) { 112 | if (funcList[i].functionName == _name) { 113 | funcList[i].DestroySelf(); 114 | i--; 115 | } 116 | } 117 | } 118 | public static bool IsFuncActive(string name) { 119 | InitIfNeeded(); 120 | for (int i = 0; i < funcList.Count; i++) { 121 | if (funcList[i].functionName == name) { 122 | return true; 123 | } 124 | } 125 | return false; 126 | } 127 | 128 | 129 | 130 | 131 | private GameObject gameObject; 132 | private float timer; 133 | private float baseTimer; 134 | private bool useUnscaledDeltaTime; 135 | private string functionName; 136 | public Action action; 137 | public Func testDestroy; 138 | 139 | 140 | private FunctionPeriodic(GameObject gameObject, Action action, float timer, Func testDestroy, string functionName, bool useUnscaledDeltaTime) { 141 | this.gameObject = gameObject; 142 | this.action = action; 143 | this.timer = timer; 144 | this.testDestroy = testDestroy; 145 | this.functionName = functionName; 146 | this.useUnscaledDeltaTime = useUnscaledDeltaTime; 147 | baseTimer = timer; 148 | } 149 | 150 | public void SkipTimerTo(float timer) { 151 | this.timer = timer; 152 | } 153 | 154 | public void SetBaseTimer(float baseTimer) { 155 | this.baseTimer = baseTimer; 156 | } 157 | 158 | public float GetBaseTimer() { 159 | return baseTimer; 160 | } 161 | 162 | private void Update() { 163 | if (useUnscaledDeltaTime) { 164 | timer -= Time.unscaledDeltaTime; 165 | } else { 166 | timer -= Time.deltaTime; 167 | } 168 | if (timer <= 0) { 169 | action(); 170 | if (testDestroy != null && testDestroy()) { 171 | //Destroy 172 | DestroySelf(); 173 | } else { 174 | //Repeat 175 | timer += baseTimer; 176 | } 177 | } 178 | } 179 | 180 | public void DestroySelf() { 181 | RemoveTimer(this); 182 | if (gameObject != null) { 183 | UnityEngine.Object.Destroy(gameObject); 184 | } 185 | } 186 | } 187 | } -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/FunctionPeriodic.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f522bd6f08a5c984a9512bb60ebc1818 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/FunctionTimer.cs: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------- Code Monkey ------------------- 3 | 4 | Thank you for downloading the Code Monkey Utilities 5 | I hope you find them useful in your projects 6 | If you have any questions use the contact form 7 | Cheers! 8 | 9 | unitycodemonkey.com 10 | -------------------------------------------------- 11 | */ 12 | 13 | using System; 14 | using UnityEngine; 15 | using System.Collections.Generic; 16 | 17 | namespace CodeMonkey.Utils { 18 | 19 | /* 20 | * Triggers a Action after a certain time 21 | * */ 22 | public class FunctionTimer { 23 | 24 | /* 25 | * Class to hook Actions into MonoBehaviour 26 | * */ 27 | private class MonoBehaviourHook : MonoBehaviour { 28 | 29 | public Action OnUpdate; 30 | 31 | private void Update() { 32 | if (OnUpdate != null) OnUpdate(); 33 | } 34 | 35 | } 36 | 37 | 38 | private static List timerList; // Holds a reference to all active timers 39 | private static GameObject initGameObject; // Global game object used for initializing class, is destroyed on scene change 40 | 41 | private static void InitIfNeeded() { 42 | if (initGameObject == null) { 43 | initGameObject = new GameObject("FunctionTimer_Global"); 44 | timerList = new List(); 45 | } 46 | } 47 | 48 | 49 | 50 | 51 | public static FunctionTimer Create(Action action, float timer) { 52 | return Create(action, timer, "", false, false); 53 | } 54 | 55 | public static FunctionTimer Create(Action action, float timer, string functionName) { 56 | return Create(action, timer, functionName, false, false); 57 | } 58 | 59 | public static FunctionTimer Create(Action action, float timer, string functionName, bool useUnscaledDeltaTime) { 60 | return Create(action, timer, functionName, useUnscaledDeltaTime, false); 61 | } 62 | 63 | public static FunctionTimer Create(Action action, float timer, string functionName, bool useUnscaledDeltaTime, bool stopAllWithSameName) { 64 | InitIfNeeded(); 65 | 66 | if (stopAllWithSameName) { 67 | StopAllTimersWithName(functionName); 68 | } 69 | 70 | GameObject obj = new GameObject("FunctionTimer Object "+functionName, typeof(MonoBehaviourHook)); 71 | FunctionTimer funcTimer = new FunctionTimer(obj, action, timer, functionName, useUnscaledDeltaTime); 72 | obj.GetComponent().OnUpdate = funcTimer.Update; 73 | 74 | timerList.Add(funcTimer); 75 | 76 | return funcTimer; 77 | } 78 | 79 | public static void RemoveTimer(FunctionTimer funcTimer) { 80 | InitIfNeeded(); 81 | timerList.Remove(funcTimer); 82 | } 83 | 84 | public static void StopAllTimersWithName(string functionName) { 85 | InitIfNeeded(); 86 | for (int i = 0; i < timerList.Count; i++) { 87 | if (timerList[i].functionName == functionName) { 88 | timerList[i].DestroySelf(); 89 | i--; 90 | } 91 | } 92 | } 93 | 94 | public static void StopFirstTimerWithName(string functionName) { 95 | InitIfNeeded(); 96 | for (int i = 0; i < timerList.Count; i++) { 97 | if (timerList[i].functionName == functionName) { 98 | timerList[i].DestroySelf(); 99 | return; 100 | } 101 | } 102 | } 103 | 104 | 105 | 106 | 107 | 108 | private GameObject gameObject; 109 | private float timer; 110 | private string functionName; 111 | private bool active; 112 | private bool useUnscaledDeltaTime; 113 | private Action action; 114 | 115 | 116 | 117 | public FunctionTimer(GameObject gameObject, Action action, float timer, string functionName, bool useUnscaledDeltaTime) { 118 | this.gameObject = gameObject; 119 | this.action = action; 120 | this.timer = timer; 121 | this.functionName = functionName; 122 | this.useUnscaledDeltaTime = useUnscaledDeltaTime; 123 | } 124 | 125 | private void Update() { 126 | if (useUnscaledDeltaTime) { 127 | timer -= Time.unscaledDeltaTime; 128 | } else { 129 | timer -= Time.deltaTime; 130 | } 131 | if (timer <= 0) { 132 | // Timer complete, trigger Action 133 | action(); 134 | DestroySelf(); 135 | } 136 | } 137 | 138 | private void DestroySelf() { 139 | RemoveTimer(this); 140 | if (gameObject != null) { 141 | UnityEngine.Object.Destroy(gameObject); 142 | } 143 | } 144 | 145 | 146 | 147 | 148 | /* 149 | * Class to trigger Actions manually without creating a GameObject 150 | * */ 151 | public class FunctionTimerObject { 152 | 153 | private float timer; 154 | private Action callback; 155 | 156 | public FunctionTimerObject(Action callback, float timer) { 157 | this.callback = callback; 158 | this.timer = timer; 159 | } 160 | 161 | public bool Update() { 162 | return Update(Time.deltaTime); 163 | } 164 | 165 | public bool Update(float deltaTime) { 166 | timer -= deltaTime; 167 | if (timer <= 0) { 168 | callback(); 169 | return true; 170 | } else { 171 | return false; 172 | } 173 | } 174 | } 175 | 176 | // Create a Object that must be manually updated through Update(); 177 | public static FunctionTimerObject CreateObject(Action callback, float timer) { 178 | return new FunctionTimerObject(callback, timer); 179 | } 180 | 181 | } 182 | 183 | } -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/FunctionTimer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c8b5f0217e73fa47827cf77f22c2f8d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/FunctionUpdater.cs: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------- Code Monkey ------------------- 3 | 4 | Thank you for downloading the Code Monkey Utilities 5 | I hope you find them useful in your projects 6 | If you have any questions use the contact form 7 | Cheers! 8 | 9 | unitycodemonkey.com 10 | -------------------------------------------------- 11 | */ 12 | 13 | using System; 14 | using UnityEngine; 15 | using System.Collections.Generic; 16 | 17 | namespace CodeMonkey.Utils { 18 | 19 | /* 20 | * Calls function on every Update until it returns true 21 | * */ 22 | public class FunctionUpdater { 23 | 24 | /* 25 | * Class to hook Actions into MonoBehaviour 26 | * */ 27 | private class MonoBehaviourHook : MonoBehaviour { 28 | 29 | public Action OnUpdate; 30 | 31 | private void Update() { 32 | if (OnUpdate != null) OnUpdate(); 33 | } 34 | 35 | } 36 | 37 | private static List updaterList; // Holds a reference to all active updaters 38 | private static GameObject initGameObject; // Global game object used for initializing class, is destroyed on scene change 39 | 40 | private static void InitIfNeeded() { 41 | if (initGameObject == null) { 42 | initGameObject = new GameObject("FunctionUpdater_Global"); 43 | updaterList = new List(); 44 | } 45 | } 46 | 47 | 48 | 49 | 50 | public static FunctionUpdater Create(Action updateFunc) { 51 | return Create(() => { updateFunc(); return false; }, "", true, false); 52 | } 53 | 54 | public static FunctionUpdater Create(Action updateFunc, string functionName) { 55 | return Create(() => { updateFunc(); return false; }, functionName, true, false); 56 | } 57 | 58 | public static FunctionUpdater Create(Func updateFunc) { 59 | return Create(updateFunc, "", true, false); 60 | } 61 | 62 | public static FunctionUpdater Create(Func updateFunc, string functionName) { 63 | return Create(updateFunc, functionName, true, false); 64 | } 65 | 66 | public static FunctionUpdater Create(Func updateFunc, string functionName, bool active) { 67 | return Create(updateFunc, functionName, active, false); 68 | } 69 | 70 | public static FunctionUpdater Create(Func updateFunc, string functionName, bool active, bool stopAllWithSameName) { 71 | InitIfNeeded(); 72 | 73 | if (stopAllWithSameName) { 74 | StopAllUpdatersWithName(functionName); 75 | } 76 | 77 | GameObject gameObject = new GameObject("FunctionUpdater Object " + functionName, typeof(MonoBehaviourHook)); 78 | FunctionUpdater functionUpdater = new FunctionUpdater(gameObject, updateFunc, functionName, active); 79 | gameObject.GetComponent().OnUpdate = functionUpdater.Update; 80 | 81 | updaterList.Add(functionUpdater); 82 | return functionUpdater; 83 | } 84 | 85 | private static void RemoveUpdater(FunctionUpdater funcUpdater) { 86 | InitIfNeeded(); 87 | updaterList.Remove(funcUpdater); 88 | } 89 | 90 | public static void DestroyUpdater(FunctionUpdater funcUpdater) { 91 | InitIfNeeded(); 92 | if (funcUpdater != null) { 93 | funcUpdater.DestroySelf(); 94 | } 95 | } 96 | 97 | public static void StopUpdaterWithName(string functionName) { 98 | InitIfNeeded(); 99 | for (int i = 0; i < updaterList.Count; i++) { 100 | if (updaterList[i].functionName == functionName) { 101 | updaterList[i].DestroySelf(); 102 | return; 103 | } 104 | } 105 | } 106 | 107 | public static void StopAllUpdatersWithName(string functionName) { 108 | InitIfNeeded(); 109 | for (int i = 0; i < updaterList.Count; i++) { 110 | if (updaterList[i].functionName == functionName) { 111 | updaterList[i].DestroySelf(); 112 | i--; 113 | } 114 | } 115 | } 116 | 117 | 118 | 119 | 120 | 121 | private GameObject gameObject; 122 | private string functionName; 123 | private bool active; 124 | private Func updateFunc; // Destroy Updater if return true; 125 | 126 | public FunctionUpdater(GameObject gameObject, Func updateFunc, string functionName, bool active) { 127 | this.gameObject = gameObject; 128 | this.updateFunc = updateFunc; 129 | this.functionName = functionName; 130 | this.active = active; 131 | } 132 | 133 | public void Pause() { 134 | active = false; 135 | } 136 | 137 | public void Resume() { 138 | active = true; 139 | } 140 | 141 | private void Update() { 142 | if (!active) return; 143 | if (updateFunc()) { 144 | DestroySelf(); 145 | } 146 | } 147 | 148 | public void DestroySelf() { 149 | RemoveUpdater(this); 150 | if (gameObject != null) { 151 | UnityEngine.Object.Destroy(gameObject); 152 | } 153 | } 154 | 155 | } 156 | 157 | } -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/FunctionUpdater.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7eacfbf662ad34e46932f36084c15e11 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/UI_Bar.cs: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------- Code Monkey ------------------- 3 | 4 | Thank you for downloading the Code Monkey Utilities 5 | I hope you find them useful in your projects 6 | If you have any questions use the contact form 7 | Cheers! 8 | 9 | unitycodemonkey.com 10 | -------------------------------------------------- 11 | */ 12 | 13 | using System; 14 | using UnityEngine; 15 | using UnityEngine.UI; 16 | 17 | namespace CodeMonkey.Utils { 18 | 19 | /* 20 | * Bar in the UI with scaleable Bar and Background 21 | * */ 22 | public class UI_Bar { 23 | 24 | public GameObject gameObject; 25 | private RectTransform rectTransform; 26 | private RectTransform background; 27 | private RectTransform bar; 28 | private Vector2 size; 29 | 30 | /* 31 | * Outline into for Bar 32 | * */ 33 | public class Outline { 34 | public float size = 1f; 35 | public Color color = Color.black; 36 | public Outline(float size, Color color) { 37 | this.size = size; 38 | this.color = color; 39 | } 40 | } 41 | 42 | public UI_Bar(GameObject gameObject, RectTransform background, RectTransform bar) { 43 | this.gameObject = gameObject; 44 | rectTransform = gameObject.GetComponent(); 45 | this.background = background; 46 | this.bar = bar; 47 | size = background.GetComponent().sizeDelta; 48 | } 49 | 50 | public UI_Bar(GameObject gameObject, Transform background, Transform bar) { 51 | this.gameObject = gameObject; 52 | rectTransform = gameObject.GetComponent(); 53 | this.background = background.GetComponent(); 54 | this.bar = bar.GetComponent(); 55 | size = background.GetComponent().sizeDelta; 56 | } 57 | 58 | public UI_Bar(Transform parent, Vector2 anchoredPosition, Vector2 size, Color barColor, float sizeRatio) { 59 | SetupParent(parent, anchoredPosition, size); 60 | SetupBar(barColor); 61 | SetSize(sizeRatio); 62 | } 63 | 64 | public UI_Bar(Transform parent, Vector2 anchoredPosition, Vector2 size, Color barColor, float sizeRatio, Outline outline) { 65 | SetupParent(parent, anchoredPosition, size); 66 | if (outline != null) SetupOutline(outline, size); 67 | SetupBar(barColor); 68 | SetSize(sizeRatio); 69 | } 70 | 71 | public UI_Bar(Transform parent, Vector2 anchoredPosition, Vector2 size, Color backgroundColor, Color barColor, float sizeRatio) { 72 | SetupParent(parent, anchoredPosition, size); 73 | SetupBackground(backgroundColor); 74 | SetupBar(barColor); 75 | SetSize(sizeRatio); 76 | } 77 | 78 | public UI_Bar(Transform parent, Vector2 anchoredPosition, Vector2 size, Color backgroundColor, Color barColor, float sizeRatio, Outline outline) { 79 | SetupParent(parent, anchoredPosition, size); 80 | if (outline != null) SetupOutline(outline, size); 81 | SetupBackground(backgroundColor); 82 | SetupBar(barColor); 83 | SetSize(sizeRatio); 84 | } 85 | 86 | private void SetupParent(Transform parent, Vector2 anchoredPosition, Vector2 size) { 87 | this.size = size; 88 | gameObject = new GameObject("UI_Bar", typeof(RectTransform)); 89 | rectTransform = gameObject.GetComponent(); 90 | rectTransform.SetParent(parent, false); 91 | rectTransform.sizeDelta = size; 92 | rectTransform.anchorMin = new Vector2(0, .5f); 93 | rectTransform.anchorMax = new Vector2(0, .5f); 94 | rectTransform.pivot = new Vector2(0, .5f); 95 | rectTransform.anchoredPosition = anchoredPosition; 96 | } 97 | 98 | private RectTransform SetupOutline(Outline outline, Vector2 size) { 99 | return UtilsClass.DrawSprite(outline.color, gameObject.transform, Vector2.zero, size + new Vector2(outline.size, outline.size), "Outline"); 100 | } 101 | 102 | private void SetupBackground(Color backgroundColor) { 103 | background = UtilsClass.DrawSprite(backgroundColor, gameObject.transform, Vector2.zero, Vector2.zero, "Background"); 104 | background.anchorMin = new Vector2(0,0); 105 | background.anchorMax = new Vector2(1,1); 106 | } 107 | 108 | private void SetupBar(Color barColor) { 109 | bar = UtilsClass.DrawSprite(barColor, gameObject.transform, Vector2.zero, Vector2.zero, "Bar"); 110 | bar.anchorMin = new Vector2(0,0); 111 | bar.anchorMax = new Vector2(0,1f); 112 | bar.pivot = new Vector2(0,.5f); 113 | } 114 | 115 | public void SetSize(float sizeRatio) { 116 | bar.sizeDelta = new Vector2(sizeRatio * size.x, 0f); 117 | } 118 | 119 | public void SetColor(Color color) { 120 | bar.GetComponent().color = color; 121 | } 122 | 123 | public void SetActive(bool active) { 124 | gameObject.SetActive(active); 125 | } 126 | 127 | public Vector2 GetAnchoredPosition() { 128 | return rectTransform.anchoredPosition; 129 | } 130 | 131 | public Vector2 GetSize() { 132 | return rectTransform.sizeDelta; 133 | } 134 | 135 | public void AddOutline(Outline outline) { 136 | RectTransform outlineRectTransform = SetupOutline(outline, size); 137 | outlineRectTransform.transform.SetAsFirstSibling(); 138 | } 139 | 140 | public void SetRaycastTarget(bool set) { 141 | foreach (Transform trans in gameObject.transform) { 142 | if (trans.GetComponent() != null) { 143 | trans.GetComponent().raycastTarget = set; 144 | } 145 | } 146 | } 147 | 148 | public void DestroySelf() { 149 | UnityEngine.Object.Destroy(gameObject); 150 | } 151 | 152 | public Button_UI AddButton() { 153 | return AddButton(null, null, null); 154 | } 155 | 156 | public Button_UI AddButton(Action ClickFunc, Action MouseOverOnceFunc, Action MouseOutOnceFunc) { 157 | Button_UI buttonUI = gameObject.AddComponent(); 158 | if (ClickFunc != null) 159 | buttonUI.ClickFunc = ClickFunc; 160 | if (MouseOverOnceFunc != null) 161 | buttonUI.MouseOverOnceFunc = MouseOverOnceFunc; 162 | if (MouseOutOnceFunc != null) 163 | buttonUI.MouseOutOnceFunc = MouseOutOnceFunc; 164 | return buttonUI; 165 | } 166 | 167 | } 168 | 169 | 170 | } 171 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/UI_Bar.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49ffd25ff4b0ca3429d1b1e2dc0ff037 3 | timeCreated: 1524300423 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/UI_BarMultiple.cs: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------- Code Monkey ------------------- 3 | 4 | Thank you for downloading the Code Monkey Utilities 5 | I hope you find them useful in your projects 6 | If you have any questions use the contact form 7 | Cheers! 8 | 9 | unitycodemonkey.com 10 | -------------------------------------------------- 11 | */ 12 | 13 | using System.Collections.Generic; 14 | using UnityEngine; 15 | using UnityEngine.UI; 16 | 17 | namespace CodeMonkey.Utils { 18 | 19 | /* 20 | * UI Container with multiple bars, useful for displaying one bar with multiple inner bars like success chance and failure chance 21 | * */ 22 | public class UI_BarMultiple { 23 | 24 | private GameObject gameObject; 25 | private RectTransform rectTransform; 26 | private RectTransform[] barArr; 27 | private Image[] barImageArr; 28 | private Vector2 size; 29 | 30 | public class Outline { 31 | public float size = 1f; 32 | public Color color = Color.black; 33 | public Outline(float size, Color color) { 34 | this.size = size; 35 | this.color = color; 36 | } 37 | } 38 | 39 | public UI_BarMultiple(Transform parent, Vector2 anchoredPosition, Vector2 size, Color[] barColorArr, Outline outline) { 40 | this.size = size; 41 | SetupParent(parent, anchoredPosition, size); 42 | if (outline != null) SetupOutline(outline, size); 43 | List barList = new List(); 44 | List barImageList = new List(); 45 | List defaultSizeList = new List(); 46 | foreach (Color color in barColorArr) { 47 | barList.Add(SetupBar(color)); 48 | defaultSizeList.Add(1f / barColorArr.Length); 49 | } 50 | barArr = barList.ToArray(); 51 | barImageArr = barImageList.ToArray(); 52 | SetSizes(defaultSizeList.ToArray()); 53 | } 54 | 55 | private void SetupParent(Transform parent, Vector2 anchoredPosition, Vector2 size) { 56 | gameObject = new GameObject("UI_BarMultiple", typeof(RectTransform)); 57 | rectTransform = gameObject.GetComponent(); 58 | rectTransform.SetParent(parent, false); 59 | rectTransform.sizeDelta = size; 60 | rectTransform.anchorMin = new Vector2(0, .5f); 61 | rectTransform.anchorMax = new Vector2(0, .5f); 62 | rectTransform.pivot = new Vector2(0, .5f); 63 | rectTransform.anchoredPosition = anchoredPosition; 64 | } 65 | 66 | private void SetupOutline(Outline outline, Vector2 size) { 67 | UtilsClass.DrawSprite(outline.color, gameObject.transform, Vector2.zero, size + new Vector2(outline.size, outline.size), "Outline"); 68 | } 69 | 70 | private RectTransform SetupBar(Color barColor) { 71 | RectTransform bar = UtilsClass.DrawSprite(barColor, gameObject.transform, Vector2.zero, Vector2.zero, "Bar"); 72 | bar.anchorMin = new Vector2(0,0); 73 | bar.anchorMax = new Vector2(0,1f); 74 | bar.pivot = new Vector2(0,.5f); 75 | return bar; 76 | } 77 | 78 | public void SetSizes(float[] sizeArr) { 79 | if (sizeArr.Length != barArr.Length) { 80 | throw new System.Exception("Length doesn't match!"); 81 | } 82 | Vector2 pos = Vector2.zero; 83 | for (int i=0; i= 1f) color.r = .9f; 72 | if (color.g >= 1f) color.g = .9f; 73 | if (color.b >= 1f) color.b = .9f; 74 | Color colorOver = color * 1.1f; // button over color lighter 75 | UI_Sprite uiSprite = new UI_Sprite(parent, Assets.i.s_White, anchoredPosition, size, color); 76 | uiSprite.AddButton(ClickFunc, () => uiSprite.SetColor(colorOver), () => uiSprite.SetColor(color)); 77 | uiTextComplex = new UI_TextComplex(uiSprite.gameObject.transform, Vector2.zero, 12, '#', text, null, null); 78 | uiTextComplex.SetTextColor(Color.black); 79 | uiTextComplex.SetAnchorMiddle(); 80 | uiTextComplex.CenterOnPosition(Vector2.zero); 81 | return uiSprite; 82 | } 83 | 84 | 85 | 86 | public GameObject gameObject; 87 | public Image image; 88 | public RectTransform rectTransform; 89 | 90 | 91 | public UI_Sprite(Transform parent, Sprite sprite, Vector2 anchoredPosition, Vector2 size, Color color) { 92 | rectTransform = UtilsClass.DrawSprite(sprite, parent, anchoredPosition, size, "UI_Sprite"); 93 | gameObject = rectTransform.gameObject; 94 | image = gameObject.GetComponent(); 95 | image.color = color; 96 | } 97 | 98 | public void SetColor(Color color) { 99 | image.color = color; 100 | } 101 | 102 | public void SetSprite(Sprite sprite) { 103 | image.sprite = sprite; 104 | } 105 | 106 | public void SetSize(Vector2 size) { 107 | rectTransform.sizeDelta = size; 108 | } 109 | 110 | public void SetAnchoredPosition(Vector2 anchoredPosition) { 111 | rectTransform.anchoredPosition = anchoredPosition; 112 | } 113 | 114 | public Button_UI AddButton(Action ClickFunc, Action MouseOverOnceFunc, Action MouseOutOnceFunc) { 115 | Button_UI buttonUI = gameObject.AddComponent(); 116 | if (ClickFunc != null) 117 | buttonUI.ClickFunc = ClickFunc; 118 | if (MouseOverOnceFunc != null) 119 | buttonUI.MouseOverOnceFunc = MouseOverOnceFunc; 120 | if (MouseOutOnceFunc != null) 121 | buttonUI.MouseOutOnceFunc = MouseOutOnceFunc; 122 | return buttonUI; 123 | } 124 | 125 | public void DestroySelf() { 126 | UnityEngine.Object.Destroy(gameObject); 127 | } 128 | 129 | } 130 | 131 | } -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/UI_Sprite.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d0052e8fbe8cbcd4d8c48038d364333b 3 | timeCreated: 1524300216 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/UI_TextComplex.cs: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------- Code Monkey ------------------- 3 | 4 | Thank you for downloading the Code Monkey Utilities 5 | I hope you find them useful in your projects 6 | If you have any questions use the contact form 7 | Cheers! 8 | 9 | unitycodemonkey.com 10 | -------------------------------------------------- 11 | */ 12 | 13 | using UnityEngine; 14 | using UnityEngine.UI; 15 | 16 | namespace CodeMonkey.Utils { 17 | 18 | /* 19 | * Displays text with icons in between the text 20 | * */ 21 | public class UI_TextComplex { 22 | 23 | private static Transform GetCanvasTransform() { 24 | return UtilsClass.GetCanvasTransform(); 25 | } 26 | 27 | public struct Icon { 28 | public Sprite sprite; 29 | public Vector2 size; 30 | public Color color; 31 | public Icon(Sprite sprite, Vector2 size, Color? color = null) { 32 | this.sprite = sprite; 33 | this.size = size; 34 | if (color == null) { 35 | this.color = Color.white; 36 | } else { 37 | this.color = (Color) color; 38 | } 39 | } 40 | } 41 | 42 | public GameObject gameObject; 43 | private Transform transform; 44 | private RectTransform rectTransform; 45 | 46 | // iconChar prepends the iconArr index; 47 | // Example using iconChar '#': 48 | // test #0 asdf 49 | // Displays "test [iconArr[0]] asdf" 50 | public UI_TextComplex(Transform parent, Vector2 anchoredPosition, int fontSize, char iconChar, string text, Icon[] iconArr, Font font) { 51 | SetupParent(parent, anchoredPosition); 52 | string tmp = text; 53 | float textPosition = 0f; 54 | while (tmp.IndexOf(iconChar) != -1) { 55 | string untilTmp = tmp.Substring(0, tmp.IndexOf(iconChar)); 56 | string iconNumber = tmp.Substring(tmp.IndexOf(iconChar)+1); 57 | int indexOfSpaceAfterIconNumber = iconNumber.IndexOf(" "); 58 | if (indexOfSpaceAfterIconNumber != -1) { 59 | // Still has more space after iconNumber 60 | iconNumber = iconNumber.Substring(0, indexOfSpaceAfterIconNumber); 61 | } else { 62 | // No more space after iconNumber 63 | } 64 | tmp = tmp.Substring(tmp.IndexOf(iconChar+iconNumber) + (iconChar+iconNumber).Length); 65 | if (untilTmp.Trim() != "") { 66 | Text uiText = UtilsClass.DrawTextUI(untilTmp, transform, new Vector2(textPosition,0), fontSize, font); 67 | textPosition += uiText.preferredWidth; 68 | } 69 | // Draw Icon 70 | int iconIndex = UtilsClass.Parse_Int(iconNumber, 0); 71 | Icon icon = iconArr[iconIndex]; 72 | UtilsClass.DrawSprite(icon.sprite, transform, new Vector2(textPosition + icon.size.x / 2f, 0), icon.size); 73 | textPosition += icon.size.x; 74 | } 75 | if (tmp.Trim() != "") { 76 | UtilsClass.DrawTextUI(tmp, transform, new Vector2(textPosition,0), fontSize, font); 77 | } 78 | } 79 | 80 | private void SetupParent(Transform parent, Vector2 anchoredPosition) { 81 | gameObject = new GameObject("UI_TextComplex", typeof(RectTransform)); 82 | transform = gameObject.transform; 83 | rectTransform = gameObject.GetComponent(); 84 | rectTransform.SetParent(parent, false); 85 | rectTransform.sizeDelta = new Vector2(0, 0); 86 | rectTransform.anchorMin = new Vector2(0, .5f); 87 | rectTransform.anchorMax = new Vector2(0, .5f); 88 | rectTransform.pivot = new Vector2(0, .5f); 89 | rectTransform.anchoredPosition = anchoredPosition; 90 | } 91 | 92 | public void SetTextColor(Color color) { 93 | foreach (Transform trans in transform) { 94 | Text text = trans.GetComponent(); 95 | if (text != null) { 96 | text.color = color; 97 | } 98 | } 99 | } 100 | 101 | public float GetTotalWidth() { 102 | float textPosition = 0f; 103 | foreach (Transform trans in transform) { 104 | Text text = trans.GetComponent(); 105 | if (text != null) { 106 | textPosition += text.preferredWidth; 107 | } 108 | Image image = trans.GetComponent(); 109 | if (image != null) { 110 | textPosition += image.GetComponent().sizeDelta.x; 111 | } 112 | } 113 | return textPosition; 114 | } 115 | 116 | public float GetTotalHeight() { 117 | foreach (Transform trans in transform) { 118 | Text text = trans.GetComponent(); 119 | if (text != null) { 120 | return text.preferredHeight; 121 | } 122 | } 123 | return 0f; 124 | } 125 | 126 | public void AddTextOutline(Color color, float size) { 127 | foreach (Transform textComplexTrans in transform) { 128 | if (textComplexTrans.GetComponent() != null) { 129 | Outline outline = textComplexTrans.gameObject.AddComponent(); 130 | outline.effectColor = color; 131 | outline.effectDistance = new Vector2(size, size); 132 | } 133 | } 134 | } 135 | 136 | public void SetAnchorMiddle() { 137 | rectTransform.anchorMin = new Vector2(.5f, .5f); 138 | rectTransform.anchorMax = new Vector2(.5f, .5f); 139 | } 140 | 141 | public void CenterOnPosition(Vector2 position) { 142 | rectTransform.anchoredPosition = position + new Vector2(-GetTotalWidth() / 2f, 0); 143 | } 144 | 145 | public void DestroySelf() { 146 | Object.Destroy(gameObject); 147 | } 148 | 149 | } 150 | 151 | } 152 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/UI_TextComplex.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8ba4b604c0e9db241bb3d130165415cd 3 | timeCreated: 1524300347 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/UtilsClass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce2355f335dcae94abba806390b1bd76 3 | timeCreated: 1524300728 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/World_Bar.cs: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------- Code Monkey ------------------- 3 | 4 | Thank you for downloading the Code Monkey Utilities 5 | I hope you find them useful in your projects 6 | If you have any questions use the contact form 7 | Cheers! 8 | 9 | unitycodemonkey.com 10 | -------------------------------------------------- 11 | */ 12 | 13 | using UnityEngine; 14 | 15 | namespace CodeMonkey.Utils { 16 | 17 | /* 18 | * Bar in the World, great for quickly making a health bar 19 | * */ 20 | public class World_Bar { 21 | 22 | private Outline outline; 23 | private GameObject gameObject; 24 | private Transform transform; 25 | private Transform background; 26 | private Transform bar; 27 | 28 | public static int GetSortingOrder(Vector3 position, int offset, int baseSortingOrder = 5000) { 29 | return (int)(baseSortingOrder - position.y) + offset; 30 | } 31 | 32 | public class Outline { 33 | public float size = 1f; 34 | public Color color = Color.black; 35 | } 36 | 37 | public static World_Bar Create(Vector3 localPosition, Vector3 localScale, Color? backgroundColor, Color barColor, float sizeRatio, Outline outline = null) { 38 | return Create(null, localPosition, localScale, backgroundColor, barColor, sizeRatio, 0, outline); 39 | } 40 | 41 | public static World_Bar Create(Transform parent, Vector3 localPosition, Vector3 localScale, Color? backgroundColor, Color barColor, float sizeRatio, int sortingOrder, Outline outline = null) { 42 | return new World_Bar(parent, localPosition, localScale, backgroundColor, barColor, sizeRatio, sortingOrder, outline); 43 | } 44 | 45 | public World_Bar(Transform parent, Vector3 localPosition, Vector3 localScale, Color? backgroundColor, Color barColor, float sizeRatio, int sortingOrder, Outline outline = null) { 46 | this.outline = outline; 47 | SetupParent(parent, localPosition); 48 | if (outline != null) SetupOutline(outline, localScale, sortingOrder - 1); 49 | if (backgroundColor != null) SetupBackground((Color)backgroundColor, localScale, sortingOrder); 50 | SetupBar(barColor, localScale, sortingOrder + 1); 51 | SetSize(sizeRatio); 52 | } 53 | 54 | private void SetupParent(Transform parent, Vector3 localPosition) { 55 | gameObject = new GameObject("World_Bar"); 56 | transform = gameObject.transform; 57 | transform.SetParent(parent); 58 | transform.localPosition = localPosition; 59 | } 60 | 61 | private void SetupOutline(Outline outline, Vector3 localScale, int sortingOrder) { 62 | UtilsClass.CreateWorldSprite(transform, "Outline", Assets.i.s_White, new Vector3(0,0), localScale + new Vector3(outline.size, outline.size), sortingOrder, outline.color); 63 | } 64 | 65 | private void SetupBackground(Color backgroundColor, Vector3 localScale, int sortingOrder) { 66 | background = UtilsClass.CreateWorldSprite(transform, "Background", Assets.i.s_White, new Vector3(0,0), localScale, sortingOrder, backgroundColor).transform; 67 | } 68 | 69 | private void SetupBar(Color barColor, Vector3 localScale, int sortingOrder) { 70 | GameObject barGO = new GameObject("Bar"); 71 | bar = barGO.transform; 72 | bar.SetParent(transform); 73 | bar.localPosition = new Vector3(-localScale.x / 2f, 0, 0); 74 | bar.localScale = new Vector3(1,1,1); 75 | Transform barIn = UtilsClass.CreateWorldSprite(bar, "BarIn", Assets.i.s_White, new Vector3(localScale.x / 2f, 0), localScale, sortingOrder, barColor).transform; 76 | } 77 | 78 | public void SetLocalScale(Vector3 localScale) { 79 | // Outline 80 | if (transform.Find("Outline") != null) { 81 | // Has outline 82 | transform.Find("Outline").localScale = localScale + new Vector3(outline.size, outline.size); 83 | } 84 | 85 | //Background 86 | background.localScale = localScale; 87 | 88 | // Set Bar Scale 89 | bar.localPosition = new Vector3(-localScale.x / 2f, 0, 0); 90 | Transform barIn = bar.Find("BarIn"); 91 | barIn.localScale = localScale; 92 | barIn.localPosition = new Vector3(localScale.x / 2f, 0); 93 | } 94 | 95 | public void SetSortingOrder(int sortingOrder) { 96 | bar.Find("BarIn").GetComponent().sortingOrder = sortingOrder; 97 | if (background != null) background.GetComponent().sortingOrder = sortingOrder - 1; 98 | if (transform.Find("Outline") != null) transform.Find("Outline").GetComponent().sortingOrder = sortingOrder - 2; 99 | } 100 | 101 | public void SetSortingLayerName(string sortingLayerName) { 102 | bar.Find("BarIn").GetComponent().sortingLayerName = sortingLayerName; 103 | if (background != null) background.GetComponent().sortingLayerName = sortingLayerName; 104 | if (transform.Find("Outline") != null) transform.Find("Outline").GetComponent().sortingLayerName = sortingLayerName; 105 | } 106 | 107 | public void SetRotation(float rotation) { 108 | transform.localEulerAngles = new Vector3(0, 0, rotation); 109 | } 110 | 111 | public void SetSize(float sizeRatio) { 112 | bar.localScale = new Vector3(sizeRatio, 1, 1); 113 | } 114 | 115 | public void SetColor(Color color) { 116 | bar.Find("BarIn").GetComponent().color = color; 117 | } 118 | 119 | public void SetActive(bool isActive) { 120 | gameObject.SetActive(isActive); 121 | } 122 | 123 | public void Show() { 124 | gameObject.SetActive(true); 125 | } 126 | 127 | public void Hide() { 128 | gameObject.SetActive(false); 129 | } 130 | 131 | public Button_Sprite AddButton(System.Action ClickFunc, System.Action MouseOverOnceFunc, System.Action MouseOutOnceFunc) { 132 | Button_Sprite buttonSprite = gameObject.AddComponent(); 133 | if (ClickFunc != null) 134 | buttonSprite.ClickFunc = ClickFunc; 135 | if (MouseOverOnceFunc != null) 136 | buttonSprite.MouseOverOnceFunc = MouseOverOnceFunc; 137 | if (MouseOutOnceFunc != null) 138 | buttonSprite.MouseOutOnceFunc = MouseOutOnceFunc; 139 | return buttonSprite; 140 | } 141 | 142 | public void DestroySelf() { 143 | if (gameObject != null) { 144 | Object.Destroy(gameObject); 145 | } 146 | } 147 | 148 | } 149 | 150 | } 151 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/World_Bar.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cc20fdc736e8c9442b35e4bcc04c596c 3 | timeCreated: 1524300272 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/World_Mesh.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91ce8dcaef210db41a183b4558f16bb2 3 | timeCreated: 1524300280 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/3rd/CodeMonkey/Utils/World_Sprite.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1460472c3006fb44daea959dda2c4d81 3 | timeCreated: 1524300280 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9d54400871b51034782185fc603a59c7 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Materials/AnchorMat.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: AnchorMat 11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 0, g: 1, b: 0, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | m_BuildTextureStacks: [] 79 | -------------------------------------------------------------------------------- /Assets/Materials/AnchorMat.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d54e3833222722c428c59798668eb3a5 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Materials/PreviewMaterial.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: PreviewMaterial 11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: _ALPHAPREMULTIPLY_ON 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: 3000 17 | stringTagMap: 18 | RenderType: Transparent 19 | disabledShaderPasses: [] 20 | m_SavedProperties: 21 | serializedVersion: 3 22 | m_TexEnvs: 23 | - _BumpMap: 24 | m_Texture: {fileID: 0} 25 | m_Scale: {x: 1, y: 1} 26 | m_Offset: {x: 0, y: 0} 27 | - _DetailAlbedoMap: 28 | m_Texture: {fileID: 0} 29 | m_Scale: {x: 1, y: 1} 30 | m_Offset: {x: 0, y: 0} 31 | - _DetailMask: 32 | m_Texture: {fileID: 0} 33 | m_Scale: {x: 1, y: 1} 34 | m_Offset: {x: 0, y: 0} 35 | - _DetailNormalMap: 36 | m_Texture: {fileID: 0} 37 | m_Scale: {x: 1, y: 1} 38 | m_Offset: {x: 0, y: 0} 39 | - _EmissionMap: 40 | m_Texture: {fileID: 0} 41 | m_Scale: {x: 1, y: 1} 42 | m_Offset: {x: 0, y: 0} 43 | - _MainTex: 44 | m_Texture: {fileID: 0} 45 | m_Scale: {x: 1, y: 1} 46 | m_Offset: {x: 0, y: 0} 47 | - _MetallicGlossMap: 48 | m_Texture: {fileID: 0} 49 | m_Scale: {x: 1, y: 1} 50 | m_Offset: {x: 0, y: 0} 51 | - _OcclusionMap: 52 | m_Texture: {fileID: 0} 53 | m_Scale: {x: 1, y: 1} 54 | m_Offset: {x: 0, y: 0} 55 | - _ParallaxMap: 56 | m_Texture: {fileID: 0} 57 | m_Scale: {x: 1, y: 1} 58 | m_Offset: {x: 0, y: 0} 59 | m_Floats: 60 | - _BumpScale: 1 61 | - _Cutoff: 0.5 62 | - _DetailNormalMapScale: 1 63 | - _DstBlend: 10 64 | - _GlossMapScale: 1 65 | - _Glossiness: 0.5 66 | - _GlossyReflections: 1 67 | - _Metallic: 0 68 | - _Mode: 3 69 | - _OcclusionStrength: 1 70 | - _Parallax: 0.02 71 | - _SmoothnessTextureChannel: 0 72 | - _SpecularHighlights: 1 73 | - _SrcBlend: 1 74 | - _UVSec: 0 75 | - _ZWrite: 0 76 | m_Colors: 77 | - _Color: {r: 1, g: 0.6666667, b: 1, a: 0.49019608} 78 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 79 | m_BuildTextureStacks: [] 80 | -------------------------------------------------------------------------------- /Assets/Materials/PreviewMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 039ea70837526f448a90b5782122b55b 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29aa0d4cec2470144a142dddb02a67b5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e0c02855deffc864a8be4591dc7e74c0 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8dfed6a613c5fae4f8753c3cd743c954 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/DOTween.XML.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34192c5e0d14aee43a0e86cc4823268a 3 | TextScriptImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/DOTween.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moecia/UnityGridBuildingSystem/7916aecb67e5aab6dce5870e67b28ab95d2ad425/Assets/Plugins/Demigiant/DOTween/DOTween.dll -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/DOTween.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a811bde74b26b53498b4f6d872b09b6d 3 | PluginImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | isPreloaded: 0 8 | platformData: 9 | Any: 10 | enabled: 1 11 | settings: {} 12 | Editor: 13 | enabled: 0 14 | settings: 15 | DefaultValueInitialized: true 16 | WindowsStoreApps: 17 | enabled: 0 18 | settings: 19 | CPU: AnyCPU 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b27f58ae5d5c33a4bb2d1f4f34bd036d 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Editor/DOTweenEditor.XML: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DOTweenEditor 5 | 6 | 7 | 8 | 9 | Starts the update loop of tween in the editor. Has no effect during playMode. 10 | 11 | Eventual callback to call after every update 12 | 13 | 14 | 15 | Stops the update loop and clears the onPreviewUpdated callback. 16 | 17 | If TRUE also resets the tweened objects to their original state 18 | 19 | 20 | 21 | Readies the tween for editor preview by setting its UpdateType to Manual plus eventual extra settings. 22 | 23 | The tween to ready 24 | If TRUE (recommended) removes all callbacks (OnComplete/Rewind/etc) 25 | If TRUE prevents the tween from being auto-killed at completion 26 | If TRUE starts playing the tween immediately 27 | 28 | 29 | Full major version + first minor version (ex: 2018.1f) 30 | 31 | 32 | Major version 33 | 34 | 35 | First minor version (ex: in 2018.1 it would be 1) 36 | 37 | 38 | 39 | Checks that the given editor texture use the correct import settings, 40 | and applies them if they're incorrect. 41 | 42 | 43 | 44 | 45 | Returns TRUE if setup is required 46 | 47 | 48 | 49 | 50 | Returns TRUE if the file/directory at the given path exists. 51 | 52 | Path, relative to Unity's project folder 53 | 54 | 55 | 56 | 57 | Converts the given project-relative path to a full path, 58 | with backward (\) slashes). 59 | 60 | 61 | 62 | 63 | Converts the given full path to a path usable with AssetDatabase methods 64 | (relative to Unity's project folder, and with the correct Unity forward (/) slashes). 65 | 66 | 67 | 68 | 69 | Connects to a asset. 70 | If the asset already exists at the given path, loads it and returns it. 71 | Otherwise, either returns NULL or automatically creates it before loading and returning it 72 | (depending on the given parameters). 73 | 74 | Asset type 75 | File path (relative to Unity's project folder) 76 | If TRUE and the requested asset doesn't exist, forces its creation 77 | 78 | 79 | 80 | Full path for the given loaded assembly, assembly file included 81 | 82 | 83 | 84 | 85 | Adds the given global define if it's not already present 86 | 87 | 88 | 89 | 90 | Removes the given global define if it's present 91 | 92 | 93 | 94 | 95 | Returns TRUE if the given global define is present in all the 96 | or only in the given , depending on passed parameters. 97 | 98 | 99 | to use. Leave NULL to check in all of them. 100 | 101 | 102 | 103 | Not used as menu item anymore, but as a utiity function 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Editor/DOTweenEditor.XML.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e2c6224d345d9249acfa6e8ef40bb2d 3 | TextScriptImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Editor/DOTweenEditor.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moecia/UnityGridBuildingSystem/7916aecb67e5aab6dce5870e67b28ab95d2ad425/Assets/Plugins/Demigiant/DOTween/Editor/DOTweenEditor.dll -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Editor/DOTweenEditor.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 45d5034162d6cf04dbe46da84fc7d074 3 | PluginImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | isPreloaded: 0 8 | platformData: 9 | Any: 10 | enabled: 0 11 | settings: {} 12 | Editor: 13 | enabled: 1 14 | settings: 15 | DefaultValueInitialized: true 16 | WindowsStoreApps: 17 | enabled: 0 18 | settings: 19 | CPU: AnyCPU 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Editor/Imgs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0034ebae0c2a9344e897db1160d71b6d 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Editor/Imgs/DOTweenIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moecia/UnityGridBuildingSystem/7916aecb67e5aab6dce5870e67b28ab95d2ad425/Assets/Plugins/Demigiant/DOTween/Editor/Imgs/DOTweenIcon.png -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Editor/Imgs/DOTweenIcon.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8da095e39e9b4df488dfd436f81116d6 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | seamlessCubemap: 0 24 | textureFormat: -3 25 | maxTextureSize: 128 26 | textureSettings: 27 | filterMode: 1 28 | aniso: 1 29 | mipBias: -1 30 | wrapMode: 1 31 | nPOTScale: 0 32 | lightmap: 0 33 | compressionQuality: 50 34 | spriteMode: 0 35 | spriteExtrude: 1 36 | spriteMeshType: 1 37 | alignment: 0 38 | spritePivot: {x: .5, y: .5} 39 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 40 | spritePixelsToUnits: 100 41 | alphaIsTransparency: 1 42 | textureType: 2 43 | buildTargetSettings: [] 44 | spriteSheet: 45 | sprites: [] 46 | spritePackingTag: 47 | userData: 48 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Editor/Imgs/Footer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moecia/UnityGridBuildingSystem/7916aecb67e5aab6dce5870e67b28ab95d2ad425/Assets/Plugins/Demigiant/DOTween/Editor/Imgs/Footer.png -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Editor/Imgs/Footer.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7051dba417b3d53409f2918f1ea4938d 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | seamlessCubemap: 0 24 | textureFormat: -3 25 | maxTextureSize: 256 26 | textureSettings: 27 | filterMode: 1 28 | aniso: 1 29 | mipBias: -1 30 | wrapMode: 1 31 | nPOTScale: 0 32 | lightmap: 0 33 | compressionQuality: 50 34 | spriteMode: 0 35 | spriteExtrude: 1 36 | spriteMeshType: 1 37 | alignment: 0 38 | spritePivot: {x: .5, y: .5} 39 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 40 | spritePixelsToUnits: 100 41 | alphaIsTransparency: 1 42 | textureType: 2 43 | buildTargetSettings: [] 44 | spriteSheet: 45 | sprites: [] 46 | spritePackingTag: 47 | userData: 48 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Editor/Imgs/Footer_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moecia/UnityGridBuildingSystem/7916aecb67e5aab6dce5870e67b28ab95d2ad425/Assets/Plugins/Demigiant/DOTween/Editor/Imgs/Footer_dark.png -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Editor/Imgs/Footer_dark.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 519694efe2bb2914788b151fbd8c01f4 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | vTOnly: 0 27 | grayScaleToAlpha: 0 28 | generateCubemap: 6 29 | cubemapConvolution: 0 30 | seamlessCubemap: 0 31 | textureFormat: -1 32 | maxTextureSize: 1024 33 | textureSettings: 34 | serializedVersion: 2 35 | filterMode: 1 36 | aniso: 1 37 | mipBias: 0 38 | wrapU: 1 39 | wrapV: 1 40 | wrapW: 1 41 | nPOTScale: 0 42 | lightmap: 0 43 | compressionQuality: 50 44 | spriteMode: 0 45 | spriteExtrude: 1 46 | spriteMeshType: 1 47 | alignment: 0 48 | spritePivot: {x: 0.5, y: 0.5} 49 | spritePixelsToUnits: 100 50 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 51 | spriteGenerateFallbackPhysicsShape: 1 52 | alphaUsage: 1 53 | alphaIsTransparency: 1 54 | spriteTessellationDetail: -1 55 | textureType: 2 56 | textureShape: 1 57 | singleChannelComponent: 0 58 | flipbookRows: 1 59 | flipbookColumns: 1 60 | maxTextureSizeSet: 0 61 | compressionQualitySet: 0 62 | textureFormatSet: 0 63 | ignorePngGamma: 0 64 | applyGammaDecoding: 1 65 | platformSettings: 66 | - serializedVersion: 3 67 | buildTarget: DefaultTexturePlatform 68 | maxTextureSize: 256 69 | resizeAlgorithm: 0 70 | textureFormat: -1 71 | textureCompression: 1 72 | compressionQuality: 50 73 | crunchedCompression: 0 74 | allowsAlphaSplitting: 0 75 | overridden: 0 76 | androidETC2FallbackOverride: 0 77 | forceMaximumCompressionQuality_BC6H_BC7: 0 78 | spriteSheet: 79 | serializedVersion: 2 80 | sprites: [] 81 | outline: [] 82 | physicsShape: [] 83 | bones: [] 84 | spriteID: 85 | internalID: 0 86 | vertices: [] 87 | indices: 88 | edges: [] 89 | weights: [] 90 | secondaryTextures: [] 91 | spritePackingTag: 92 | pSDRemoveMatte: 0 93 | pSDShowRemoveMatteOption: 0 94 | userData: 95 | assetBundleName: 96 | assetBundleVariant: 97 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Editor/Imgs/Header.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moecia/UnityGridBuildingSystem/7916aecb67e5aab6dce5870e67b28ab95d2ad425/Assets/Plugins/Demigiant/DOTween/Editor/Imgs/Header.jpg -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Editor/Imgs/Header.jpg.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78a59ca99f8987941adb61f9e14a06a7 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | seamlessCubemap: 0 24 | textureFormat: -3 25 | maxTextureSize: 512 26 | textureSettings: 27 | filterMode: 1 28 | aniso: 1 29 | mipBias: -1 30 | wrapMode: 1 31 | nPOTScale: 0 32 | lightmap: 0 33 | compressionQuality: 50 34 | spriteMode: 0 35 | spriteExtrude: 1 36 | spriteMeshType: 1 37 | alignment: 0 38 | spritePivot: {x: .5, y: .5} 39 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 40 | spritePixelsToUnits: 100 41 | alphaIsTransparency: 1 42 | textureType: 2 43 | buildTargetSettings: [] 44 | spriteSheet: 45 | sprites: [] 46 | spritePackingTag: 47 | userData: 48 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Modules.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 143604b8bad857d47a6f7cc7a533e2dc 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModuleAudio.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b766d08851589514b97afb23c6f30a70 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModulePhysics.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dae9aa560b4242648a3affa2bfabc365 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModulePhysics2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 230fe34542e175245ba74b4659dae700 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModuleSprite.cs: -------------------------------------------------------------------------------- 1 | // Author: Daniele Giardini - http://www.demigiant.com 2 | // Created: 2018/07/13 3 | 4 | #if true && (UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER) // MODULE_MARKER 5 | using System; 6 | using UnityEngine; 7 | using DG.Tweening.Core; 8 | using DG.Tweening.Plugins.Options; 9 | 10 | #pragma warning disable 1591 11 | namespace DG.Tweening 12 | { 13 | public static class DOTweenModuleSprite 14 | { 15 | #region Shortcuts 16 | 17 | #region SpriteRenderer 18 | 19 | /// Tweens a SpriteRenderer's color to the given value. 20 | /// Also stores the spriteRenderer as the tween's target so it can be used for filtered operations 21 | /// The end value to reachThe duration of the tween 22 | public static TweenerCore DOColor(this SpriteRenderer target, Color endValue, float duration) 23 | { 24 | TweenerCore t = DOTween.To(() => target.color, x => target.color = x, endValue, duration); 25 | t.SetTarget(target); 26 | return t; 27 | } 28 | 29 | /// Tweens a Material's alpha color to the given value. 30 | /// Also stores the spriteRenderer as the tween's target so it can be used for filtered operations 31 | /// The end value to reachThe duration of the tween 32 | public static TweenerCore DOFade(this SpriteRenderer target, float endValue, float duration) 33 | { 34 | TweenerCore t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration); 35 | t.SetTarget(target); 36 | return t; 37 | } 38 | 39 | /// Tweens a SpriteRenderer's color using the given gradient 40 | /// (NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener). 41 | /// Also stores the image as the tween's target so it can be used for filtered operations 42 | /// The gradient to useThe duration of the tween 43 | public static Sequence DOGradientColor(this SpriteRenderer target, Gradient gradient, float duration) 44 | { 45 | Sequence s = DOTween.Sequence(); 46 | GradientColorKey[] colors = gradient.colorKeys; 47 | int len = colors.Length; 48 | for (int i = 0; i < len; ++i) { 49 | GradientColorKey c = colors[i]; 50 | if (i == 0 && c.time <= 0) { 51 | target.color = c.color; 52 | continue; 53 | } 54 | float colorDuration = i == len - 1 55 | ? duration - s.Duration(false) // Verifies that total duration is correct 56 | : duration * (i == 0 ? c.time : c.time - colors[i - 1].time); 57 | s.Append(target.DOColor(c.color, colorDuration).SetEase(Ease.Linear)); 58 | } 59 | s.SetTarget(target); 60 | return s; 61 | } 62 | 63 | #endregion 64 | 65 | #region Blendables 66 | 67 | #region SpriteRenderer 68 | 69 | /// Tweens a SpriteRenderer's color to the given value, 70 | /// in a way that allows other DOBlendableColor tweens to work together on the same target, 71 | /// instead than fight each other as multiple DOColor would do. 72 | /// Also stores the SpriteRenderer as the tween's target so it can be used for filtered operations 73 | /// The value to tween toThe duration of the tween 74 | public static Tweener DOBlendableColor(this SpriteRenderer target, Color endValue, float duration) 75 | { 76 | endValue = endValue - target.color; 77 | Color to = new Color(0, 0, 0, 0); 78 | return DOTween.To(() => to, x => { 79 | Color diff = x - to; 80 | to = x; 81 | target.color += diff; 82 | }, endValue, duration) 83 | .Blendable().SetTarget(target); 84 | } 85 | 86 | #endregion 87 | 88 | #endregion 89 | 90 | #endregion 91 | } 92 | } 93 | #endif 94 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModuleSprite.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 188918ab119d93148aa0de59ccf5286b 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModuleUI.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a060394c03331a64392db53a10e7f2d1 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModuleUnityVersion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 63c02322328255542995bd02b47b0457 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModuleUtils.cs: -------------------------------------------------------------------------------- 1 | // Author: Daniele Giardini - http://www.demigiant.com 2 | // Created: 2018/07/13 3 | 4 | using System; 5 | using System.Reflection; 6 | using UnityEngine; 7 | using DG.Tweening.Core; 8 | using DG.Tweening.Plugins.Core.PathCore; 9 | using DG.Tweening.Plugins.Options; 10 | 11 | #pragma warning disable 1591 12 | namespace DG.Tweening 13 | { 14 | /// 15 | /// Utility functions that deal with available Modules. 16 | /// Modules defines: 17 | /// - DOTAUDIO 18 | /// - DOTPHYSICS 19 | /// - DOTPHYSICS2D 20 | /// - DOTSPRITE 21 | /// - DOTUI 22 | /// Extra defines set and used for implementation of external assets: 23 | /// - DOTWEEN_TMP ► TextMesh Pro 24 | /// - DOTWEEN_TK2D ► 2D Toolkit 25 | /// 26 | public static class DOTweenModuleUtils 27 | { 28 | static bool _initialized; 29 | 30 | #region Reflection 31 | 32 | /// 33 | /// Called via Reflection by DOTweenComponent on Awake 34 | /// 35 | #if UNITY_2018_1_OR_NEWER 36 | [UnityEngine.Scripting.Preserve] 37 | #endif 38 | public static void Init() 39 | { 40 | if (_initialized) return; 41 | 42 | _initialized = true; 43 | DOTweenExternalCommand.SetOrientationOnPath += Physics.SetOrientationOnPath; 44 | 45 | #if UNITY_EDITOR 46 | #if UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_1 47 | UnityEditor.EditorApplication.playmodeStateChanged += PlaymodeStateChanged; 48 | #else 49 | UnityEditor.EditorApplication.playModeStateChanged += PlaymodeStateChanged; 50 | #endif 51 | #endif 52 | } 53 | 54 | #if UNITY_2018_1_OR_NEWER 55 | #pragma warning disable 56 | [UnityEngine.Scripting.Preserve] 57 | // Just used to preserve methods when building, never called 58 | static void Preserver() 59 | { 60 | Assembly[] loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies(); 61 | MethodInfo mi = typeof(MonoBehaviour).GetMethod("Stub"); 62 | } 63 | #pragma warning restore 64 | #endif 65 | 66 | #endregion 67 | 68 | #if UNITY_EDITOR 69 | // Fires OnApplicationPause in DOTweenComponent even when Editor is paused (otherwise it's only fired at runtime) 70 | #if UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_1 71 | static void PlaymodeStateChanged() 72 | #else 73 | static void PlaymodeStateChanged(UnityEditor.PlayModeStateChange state) 74 | #endif 75 | { 76 | if (DOTween.instance == null) return; 77 | DOTween.instance.OnApplicationPause(UnityEditor.EditorApplication.isPaused); 78 | } 79 | #endif 80 | 81 | // █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ 82 | // ███ INTERNAL CLASSES ████████████████████████████████████████████████████████████████████████████████████████████████ 83 | // █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ 84 | 85 | public static class Physics 86 | { 87 | // Called via DOTweenExternalCommand callback 88 | public static void SetOrientationOnPath(PathOptions options, Tween t, Quaternion newRot, Transform trans) 89 | { 90 | #if true // PHYSICS_MARKER 91 | if (options.isRigidbody) ((Rigidbody)t.target).rotation = newRot; 92 | else trans.rotation = newRot; 93 | #else 94 | trans.rotation = newRot; 95 | #endif 96 | } 97 | 98 | // Returns FALSE if the DOTween's Physics2D Module is disabled, or if there's no Rigidbody2D attached 99 | public static bool HasRigidbody2D(Component target) 100 | { 101 | #if true // PHYSICS2D_MARKER 102 | return target.GetComponent() != null; 103 | #else 104 | return false; 105 | #endif 106 | } 107 | 108 | #region Called via Reflection 109 | 110 | 111 | // Called via Reflection by DOTweenPathInspector 112 | // Returns FALSE if the DOTween's Physics Module is disabled, or if there's no rigidbody attached 113 | #if UNITY_2018_1_OR_NEWER 114 | [UnityEngine.Scripting.Preserve] 115 | #endif 116 | public static bool HasRigidbody(Component target) 117 | { 118 | #if true // PHYSICS_MARKER 119 | return target.GetComponent() != null; 120 | #else 121 | return false; 122 | #endif 123 | } 124 | 125 | // Called via Reflection by DOTweenPath 126 | #if UNITY_2018_1_OR_NEWER 127 | [UnityEngine.Scripting.Preserve] 128 | #endif 129 | public static TweenerCore CreateDOTweenPathTween( 130 | MonoBehaviour target, bool tweenRigidbody, bool isLocal, Path path, float duration, PathMode pathMode 131 | ){ 132 | TweenerCore t; 133 | #if true // PHYSICS_MARKER 134 | Rigidbody rBody = tweenRigidbody ? target.GetComponent() : null; 135 | if (tweenRigidbody && rBody != null) { 136 | t = isLocal 137 | ? rBody.DOLocalPath(path, duration, pathMode) 138 | : rBody.DOPath(path, duration, pathMode); 139 | } else { 140 | t = isLocal 141 | ? target.transform.DOLocalPath(path, duration, pathMode) 142 | : target.transform.DOPath(path, duration, pathMode); 143 | } 144 | #else 145 | t = isLocal 146 | ? target.transform.DOLocalPath(path, duration, pathMode) 147 | : target.transform.DOPath(path, duration, pathMode); 148 | #endif 149 | return t; 150 | } 151 | 152 | #endregion 153 | } 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/Modules/DOTweenModuleUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7bcaf917d9cf5b84090421a5a2abe42e 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/readme.txt: -------------------------------------------------------------------------------- 1 | DOTween and DOTween Pro are copyright (c) 2014-2018 Daniele Giardini - Demigiant 2 | 3 | // IMPORTANT!!! ///////////////////////////////////////////// 4 | // Upgrading DOTween from versions older than 1.2.000 /////// 5 | // (or DOTween Pro older than 1.0.000) ////////////////////// 6 | ------------------------------------------------------------- 7 | If you're upgrading your project from a version of DOTween older than 1.2.000 (or DOTween Pro older than 1.0.000) please follow these instructions carefully. 8 | 1) Import the new version in the same folder as the previous one, overwriting old files. A lot of errors will appear but don't worry 9 | 2) Close and reopen Unity (and your project). This is fundamental: skipping this step will cause a bloodbath 10 | 3) Open DOTween's Utility Panel (Tools > Demigiant > DOTween Utility Panel) if it doesn't open automatically, then press "Setup DOTween...": this will run the upgrade setup 11 | 4) From the Add/Remove Modules panel that opens, activate/deactivate Modules for Unity systems and for external assets (Pro version only) 12 | 13 | // GET STARTED ////////////////////////////////////////////// 14 | 15 | - After importing a new DOTween update, select DOTween's Utility Panel from the "Tools/Demigiant" menu (if it doesn't open automatically) and press the "Setup DOTween..." button to activate/deactivate Modules. You can also access a Preferences Tab from there to choose default settings for DOTween. 16 | - In your code, add "using DG.Tweening" to each class where you want to use DOTween. 17 | - You're ready to tween. Check out the links below for full documentation and license info. 18 | 19 | 20 | // LINKS /////////////////////////////////////////////////////// 21 | 22 | DOTween website (documentation, examples, etc): http://dotween.demigiant.com 23 | DOTween license: http://dotween.demigiant.com/license.php 24 | DOTween repository (Google Code): https://code.google.com/p/dotween/ 25 | Demigiant website (documentation, examples, etc): http://www.demigiant.com 26 | 27 | // NOTES ////////////////////////////////////////////////////// 28 | 29 | - DOTween's Utility Panel can be found under "Tools > Demigiant > DOTween Utility Panel" and also contains other useful options, plus a tab to set DOTween's preferences -------------------------------------------------------------------------------- /Assets/Plugins/Demigiant/DOTween/readme.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fccfc62abf2eb0a4db614853430894fd 3 | TextScriptImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e7a70afe2c1c824eb1a3aca85c703fd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Prefabs/Cube 1x1.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 820274dddc414ab43a02a7078a58e829 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Prefabs/Cube 2x2.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fbb54b2d29154f243b4ddc0d79f34455 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9ea52a80d64d10248aa466884fc8a202 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Resources/DOTweenSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 16995157, guid: a811bde74b26b53498b4f6d872b09b6d, type: 3} 13 | m_Name: DOTweenSettings 14 | m_EditorClassIdentifier: 15 | useSafeMode: 1 16 | safeModeOptions: 17 | nestedTweenFailureBehaviour: 0 18 | timeScale: 1 19 | useSmoothDeltaTime: 0 20 | maxSmoothUnscaledTime: 0.15 21 | rewindCallbackMode: 0 22 | showUnityEditorReport: 0 23 | logBehaviour: 0 24 | drawGizmos: 1 25 | defaultRecyclable: 0 26 | defaultAutoPlay: 3 27 | defaultUpdateType: 0 28 | defaultTimeScaleIndependent: 0 29 | defaultEaseType: 6 30 | defaultEaseOvershootOrAmplitude: 1.70158 31 | defaultEasePeriod: 0 32 | defaultAutoKill: 1 33 | defaultLoopType: 0 34 | debugMode: 0 35 | debugStoreTargetId: 0 36 | showPreviewPanel: 1 37 | storeSettingsLocation: 0 38 | modules: 39 | showPanel: 0 40 | audioEnabled: 1 41 | physicsEnabled: 1 42 | physics2DEnabled: 1 43 | spriteEnabled: 1 44 | uiEnabled: 1 45 | textMeshProEnabled: 0 46 | tk2DEnabled: 0 47 | deAudioEnabled: 0 48 | deUnityExtendedEnabled: 0 49 | showPlayingTweens: 0 50 | showPausedTweens: 0 51 | -------------------------------------------------------------------------------- /Assets/Resources/DOTweenSettings.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 31f6dbd3337780344bb61d3276a81a24 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Resources/ScriptableObjects.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a8ec0a5143dace49babb063409bc2b1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Resources/ScriptableObjects/Cube 1x1_SO.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 5ab2088ca752ac14086b0161b4402499, type: 3} 13 | m_Name: Cube 1x1_SO 14 | m_EditorClassIdentifier: 15 | NameString: Cube 1x1 16 | Prefab: {fileID: 9034170397931973392, guid: 820274dddc414ab43a02a7078a58e829, type: 3} 17 | Width: 1 18 | Height: 1 19 | -------------------------------------------------------------------------------- /Assets/Resources/ScriptableObjects/Cube 1x1_SO.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 531d9fa050f6dd24493bc643c9550a89 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Resources/ScriptableObjects/Cube 2x2_SO.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 5ab2088ca752ac14086b0161b4402499, type: 3} 13 | m_Name: Cube 2x2_SO 14 | m_EditorClassIdentifier: 15 | NameString: Cube 2x2 16 | Prefab: {fileID: 2544116289532369352, guid: fbb54b2d29154f243b4ddc0d79f34455, type: 3} 17 | Width: 2 18 | Height: 2 19 | -------------------------------------------------------------------------------- /Assets/Resources/ScriptableObjects/Cube 2x2_SO.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9bca838ac561c2418f4e8b2a6dbe030 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce51056dfcf967845a2433e2bcc22456 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/SampleScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9fc0d4010bbf28b4594072e72b8655ab 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bce8b010c4ffefc46bcade7dd77b4f86 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts/Actor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 96179fcf00130004390a2c09243206f9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts/Actor/PathFindingMovementHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using PathFinding; 5 | using Grid; 6 | 7 | public class PathFindingMovementHandler : MonoBehaviour 8 | { 9 | [SerializeField] private float speed = 40f; 10 | [SerializeField] private float stopDistance = 1f; 11 | 12 | private int currentPathIndex; 13 | private List path; 14 | 15 | // Start is called before the first frame update 16 | void Start() 17 | { 18 | 19 | } 20 | 21 | // Update is called once per frame 22 | void Update() 23 | { 24 | if (!GridBuildingSystem.Instance.IsBuildingMode) 25 | { 26 | HandleMovement(); 27 | 28 | if (Input.GetMouseButtonDown(0)) 29 | { 30 | SetTargetPosition(MousePositionUtils.MouseToTerrainPosition()); 31 | } 32 | } 33 | } 34 | 35 | private void SetTargetPosition(Vector3 targetPosition) 36 | { 37 | currentPathIndex = 0; 38 | path = GridPathFinding.Instance.FindPath(transform.position, targetPosition); 39 | 40 | if (path != null && path.Count > 1) 41 | { 42 | path.RemoveAt(0); 43 | } 44 | } 45 | 46 | private void StopMoving() 47 | { 48 | path = null; 49 | } 50 | 51 | private void HandleMovement() 52 | { 53 | if (path != null) 54 | { 55 | var currPath = path[currentPathIndex]; 56 | var targetPosition = new Vector3(currPath.x, transform.position.y, currPath.z); 57 | 58 | for (int i = currentPathIndex; i < path.Count - 1; ++i) 59 | { 60 | Debug.DrawLine(new Vector3(path[i].x, transform.position.y, path[i].z), 61 | new Vector3(path[i + 1].x, transform.position.y, path[i + 1].z), 62 | Color.green); 63 | } 64 | 65 | if (Vector3.Distance(transform.position, targetPosition) > stopDistance) 66 | { 67 | var moveDir = (targetPosition - transform.position).normalized; 68 | transform.position = transform.position + moveDir * speed * Time.deltaTime; 69 | } 70 | else 71 | { 72 | currentPathIndex++; 73 | if (currentPathIndex >= path.Count) 74 | { 75 | StopMoving(); 76 | } 77 | } 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Assets/Scripts/Actor/PathFindingMovementHandler.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1143d6d492c195a41aac6ec829a370b0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/Building.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 293ce1f01ef0d854d94ef4e2302cd7ae 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts/Building/BuildingPreview.cs: -------------------------------------------------------------------------------- 1 | using Grid; 2 | using UnityEngine; 3 | using UnityEngine.AI; 4 | 5 | public class BuildingPreview : MonoBehaviour 6 | { 7 | [SerializeField] private Material previewMaterial; 8 | 9 | private Transform visual; 10 | private PlaceableObjectSO placeableObjectSO; 11 | private Mesh previewMesh; 12 | 13 | private void Start() 14 | { 15 | if (GridBuildingSystem.Instance.IsBuildingMode) 16 | { 17 | RefreshVisual(); 18 | } 19 | GridBuildingSystem.Instance.OnBuildingModeChanged += BuildingModeChangedHandler; 20 | } 21 | 22 | private void LateUpdate() 23 | { 24 | if (GridBuildingSystem.Instance.IsBuildingMode) 25 | { 26 | var targetPosition = GridBuildingSystem.Instance.GetMouseWorldSnappedPosition(); 27 | targetPosition.y = 1f; 28 | transform.position = Vector3.Lerp(transform.position, targetPosition, Time.deltaTime * 15f); 29 | transform.rotation = Quaternion.Lerp(transform.rotation, GridBuildingSystem.Instance.GetCurrentBuildingRotation(), Time.deltaTime * 15f); 30 | } 31 | } 32 | 33 | private void RefreshVisual() 34 | { 35 | DestroyPreview(); 36 | 37 | var placeableObjectSO = GridBuildingSystem.Instance.PlaceableObjectSO; 38 | if (placeableObjectSO != null) 39 | { 40 | visual = Instantiate(placeableObjectSO.Prefab.GetChild(0), Vector3.zero, Quaternion.identity); 41 | visual.parent = transform; 42 | visual.localPosition = Vector3.zero; 43 | visual.localEulerAngles = Vector3.zero; 44 | var meshes = visual.GetComponentsInChildren(); 45 | foreach (var mesh in meshes) 46 | { 47 | mesh.material = previewMaterial; 48 | } 49 | var navObstacles = visual.GetComponentsInChildren(); 50 | foreach (var navObstacle in navObstacles) 51 | { 52 | navObstacle.enabled = false; 53 | } 54 | } 55 | } 56 | 57 | private void DestroyPreview() 58 | { 59 | if (visual != null) 60 | { 61 | Destroy(visual.gameObject); 62 | visual = null; 63 | } 64 | } 65 | 66 | private void BuildingModeChangedHandler(bool IsBuildingMode) 67 | { 68 | if (IsBuildingMode) 69 | { 70 | RefreshVisual(); 71 | } 72 | else 73 | { 74 | DestroyPreview(); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Assets/Scripts/Building/BuildingPreview.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2937dcb9ec75f74991ecf1dbae7e5db 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/Building/PlaceableObject.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using DG.Tweening; 5 | 6 | public class PlaceableObject : MonoBehaviour 7 | { 8 | public PlaceableObjectSO placeableObjectSO; 9 | public PlaceableObjectSO.Dir dir; 10 | private Vector2Int origin; 11 | 12 | public static PlaceableObject Create(Vector3 worldPosition, Vector2Int origin, PlaceableObjectSO.Dir dir, PlaceableObjectSO placeableObjectSO) 13 | { 14 | var placedObjectTransform = Instantiate( 15 | placeableObjectSO.Prefab, 16 | worldPosition, 17 | Quaternion.Euler(0, placeableObjectSO.GetRotationAngle(dir), 0)); 18 | var placeableObject = placedObjectTransform.GetComponent(); 19 | 20 | placeableObject.placeableObjectSO = placeableObjectSO; 21 | placeableObject.origin = origin; 22 | placeableObject.dir = dir; 23 | 24 | // Build effects 25 | placedObjectTransform.DOShakeScale(.5f, .2f, 10, 90, true); 26 | 27 | return placeableObject; 28 | } 29 | 30 | public List GetGridPositionList() 31 | { 32 | return placeableObjectSO.GetGridPositionList(origin, dir); 33 | } 34 | 35 | public void DestroySelf() 36 | { 37 | Destroy(gameObject); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Assets/Scripts/Building/PlaceableObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a31fe8139c9d24e499d0102676cd5fc0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/Building/PlaceableObjectSO.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | [CreateAssetMenu()] 6 | public class PlaceableObjectSO : ScriptableObject 7 | { 8 | public static Dir GetNextDir(Dir dir) 9 | { 10 | switch (dir) 11 | { 12 | default: 13 | case Dir.Down: return Dir.Left; 14 | case Dir.Left: return Dir.Up; 15 | case Dir.Up: return Dir.Right; 16 | case Dir.Right: return Dir.Down; 17 | } 18 | } 19 | 20 | public enum Dir 21 | { 22 | Down, 23 | Left, 24 | Up, 25 | Right, 26 | } 27 | 28 | public string NameString; 29 | public Transform Prefab; 30 | public int Width; 31 | public int Height; 32 | 33 | 34 | public int GetRotationAngle(Dir dir) 35 | { 36 | switch (dir) 37 | { 38 | default: 39 | case Dir.Down: return 0; 40 | case Dir.Left: return 90; 41 | case Dir.Up: return 180; 42 | case Dir.Right: return 270; 43 | } 44 | } 45 | 46 | public Vector2Int GetRotationOffset(Dir dir) 47 | { 48 | switch (dir) 49 | { 50 | default: 51 | case Dir.Down: return new Vector2Int(0, 0); 52 | case Dir.Left: return new Vector2Int(0, Width); 53 | case Dir.Up: return new Vector2Int(Width, Height); 54 | case Dir.Right: return new Vector2Int(Height, 0); 55 | } 56 | } 57 | 58 | public List GetGridPositionList(Vector2Int offset, Dir dir) 59 | { 60 | List gridPositionList = new List(); 61 | switch (dir) 62 | { 63 | default: 64 | case Dir.Down: 65 | case Dir.Up: 66 | for (int x = 0; x < Width; x++) 67 | { 68 | for (int y = 0; y < Height; y++) 69 | { 70 | gridPositionList.Add(offset + new Vector2Int(x, y)); 71 | } 72 | } 73 | break; 74 | case Dir.Left: 75 | case Dir.Right: 76 | for (int x = 0; x < Height; x++) 77 | { 78 | for (int y = 0; y < Width; y++) 79 | { 80 | gridPositionList.Add(offset + new Vector2Int(x, y)); 81 | } 82 | } 83 | break; 84 | } 85 | return gridPositionList; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Assets/Scripts/Building/PlaceableObjectSO.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ab2088ca752ac14086b0161b4402499 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/Grid.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53051d2562704744693a7c1ec850d007 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts/Grid/GridBuildingSystem.cs: -------------------------------------------------------------------------------- 1 | using CodeMonkey.Utils; 2 | using PathFinding; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using UnityEngine; 9 | 10 | namespace Grid 11 | { 12 | public class GridBuildingSystem : Singleton, IDisposable 13 | { 14 | public PlaceableObjectSO PlaceableObjectSO; 15 | public int rowCount = 10; 16 | public int columnCount = 10; 17 | public int cellSize = 5; 18 | public Vector3 StartOrigin = Vector3.zero; 19 | public bool ShowDebug = false; 20 | 21 | public Action OnSelectChanged; 22 | public Action OnBuildingModeChanged; 23 | 24 | public bool IsBuildingMode { get; set; } = false; 25 | 26 | private GridXZ grid; 27 | private PlaceableObjectSO.Dir dir = PlaceableObjectSO.Dir.Down; 28 | 29 | private GridPathFinding pf; 30 | 31 | public override void Awake() 32 | { 33 | base.Awake(); 34 | 35 | grid = new GridXZ(rowCount, 36 | columnCount, 37 | cellSize, 38 | StartOrigin, 39 | (GridXZ g, int x, int z) => new GridObject(g, x, z), 40 | ShowDebug); 41 | pf = new GridPathFinding(grid); 42 | } 43 | 44 | private void Update() 45 | { 46 | if (Input.GetKeyDown(KeyCode.B)) 47 | { 48 | IsBuildingMode = !IsBuildingMode; 49 | OnBuildingModeChanged.Invoke(IsBuildingMode); 50 | } 51 | 52 | if (IsBuildingMode) 53 | { 54 | if (Input.GetMouseButtonDown(0)) 55 | { 56 | var mousePosition = MousePositionUtils.MouseToTerrainPosition(); 57 | grid.GetXZ(mousePosition, out int x, out int z); 58 | 59 | PlaceBuilding(PlaceableObjectSO, x, z, dir); 60 | } 61 | 62 | if (Input.GetMouseButtonDown(1)) 63 | { 64 | var gridObject = grid.GetGridObject(MousePositionUtils.MouseToTerrainPosition()); 65 | var placedObject = gridObject.PlaceableObject; 66 | if (placedObject != null) 67 | { 68 | placedObject.DestroySelf(); 69 | var gridPosList = placedObject.GetGridPositionList(); 70 | foreach (var gridPos in gridPosList) 71 | { 72 | grid.GetGridObject(gridPos.x, gridPos.y).PlaceableObject = placedObject; 73 | } 74 | } 75 | } 76 | 77 | if (Input.GetKeyDown(KeyCode.R)) 78 | { 79 | dir = PlaceableObjectSO.GetNextDir(dir); 80 | } 81 | } 82 | } 83 | 84 | private void OnDestroy() 85 | { 86 | Dispose(); 87 | } 88 | 89 | private void PlaceBuilding(PlaceableObjectSO placeableObjectSO, int x, int z, PlaceableObjectSO.Dir direction) 90 | { 91 | var gridPosList = placeableObjectSO.GetGridPositionList(new Vector2Int(x, z), dir); 92 | var canBuild = true; 93 | foreach (var gridPos in gridPosList) 94 | { 95 | if (!grid.GetGridObject(gridPos.x, gridPos.y).CanBuild) 96 | { 97 | canBuild = false; 98 | break; 99 | } 100 | } 101 | if (canBuild) 102 | { 103 | var rotOffset = placeableObjectSO.GetRotationOffset(dir); 104 | var placedWorldPos = grid.GetWorldPosition(x, z) + new Vector3(rotOffset.x, 0, rotOffset.y) * grid.CellSize; 105 | 106 | var placedObject = PlaceableObject.Create( 107 | placedWorldPos, 108 | new Vector2Int(x, z), dir, 109 | placeableObjectSO); 110 | foreach (var gridPos in gridPosList) 111 | { 112 | var gridTobuild = grid.GetGridObject(gridPos.x, gridPos.y); 113 | gridTobuild.PlaceableObject = placedObject; 114 | gridTobuild.PlaceableObjectName = placedObject.placeableObjectSO.NameString; 115 | gridTobuild.Direction = placedObject.dir; 116 | } 117 | } 118 | else 119 | { 120 | UtilsClass.CreateWorldTextPopup("Cannot build here", grid.GetWorldPosition(x, z)); 121 | } 122 | } 123 | 124 | public Quaternion GetCurrentBuildingRotation() 125 | { 126 | if (PlaceableObjectSO != null) 127 | { 128 | return Quaternion.Euler(0, PlaceableObjectSO.GetRotationAngle(dir), 0); 129 | } 130 | else 131 | { 132 | return Quaternion.identity; 133 | } 134 | } 135 | 136 | public Vector3 GetMouseWorldSnappedPosition() 137 | { 138 | var mousePosition = MousePositionUtils.MouseToTerrainPosition(); 139 | grid.GetXZ(mousePosition, out int x, out int z); 140 | 141 | if (PlaceableObjectSO != null) 142 | { 143 | var rotationOffset = PlaceableObjectSO.GetRotationOffset(dir); 144 | return grid.GetWorldPosition(x, z) + new Vector3(rotationOffset.x, 0, rotationOffset.y) * grid.CellSize; 145 | } 146 | else 147 | { 148 | return mousePosition; 149 | } 150 | } 151 | 152 | public void SaveGrid() 153 | { 154 | SaveSystem.SaveObject("grid", grid); 155 | } 156 | 157 | public void LoadGrid() 158 | { 159 | foreach (var gridObject in grid.GridArray) 160 | { 161 | if (gridObject.PlaceableObject != null) 162 | { 163 | gridObject.PlaceableObject.DestroySelf(); 164 | gridObject.ClearPlaceableObject(); 165 | } 166 | } 167 | RebuildGrid(); 168 | pf = new GridPathFinding(grid); 169 | } 170 | 171 | public void RebuildGrid() 172 | { 173 | var g = SaveSystem.LoadSavedObject>("grid"); 174 | this.grid = new GridXZ(g.Width, 175 | g.Height, 176 | g.CellSize, 177 | StartOrigin, 178 | (GridXZ g, int x, int z) => new GridObject(g, x, z), 179 | ShowDebug); 180 | foreach (var gridObject in g.GridArray) 181 | { 182 | var name = gridObject.PlaceableObjectName; 183 | if (!String.IsNullOrEmpty(name)) 184 | { 185 | var placeableObjectSO = Resources.Load($"ScriptableObjects/{name}_SO"); 186 | PlaceBuilding(placeableObjectSO, gridObject.x, gridObject.z, gridObject.Direction); 187 | } 188 | } 189 | } 190 | 191 | public void Dispose() 192 | { 193 | for (int i = 0; i < grid.GridArray.GetLength(0); i++) 194 | { 195 | for (int j = 0; j < grid.GridArray.GetLength(1); j++) 196 | { 197 | grid.GridArray[i, j] = null; 198 | } 199 | } 200 | grid.GridArray = null; 201 | grid = null; 202 | } 203 | } 204 | } -------------------------------------------------------------------------------- /Assets/Scripts/Grid/GridBuildingSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22ec9857ceb8c93418abaa4464d1d49a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/Grid/GridObject.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Grid 4 | { 5 | public class GridObject 6 | { 7 | public bool CanBuild { get { return placeableObject == null; } } 8 | [JsonIgnore] 9 | public PlaceableObject PlaceableObject 10 | { 11 | get => placeableObject; 12 | set 13 | { 14 | IsWalkable = false; 15 | placeableObject = value; 16 | grid.TriggerGridObjectChanged(x, z); 17 | } 18 | } 19 | public int x; 20 | public int z; 21 | public string PlaceableObjectName; 22 | public PlaceableObjectSO.Dir Direction; 23 | 24 | private GridXZ grid; 25 | private PlaceableObject placeableObject; 26 | 27 | // Path Finding 28 | // Cost from the start node 29 | [JsonIgnore] 30 | public int G; 31 | // Heuristic cost to reach the end node(won't consider obstacle) 32 | [JsonIgnore] 33 | public int H; 34 | [JsonIgnore] 35 | public int F; 36 | [JsonIgnore] 37 | public GridObject CameFromNode; 38 | [JsonIgnore] 39 | public bool IsWalkable; 40 | 41 | public GridObject(GridXZ grid, int x, int z) 42 | { 43 | this.grid = grid; 44 | this.x = x; 45 | this.z = z; 46 | IsWalkable = true; 47 | } 48 | 49 | public override string ToString() 50 | { 51 | return $"{x}, {z}"; 52 | } 53 | 54 | public void CalculateFCost() 55 | { 56 | F = G + H; 57 | } 58 | 59 | public void ClearPlaceableObject() 60 | { 61 | IsWalkable = true; 62 | placeableObject = null; 63 | PlaceableObjectName = null; 64 | Direction = PlaceableObjectSO.Dir.Down; 65 | grid.TriggerGridObjectChanged(x, z); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Assets/Scripts/Grid/GridObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83ccea95185b6a444a5862b78addde74 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/Grid/GridXZ.cs: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------- Code Monkey ------------------- 3 | 4 | Thank you for downloading this package 5 | I hope you find it useful in your projects 6 | If you have any questions let me know 7 | Cheers! 8 | 9 | unitycodemonkey.com 10 | -------------------------------------------------- 11 | */ 12 | 13 | using System; 14 | using System.Collections; 15 | using System.Collections.Generic; 16 | using UnityEngine; 17 | using CodeMonkey.Utils; 18 | using Newtonsoft.Json; 19 | 20 | public class GridXZ 21 | { 22 | 23 | public event EventHandler OnGridObjectChanged; 24 | public class OnGridObjectChangedEventArgs : EventArgs 25 | { 26 | public int x; 27 | public int z; 28 | } 29 | 30 | public TGridObject[,] GridArray; 31 | public int Width; 32 | public int Height; 33 | public float CellSize; 34 | [JsonIgnore] 35 | public TextMesh[,] DebugTextArray { get; private set; } 36 | private Vector3 originPosition; 37 | 38 | public GridXZ() { } 39 | 40 | public GridXZ(int width, int height, float cellSize, Vector3 originPosition, Func, int, int, TGridObject> createGridObject, bool showDebug) 41 | { 42 | this.Width = width; 43 | this.Height = height; 44 | this.CellSize = cellSize; 45 | this.originPosition = originPosition; 46 | 47 | GridArray = new TGridObject[width, height]; 48 | 49 | for (int x = 0; x < GridArray.GetLength(0); x++) 50 | { 51 | for (int z = 0; z < GridArray.GetLength(1); z++) 52 | { 53 | GridArray[x, z] = createGridObject(this, x, z); 54 | } 55 | } 56 | 57 | if (showDebug) 58 | { 59 | InitializeDebugTextArray(width, height, cellSize); 60 | } 61 | } 62 | 63 | public void InitializeDebugTextArray(int width, int height, float cellSize) 64 | { 65 | DebugTextArray = new TextMesh[width, height]; 66 | for (int x = 0; x < GridArray.GetLength(0); x++) 67 | { 68 | for (int z = 0; z < GridArray.GetLength(1); z++) 69 | { 70 | DebugTextArray[x, z] = UtilsClass.CreateWorldText(GridArray[x, z]?.ToString(), null, GetWorldPosition(x, z) + new Vector3(cellSize, 0, cellSize) * .5f, 15, Color.white, TextAnchor.MiddleCenter, TextAlignment.Center); 71 | Debug.DrawLine(GetWorldPosition(x, z), GetWorldPosition(x, z + 1), Color.white, 100f); 72 | Debug.DrawLine(GetWorldPosition(x, z), GetWorldPosition(x + 1, z), Color.white, 100f); 73 | } 74 | } 75 | Debug.DrawLine(GetWorldPosition(0, height), GetWorldPosition(width, height), Color.white, 100f); 76 | Debug.DrawLine(GetWorldPosition(width, 0), GetWorldPosition(width, height), Color.white, 100f); 77 | 78 | OnGridObjectChanged += (object sender, OnGridObjectChangedEventArgs eventArgs) => 79 | { 80 | DebugTextArray[eventArgs.x, eventArgs.z].text = GridArray[eventArgs.x, eventArgs.z]?.ToString(); 81 | }; 82 | } 83 | 84 | public void SetDebugText(int x, int z, string text) 85 | { 86 | DebugTextArray[x, z].text = text; 87 | } 88 | 89 | public Vector3 GetWorldPosition(int x, int z) 90 | { 91 | return new Vector3(x, 0, z) * CellSize + originPosition; 92 | } 93 | 94 | public void GetXZ(Vector3 worldPosition, out int x, out int z) 95 | { 96 | x = Mathf.FloorToInt((worldPosition - originPosition).x / CellSize); 97 | z = Mathf.FloorToInt((worldPosition - originPosition).z / CellSize); 98 | } 99 | 100 | public void SetGridObject(int x, int z, TGridObject value) 101 | { 102 | if (x >= 0 && z >= 0 && x < Width && z < Height) 103 | { 104 | GridArray[x, z] = value; 105 | TriggerGridObjectChanged(x, z); 106 | } 107 | } 108 | 109 | public void TriggerGridObjectChanged(int x, int z) 110 | { 111 | OnGridObjectChanged?.Invoke(this, new OnGridObjectChangedEventArgs { x = x, z = z }); 112 | } 113 | 114 | public void SetGridObject(Vector3 worldPosition, TGridObject value) 115 | { 116 | GetXZ(worldPosition, out int x, out int z); 117 | SetGridObject(x, z, value); 118 | } 119 | 120 | public TGridObject GetGridObject(int x, int z) 121 | { 122 | if (x >= 0 && z >= 0 && x < Width && z < Height) 123 | { 124 | return GridArray[x, z]; 125 | } 126 | else 127 | { 128 | return default(TGridObject); 129 | } 130 | } 131 | 132 | public TGridObject GetGridObject(Vector3 worldPosition) 133 | { 134 | int x, z; 135 | GetXZ(worldPosition, out x, out z); 136 | return GetGridObject(x, z); 137 | } 138 | 139 | public Vector2Int ValidateGridPosition(Vector2Int gridPosition) 140 | { 141 | return new Vector2Int( 142 | Mathf.Clamp(gridPosition.x, 0, Width - 1), 143 | Mathf.Clamp(gridPosition.y, 0, Height - 1) 144 | ); 145 | } 146 | 147 | } -------------------------------------------------------------------------------- /Assets/Scripts/Grid/GridXZ.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2c69a735a5d42b74f81d6765d3dce1a6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/PathFinding.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cbedeff627465994ea235f8647d36591 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts/PathFinding/GridPathFinding.cs: -------------------------------------------------------------------------------- 1 | using Grid; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | namespace PathFinding 7 | { 8 | public class GridPathFinding 9 | { 10 | public static GridPathFinding Instance { get; private set; } 11 | 12 | public GridXZ Grid { get; private set; } 13 | 14 | private const int MOVE_STRAIGHT_COST = 10; 15 | private const int MOVE_DIAGONAL_COST = 14; 16 | 17 | private List openList; 18 | private List closeList; 19 | 20 | public GridPathFinding(GridXZ grid) 21 | { 22 | Instance = this; 23 | Grid = grid; 24 | } 25 | 26 | public List FindPath(int startX, int startZ, int endX, int endZ) 27 | { 28 | var startNode = Grid.GetGridObject(startX, startZ); 29 | var endNode = Grid.GetGridObject(endX, endZ); 30 | 31 | openList = new List { startNode }; 32 | closeList = new List(); 33 | 34 | // Init nodes 35 | for (int x = 0; x < Grid.Width; ++x) 36 | { 37 | for (int z = 0; z < Grid.Height; ++z) 38 | { 39 | var pathNode = Grid.GetGridObject(x, z); 40 | pathNode.G = int.MaxValue; 41 | pathNode.CalculateFCost(); 42 | pathNode.CameFromNode = null; 43 | } 44 | } 45 | 46 | startNode.G = 0; 47 | startNode.H = CalculateDistanceCost(startNode, endNode); 48 | 49 | while (openList.Count > 0) 50 | { 51 | var currNode = GetLowestFCostNode(openList); 52 | if (currNode == endNode) 53 | { 54 | return CalculatePath(endNode); 55 | } 56 | 57 | openList.Remove(currNode); 58 | closeList.Add(currNode); 59 | 60 | var neightbhourNodes = GetNeighbourList(currNode); 61 | foreach (var neighbourNode in neightbhourNodes) 62 | { 63 | if (closeList.Contains(neighbourNode)) continue; 64 | if (!neighbourNode.IsWalkable) 65 | { 66 | closeList.Add(neighbourNode); 67 | continue; 68 | } 69 | 70 | int tentativeGCost = currNode.G + CalculateDistanceCost(currNode, neighbourNode); 71 | if (tentativeGCost < neighbourNode.G) 72 | { 73 | neighbourNode.CameFromNode = currNode; 74 | neighbourNode.G = tentativeGCost; 75 | neighbourNode.H = CalculateDistanceCost(neighbourNode, endNode); 76 | neighbourNode.CalculateFCost(); 77 | 78 | if (!openList.Contains(neighbourNode)) 79 | { 80 | openList.Add(neighbourNode); 81 | } 82 | } 83 | } 84 | } 85 | 86 | return null; 87 | } 88 | 89 | public List FindPath(Vector3 startWorldPostion, Vector3 endWorldPosition) 90 | { 91 | Grid.GetXZ(startWorldPostion, out int startX, out int startZ); 92 | Grid.GetXZ(endWorldPosition, out int endX, out int endZ); 93 | 94 | var path = FindPath(startX, startZ, endX, endZ); 95 | 96 | if (path == null) 97 | { 98 | return null; 99 | } 100 | else 101 | { 102 | var vectorPath = new List(); 103 | foreach (var pathNode in path) 104 | { 105 | vectorPath.Add(new Vector3(pathNode.x, 0, pathNode.z) * Grid.CellSize + Vector3.one * Grid.CellSize * .5f); 106 | } 107 | return vectorPath; 108 | } 109 | } 110 | 111 | public GridObject GetNode(int x, int y) 112 | { 113 | return Grid.GetGridObject(x, y); 114 | } 115 | 116 | private int CalculateDistanceCost(GridObject a, GridObject b) 117 | { 118 | int xDist = Mathf.Abs(a.x - b.x); 119 | int zDist = Mathf.Abs(a.z - b.z); 120 | int remaining = Mathf.Abs(xDist - zDist); 121 | return MOVE_DIAGONAL_COST * Mathf.Min(xDist, zDist) + MOVE_STRAIGHT_COST * remaining; 122 | } 123 | 124 | private GridObject GetLowestFCostNode(List pathNodeList) 125 | { 126 | var lowestFCostNode = pathNodeList[0]; 127 | for (int i = 0; i < pathNodeList.Count; ++i) 128 | { 129 | if (pathNodeList[i].F < lowestFCostNode.F) 130 | { 131 | lowestFCostNode = pathNodeList[i]; 132 | } 133 | } 134 | return lowestFCostNode; 135 | } 136 | 137 | private List CalculatePath(GridObject endNode) 138 | { 139 | var path = new List(); 140 | 141 | path.Add(endNode); 142 | var currNode = endNode; 143 | while (currNode.CameFromNode != null) 144 | { 145 | path.Add(currNode.CameFromNode); 146 | currNode = currNode.CameFromNode; 147 | } 148 | path.Reverse(); 149 | return path; 150 | } 151 | 152 | private List GetNeighbourList(GridObject currNode) 153 | { 154 | var neighbours = new List(); 155 | 156 | if (currNode.x - 1 >= 0) 157 | { 158 | // Left 159 | neighbours.Add(GetNode(currNode.x - 1, currNode.z)); 160 | // Left Down 161 | if (currNode.z - 1 >= 0) neighbours.Add(GetNode(currNode.x - 1, currNode.z - 1)); 162 | // Left Up 163 | if (currNode.z + 1 < Grid.Height) neighbours.Add(GetNode(currNode.x - 1, currNode.z + 1)); 164 | } 165 | if (currNode.x + 1 < Grid.Width) 166 | { 167 | // Right 168 | neighbours.Add(GetNode(currNode.x + 1, currNode.z)); 169 | // Right Down 170 | if (currNode.z - 1 >= 0) neighbours.Add(GetNode(currNode.x + 1, currNode.z - 1)); 171 | // Right Up 172 | if (currNode.z + 1 < Grid.Height) neighbours.Add(GetNode(currNode.x + 1, currNode.z + 1)); 173 | } 174 | // Up 175 | if (currNode.z + 1 < Grid.Width) neighbours.Add(GetNode(currNode.x, currNode.z + 1)); 176 | // Down 177 | if (currNode.z - 1 >= 0) neighbours.Add(GetNode(currNode.x, currNode.z - 1)); 178 | 179 | return neighbours; 180 | } 181 | } 182 | 183 | } -------------------------------------------------------------------------------- /Assets/Scripts/PathFinding/GridPathFinding.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c2414c1c9cb2ea4418312af3c3faf92a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/Utils.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e0574f4ad489b094390a56ec4043a333 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts/Utils/MousePositionUtils.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public static class MousePositionUtils 4 | { 5 | public static Vector3 MouseToTerrainPosition() 6 | { 7 | Vector3 position = Vector3.zero; 8 | var ray = Camera.main.ScreenPointToRay(Input.mousePosition); 9 | if (Physics.Raycast(ray, out RaycastHit info, 10000, LayerMask.GetMask("Level"))) 10 | { 11 | position = info.point; 12 | } 13 | return position; 14 | } 15 | 16 | public static RaycastHit CameraRay() 17 | { 18 | var ray = Camera.main.ScreenPointToRay(Input.mousePosition); 19 | if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit info)) 20 | { 21 | return info; 22 | } 23 | return new RaycastHit(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Assets/Scripts/Utils/MousePositionUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d08e38c69193a6949bfad2f6a74eb1ad 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/Utils/SaveSystem.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using UnityEngine; 6 | 7 | public class SaveSystem 8 | { 9 | public static void SaveFile(string filename, string saveData) 10 | { 11 | var savePath = Path.Combine(Application.persistentDataPath, $"{filename}.json"); 12 | var fileStream = new FileStream(savePath, FileMode.Create); 13 | 14 | using (var writer = new StreamWriter(fileStream)) 15 | { 16 | writer.Write(saveData); 17 | } 18 | } 19 | 20 | public static string LoadFile(string filename) 21 | { 22 | var savePath = Path.Combine(Application.persistentDataPath, $"{filename}.json"); 23 | if (File.Exists(savePath)) 24 | { 25 | using(var reader = new StreamReader(savePath)) 26 | { 27 | return reader.ReadToEnd(); 28 | } 29 | } 30 | else 31 | { 32 | Debug.LogError("Cannot find the save file!"); 33 | } 34 | return null; 35 | } 36 | 37 | public static void SaveObject(string filename, object saveData) 38 | { 39 | string json = JsonConvert.SerializeObject(saveData); 40 | SaveFile(filename, json); 41 | Debug.Log("Save success!"); 42 | } 43 | 44 | public static TSaveObject LoadSavedObject(string filename) 45 | { 46 | var saveData = LoadFile(filename); 47 | if(saveData != null) 48 | { 49 | var saveObject = JsonConvert.DeserializeObject(saveData); 50 | return saveObject; 51 | } 52 | return default; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Assets/Scripts/Utils/SaveSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d1c0db0dc39e7e4ea2d47a5beae9df7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/Utils/Singleton.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public abstract class Singleton : MonoBehaviour where T : MonoBehaviour 6 | { 7 | private static T instance; 8 | [SerializeField] private bool destroyOnLoad = false; 9 | 10 | public static T Instance 11 | { 12 | get { return instance; } 13 | set 14 | { 15 | if (instance == null) 16 | { 17 | instance = value; 18 | } 19 | else if (instance != value) 20 | { 21 | Destroy(value.gameObject); 22 | } 23 | } 24 | } 25 | 26 | public virtual void Awake() 27 | { 28 | Instance = this as T; 29 | if (!destroyOnLoad) 30 | { 31 | DontDestroyOnLoad(this); 32 | } 33 | 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /Assets/Scripts/Utils/Singleton.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 44979abbea9455b46a1317c4b1020a04 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Terrain.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7d3330c6452bdd143886d188294fdfdf 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Terrain/New Terrain.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moecia/UnityGridBuildingSystem/7916aecb67e5aab6dce5870e67b28ab95d2ad425/Assets/Terrain/New Terrain.asset -------------------------------------------------------------------------------- /Assets/Terrain/New Terrain.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7d5a781c1409f8049acbd32cf975f911 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 15600000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.collab-proxy": "1.5.7", 4 | "com.unity.ide.rider": "2.0.7", 5 | "com.unity.ide.visualstudio": "2.0.8", 6 | "com.unity.ide.vscode": "1.2.3", 7 | "com.unity.test-framework": "1.1.24", 8 | "com.unity.textmeshpro": "3.0.6", 9 | "com.unity.timeline": "1.4.8", 10 | "com.unity.ugui": "1.0.0", 11 | "com.unity.modules.ai": "1.0.0", 12 | "com.unity.modules.androidjni": "1.0.0", 13 | "com.unity.modules.animation": "1.0.0", 14 | "com.unity.modules.assetbundle": "1.0.0", 15 | "com.unity.modules.audio": "1.0.0", 16 | "com.unity.modules.cloth": "1.0.0", 17 | "com.unity.modules.director": "1.0.0", 18 | "com.unity.modules.imageconversion": "1.0.0", 19 | "com.unity.modules.imgui": "1.0.0", 20 | "com.unity.modules.jsonserialize": "1.0.0", 21 | "com.unity.modules.particlesystem": "1.0.0", 22 | "com.unity.modules.physics": "1.0.0", 23 | "com.unity.modules.physics2d": "1.0.0", 24 | "com.unity.modules.screencapture": "1.0.0", 25 | "com.unity.modules.terrain": "1.0.0", 26 | "com.unity.modules.terrainphysics": "1.0.0", 27 | "com.unity.modules.tilemap": "1.0.0", 28 | "com.unity.modules.ui": "1.0.0", 29 | "com.unity.modules.uielements": "1.0.0", 30 | "com.unity.modules.umbra": "1.0.0", 31 | "com.unity.modules.unityanalytics": "1.0.0", 32 | "com.unity.modules.unitywebrequest": "1.0.0", 33 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 34 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 35 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 36 | "com.unity.modules.unitywebrequestwww": "1.0.0", 37 | "com.unity.modules.vehicles": "1.0.0", 38 | "com.unity.modules.video": "1.0.0", 39 | "com.unity.modules.vr": "1.0.0", 40 | "com.unity.modules.wind": "1.0.0", 41 | "com.unity.modules.xr": "1.0.0" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Volume: 1 8 | Rolloff Scale: 1 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_SampleRate: 0 12 | m_DSPBufferSize: 1024 13 | m_VirtualVoiceCount: 512 14 | m_RealVoiceCount: 32 15 | m_SpatializerPlugin: 16 | m_AmbisonicDecoderPlugin: 17 | m_DisableAudio: 0 18 | m_VirtualizeEffects: 1 19 | m_RequestedDSPBufferSize: 1024 20 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 1 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ContactPairsMode: 0 26 | m_BroadphaseType: 0 27 | m_WorldBounds: 28 | m_Center: {x: 0, y: 0, z: 0} 29 | m_Extent: {x: 250, y: 250, z: 250} 30 | m_WorldSubdivisions: 8 31 | m_FrictionType: 0 32 | m_EnableEnhancedDeterminism: 0 33 | m_EnableUnifiedHeightmaps: 1 34 | m_DefaultMaxAngluarSpeed: 7 35 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | m_configObjects: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 0 10 | m_DefaultBehaviorMode: 0 11 | m_PrefabRegularEnvironment: {fileID: 0} 12 | m_PrefabUIEnvironment: {fileID: 0} 13 | m_SpritePackerMode: 0 14 | m_SpritePackerPaddingPower: 1 15 | m_EtcTextureCompressorBehavior: 1 16 | m_EtcTextureFastCompressor: 1 17 | m_EtcTextureNormalCompressor: 2 18 | m_EtcTextureBestCompressor: 4 19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref 20 | m_ProjectGenerationRootNamespace: 21 | m_CollabEditorSettings: 22 | inProgressEnabled: 1 23 | m_EnableTextureStreamingInEditMode: 1 24 | m_EnableTextureStreamingInPlayMode: 1 25 | m_AsyncShaderCompilation: 1 26 | m_EnterPlayModeOptionsEnabled: 0 27 | m_EnterPlayModeOptions: 3 28 | m_ShowLightmapResolutionOverlay: 1 29 | m_UseLegacyProbeSampleCount: 0 30 | m_SerializeInlineMappingsOnOneLine: 1 -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | m_PreloadedShaders: [] 39 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 40 | type: 0} 41 | m_CustomRenderPipeline: {fileID: 0} 42 | m_TransparencySortMode: 0 43 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 44 | m_DefaultRenderingPath: 1 45 | m_DefaultMobileRenderingPath: 1 46 | m_TierSettings: [] 47 | m_LightmapStripping: 0 48 | m_FogStripping: 0 49 | m_InstancingStripping: 0 50 | m_LightmapKeepPlain: 1 51 | m_LightmapKeepDirCombined: 1 52 | m_LightmapKeepDynamicPlain: 1 53 | m_LightmapKeepDynamicDirCombined: 1 54 | m_LightmapKeepShadowMask: 1 55 | m_LightmapKeepSubtractive: 1 56 | m_FogKeepLinear: 1 57 | m_FogKeepExp: 1 58 | m_FogKeepExp2: 1 59 | m_AlbedoSwatchInfos: [] 60 | m_LightsUseLinearIntensity: 0 61 | m_LightsUseColorTemperature: 0 62 | m_LogWhenShaderIsCompiled: 0 63 | m_AllowEnlightenSupportForUpgradedProject: 0 64 | -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /ProjectSettings/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreviewPackages: 0 16 | m_EnablePackageDependencies: 0 17 | m_AdvancedSettingsExpanded: 1 18 | m_ScopedRegistriesSettingsExpanded: 1 19 | oneTimeWarningShown: 0 20 | m_Registries: 21 | - m_Id: main 22 | m_Name: 23 | m_Url: https://packages.unity.com 24 | m_Scopes: [] 25 | m_IsDefault: 1 26 | m_Capabilities: 7 27 | m_UserSelectedRegistryName: 28 | m_UserAddingNewScopedRegistry: 0 29 | m_RegistryInfoDraft: 30 | m_ErrorMessage: 31 | m_Original: 32 | m_Id: 33 | m_Name: 34 | m_Url: 35 | m_Scopes: [] 36 | m_IsDefault: 0 37 | m_Capabilities: 0 38 | m_Modified: 0 39 | m_Name: 40 | m_Url: 41 | m_Scopes: 42 | - 43 | m_SelectedScopeIndex: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_AutoSimulation: 1 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_ReuseCollisionCallbacks: 1 46 | m_AutoSyncTransforms: 0 47 | m_AlwaysShowColliders: 0 48 | m_ShowColliderSleep: 1 49 | m_ShowColliderContacts: 0 50 | m_ShowColliderAABB: 0 51 | m_ContactArrowScale: 0.2 52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 57 | -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_DefaultPresets: {} 8 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2020.3.10f1 2 | m_EditorVersionWithRevision: 2020.3.10f1 (297d780c91bc) 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 5 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | streamingMipmapsActive: 0 33 | streamingMipmapsAddAllCameras: 1 34 | streamingMipmapsMemoryBudget: 512 35 | streamingMipmapsRenderersPerFrame: 512 36 | streamingMipmapsMaxLevelReduction: 2 37 | streamingMipmapsMaxFileIORequests: 1024 38 | particleRaycastBudget: 4 39 | asyncUploadTimeSlice: 2 40 | asyncUploadBufferSize: 16 41 | asyncUploadPersistentBuffer: 1 42 | resolutionScalingFixedDPIFactor: 1 43 | excludedTargetPlatforms: [] 44 | - serializedVersion: 2 45 | name: Low 46 | pixelLightCount: 0 47 | shadows: 0 48 | shadowResolution: 0 49 | shadowProjection: 1 50 | shadowCascades: 1 51 | shadowDistance: 20 52 | shadowNearPlaneOffset: 3 53 | shadowCascade2Split: 0.33333334 54 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 55 | shadowmaskMode: 0 56 | blendWeights: 2 57 | textureQuality: 0 58 | anisotropicTextures: 0 59 | antiAliasing: 0 60 | softParticles: 0 61 | softVegetation: 0 62 | realtimeReflectionProbes: 0 63 | billboardsFaceCameraPosition: 0 64 | vSyncCount: 0 65 | lodBias: 0.4 66 | maximumLODLevel: 0 67 | streamingMipmapsActive: 0 68 | streamingMipmapsAddAllCameras: 1 69 | streamingMipmapsMemoryBudget: 512 70 | streamingMipmapsRenderersPerFrame: 512 71 | streamingMipmapsMaxLevelReduction: 2 72 | streamingMipmapsMaxFileIORequests: 1024 73 | particleRaycastBudget: 16 74 | asyncUploadTimeSlice: 2 75 | asyncUploadBufferSize: 16 76 | asyncUploadPersistentBuffer: 1 77 | resolutionScalingFixedDPIFactor: 1 78 | excludedTargetPlatforms: [] 79 | - serializedVersion: 2 80 | name: Medium 81 | pixelLightCount: 1 82 | shadows: 1 83 | shadowResolution: 0 84 | shadowProjection: 1 85 | shadowCascades: 1 86 | shadowDistance: 20 87 | shadowNearPlaneOffset: 3 88 | shadowCascade2Split: 0.33333334 89 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 90 | shadowmaskMode: 0 91 | blendWeights: 2 92 | textureQuality: 0 93 | anisotropicTextures: 1 94 | antiAliasing: 0 95 | softParticles: 0 96 | softVegetation: 0 97 | realtimeReflectionProbes: 0 98 | billboardsFaceCameraPosition: 0 99 | vSyncCount: 1 100 | lodBias: 0.7 101 | maximumLODLevel: 0 102 | streamingMipmapsActive: 0 103 | streamingMipmapsAddAllCameras: 1 104 | streamingMipmapsMemoryBudget: 512 105 | streamingMipmapsRenderersPerFrame: 512 106 | streamingMipmapsMaxLevelReduction: 2 107 | streamingMipmapsMaxFileIORequests: 1024 108 | particleRaycastBudget: 64 109 | asyncUploadTimeSlice: 2 110 | asyncUploadBufferSize: 16 111 | asyncUploadPersistentBuffer: 1 112 | resolutionScalingFixedDPIFactor: 1 113 | excludedTargetPlatforms: [] 114 | - serializedVersion: 2 115 | name: High 116 | pixelLightCount: 2 117 | shadows: 2 118 | shadowResolution: 1 119 | shadowProjection: 1 120 | shadowCascades: 2 121 | shadowDistance: 40 122 | shadowNearPlaneOffset: 3 123 | shadowCascade2Split: 0.33333334 124 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 125 | shadowmaskMode: 1 126 | blendWeights: 2 127 | textureQuality: 0 128 | anisotropicTextures: 1 129 | antiAliasing: 0 130 | softParticles: 0 131 | softVegetation: 1 132 | realtimeReflectionProbes: 1 133 | billboardsFaceCameraPosition: 1 134 | vSyncCount: 1 135 | lodBias: 1 136 | maximumLODLevel: 0 137 | streamingMipmapsActive: 0 138 | streamingMipmapsAddAllCameras: 1 139 | streamingMipmapsMemoryBudget: 512 140 | streamingMipmapsRenderersPerFrame: 512 141 | streamingMipmapsMaxLevelReduction: 2 142 | streamingMipmapsMaxFileIORequests: 1024 143 | particleRaycastBudget: 256 144 | asyncUploadTimeSlice: 2 145 | asyncUploadBufferSize: 16 146 | asyncUploadPersistentBuffer: 1 147 | resolutionScalingFixedDPIFactor: 1 148 | excludedTargetPlatforms: [] 149 | - serializedVersion: 2 150 | name: Very High 151 | pixelLightCount: 3 152 | shadows: 2 153 | shadowResolution: 2 154 | shadowProjection: 1 155 | shadowCascades: 2 156 | shadowDistance: 70 157 | shadowNearPlaneOffset: 3 158 | shadowCascade2Split: 0.33333334 159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 160 | shadowmaskMode: 1 161 | blendWeights: 4 162 | textureQuality: 0 163 | anisotropicTextures: 2 164 | antiAliasing: 2 165 | softParticles: 1 166 | softVegetation: 1 167 | realtimeReflectionProbes: 1 168 | billboardsFaceCameraPosition: 1 169 | vSyncCount: 1 170 | lodBias: 1.5 171 | maximumLODLevel: 0 172 | streamingMipmapsActive: 0 173 | streamingMipmapsAddAllCameras: 1 174 | streamingMipmapsMemoryBudget: 512 175 | streamingMipmapsRenderersPerFrame: 512 176 | streamingMipmapsMaxLevelReduction: 2 177 | streamingMipmapsMaxFileIORequests: 1024 178 | particleRaycastBudget: 1024 179 | asyncUploadTimeSlice: 2 180 | asyncUploadBufferSize: 16 181 | asyncUploadPersistentBuffer: 1 182 | resolutionScalingFixedDPIFactor: 1 183 | excludedTargetPlatforms: [] 184 | - serializedVersion: 2 185 | name: Ultra 186 | pixelLightCount: 4 187 | shadows: 2 188 | shadowResolution: 2 189 | shadowProjection: 1 190 | shadowCascades: 4 191 | shadowDistance: 150 192 | shadowNearPlaneOffset: 3 193 | shadowCascade2Split: 0.33333334 194 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 195 | shadowmaskMode: 1 196 | blendWeights: 4 197 | textureQuality: 0 198 | anisotropicTextures: 2 199 | antiAliasing: 2 200 | softParticles: 1 201 | softVegetation: 1 202 | realtimeReflectionProbes: 1 203 | billboardsFaceCameraPosition: 1 204 | vSyncCount: 1 205 | lodBias: 2 206 | maximumLODLevel: 0 207 | streamingMipmapsActive: 0 208 | streamingMipmapsAddAllCameras: 1 209 | streamingMipmapsMemoryBudget: 512 210 | streamingMipmapsRenderersPerFrame: 512 211 | streamingMipmapsMaxLevelReduction: 2 212 | streamingMipmapsMaxFileIORequests: 1024 213 | particleRaycastBudget: 4096 214 | asyncUploadTimeSlice: 2 215 | asyncUploadBufferSize: 16 216 | asyncUploadPersistentBuffer: 1 217 | resolutionScalingFixedDPIFactor: 1 218 | excludedTargetPlatforms: [] 219 | m_PerPlatformDefaultQuality: 220 | Android: 2 221 | Lumin: 5 222 | Nintendo 3DS: 5 223 | Nintendo Switch: 5 224 | PS4: 5 225 | PSP2: 2 226 | Stadia: 5 227 | Standalone: 5 228 | WebGL: 3 229 | Windows Store Apps: 5 230 | XboxOne: 5 231 | iPhone: 2 232 | tvOS: 2 233 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: 7 | - Terrain 8 | layers: 9 | - Default 10 | - TransparentFX 11 | - Ignore Raycast 12 | - 13 | - Water 14 | - UI 15 | - Level 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | - 41 | m_SortingLayers: 42 | - name: Default 43 | uniqueID: 0 44 | locked: 0 45 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_DashboardUrl: https://dashboard.unity3d.com 13 | m_TestInitMode: 0 14 | CrashReportingSettings: 15 | m_EventUrl: https://perf-events.cloud.unity3d.com 16 | m_Enabled: 0 17 | m_LogBufferSize: 10 18 | m_CaptureEditorExceptions: 1 19 | UnityPurchasingSettings: 20 | m_Enabled: 0 21 | m_TestMode: 0 22 | UnityAnalyticsSettings: 23 | m_Enabled: 0 24 | m_TestMode: 0 25 | m_InitializeOnStartup: 1 26 | UnityAdsSettings: 27 | m_Enabled: 0 28 | m_InitializeOnStartup: 1 29 | m_TestMode: 0 30 | m_IosGameId: 31 | m_AndroidGameId: 32 | m_GameIds: {} 33 | m_GameId: 34 | PerformanceReportingSettings: 35 | m_Enabled: 0 36 | -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | -------------------------------------------------------------------------------- /ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /UserSettings/EditorUserSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!162 &1 4 | EditorUserSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_ConfigSettings: 8 | RecentlyUsedScenePath-0: 9 | value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d 10 | flags: 0 11 | vcSharedLogLevel: 12 | value: 0d5e400f0650 13 | flags: 0 14 | m_VCAutomaticAdd: 1 15 | m_VCDebugCom: 0 16 | m_VCDebugCmd: 0 17 | m_VCDebugOut: 0 18 | m_SemanticMergeMode: 2 19 | m_VCShowFailedCheckout: 1 20 | m_VCOverwriteFailedCheckoutAssets: 1 21 | m_VCProjectOverlayIcons: 1 22 | m_VCHierarchyOverlayIcons: 1 23 | m_VCOtherOverlayIcons: 1 24 | m_VCAllowAsyncUpdate: 1 25 | --------------------------------------------------------------------------------