├── Audio.meta ├── Audio ├── ZombiePlayerMixer.mixer └── ZombiePlayerMixer.mixer.meta ├── Maps.meta ├── Maps ├── ZombieCity.unity ├── ZombieCity.unity.meta ├── ZombieDungeon.meta ├── ZombieDungeon.unity ├── ZombieDungeon.unity.meta └── ZombieDungeon │ ├── LightingData.asset │ ├── LightingData.asset.meta │ ├── ReflectionProbe-0.exr │ └── ReflectionProbe-0.exr.meta ├── Materials.meta ├── Materials ├── FlareParticleMaterial.mat ├── FlareParticleMaterial.mat.meta ├── LineRenderMaterial.mat └── LineRenderMaterial.mat.meta ├── Prefabs.meta ├── Prefabs ├── Cliffs.meta ├── Cliffs │ ├── Cliff_1.prefab │ ├── Cliff_1.prefab.meta │ ├── Cliff_2.prefab │ ├── Cliff_2.prefab.meta │ ├── Cliff_3.prefab │ ├── Cliff_3.prefab.meta │ ├── Cliff_4.prefab │ └── Cliff_4.prefab.meta ├── Game.meta ├── Game │ ├── SurvivalGame.prefab │ └── SurvivalGame.prefab.meta ├── Roads.meta ├── Roads │ ├── Asphalt.meta │ └── Asphalt │ │ ├── Road_Asphalt_C.prefab │ │ ├── Road_Asphalt_C.prefab.meta │ │ ├── Road_Asphalt_C2.prefab │ │ ├── Road_Asphalt_C2.prefab.meta │ │ ├── Road_Asphalt_S.prefab │ │ ├── Road_Asphalt_S.prefab.meta │ │ ├── Road_Asphalt_S2.prefab │ │ ├── Road_Asphalt_S2.prefab.meta │ │ ├── Road_Asphalt_S3.prefab │ │ ├── Road_Asphalt_S3.prefab.meta │ │ ├── Road_Asphalt_S4.prefab │ │ ├── Road_Asphalt_S4.prefab.meta │ │ ├── Road_Asphalt_S5.prefab │ │ ├── Road_Asphalt_S5.prefab.meta │ │ ├── Road_Asphalt_S6.prefab │ │ ├── Road_Asphalt_S6.prefab.meta │ │ ├── Road_Asphalt_T.prefab │ │ ├── Road_Asphalt_T.prefab.meta │ │ ├── Road_Asphalt_X.prefab │ │ └── Road_Asphalt_X.prefab.meta ├── Vehicles.meta └── Vehicles │ ├── Vehicle_Buggy.prefab │ ├── Vehicle_Buggy.prefab.meta │ ├── Vehicle_BuggyTri.prefab │ ├── Vehicle_BuggyTri.prefab.meta │ ├── Vehicle_Truck.prefab │ └── Vehicle_Truck.prefab.meta ├── README.md ├── README.md.meta ├── Scripts.meta ├── Scripts ├── Audio.meta ├── Audio │ ├── PlaySfxAndKill.cs │ ├── PlaySfxAndKill.cs.meta │ ├── SfxPlayer.cs │ └── SfxPlayer.cs.meta ├── Dungeon.meta ├── Dungeon │ ├── Rules.meta │ └── Rules │ │ ├── GrassTransformRule.cs │ │ └── GrassTransformRule.cs.meta ├── Player.meta ├── Player │ ├── PlayerController.cs │ ├── PlayerController.cs.meta │ ├── WeaponInfo.cs │ ├── WeaponInfo.cs.meta │ ├── WeaponRegistry.cs │ └── WeaponRegistry.cs.meta ├── ShooterDemoLib.meta ├── ShooterDemoLib │ ├── AI.meta │ ├── AI │ │ ├── AIController.cs │ │ ├── AIController.cs.meta │ │ ├── CharacterControlScript.cs │ │ ├── CharacterControlScript.cs.meta │ │ ├── LastPlayerSighting.cs │ │ ├── LastPlayerSighting.cs.meta │ │ ├── LevelNpcSpawner.cs │ │ ├── LevelNpcSpawner.cs.meta │ │ ├── PatrolPath.cs │ │ ├── PatrolPath.cs.meta │ │ ├── SpecialRoomFinder.cs │ │ ├── SpecialRoomFinder.cs.meta │ │ ├── StateMachine.cs │ │ └── StateMachine.cs.meta │ ├── Audio.meta │ ├── Audio │ │ ├── MixLevels.cs │ │ └── MixLevels.cs.meta │ ├── Camera.meta │ ├── Camera │ │ ├── CameraFollow.cs │ │ └── CameraFollow.cs.meta │ ├── Enemy.meta │ ├── Enemy │ │ ├── EnemyAttack.cs │ │ ├── EnemyAttack.cs.meta │ │ ├── EnemyHealth.cs │ │ ├── EnemyHealth.cs.meta │ │ ├── EnemyMovement.cs │ │ └── EnemyMovement.cs.meta │ ├── Game.meta │ ├── Game │ │ ├── GameController.cs │ │ ├── GameController.cs.meta │ │ ├── LevelGoal.cs │ │ └── LevelGoal.cs.meta │ ├── Helpers.meta │ ├── Helpers │ │ ├── BeautyShot.cs │ │ ├── BeautyShot.cs.meta │ │ ├── RandomAnimationPoint.cs │ │ ├── RandomAnimationPoint.cs.meta │ │ ├── RandomParticlePoint.cs │ │ ├── RandomParticlePoint.cs.meta │ │ ├── VolumeHandler.cs │ │ └── VolumeHandler.cs.meta │ ├── Managers.meta │ ├── Managers │ │ ├── EnemyManager.cs │ │ ├── EnemyManager.cs.meta │ │ ├── GameOverManager.cs │ │ ├── GameOverManager.cs.meta │ │ ├── PauseManager.cs │ │ ├── PauseManager.cs.meta │ │ ├── ScoreManager.cs │ │ └── ScoreManager.cs.meta │ ├── MiniMap.meta │ ├── MiniMap │ │ ├── MiniMapCameraTracker.cs │ │ ├── MiniMapCameraTracker.cs.meta │ │ ├── MiniMapEnemyDots.cs │ │ ├── MiniMapEnemyDots.cs.meta │ │ ├── MiniMapGenerator.cs │ │ ├── MiniMapGenerator.cs.meta │ │ ├── MiniMapRebuilder.cs │ │ ├── MiniMapRebuilder.cs.meta │ │ ├── MiniMapRenderer.cs │ │ └── MiniMapRenderer.cs.meta │ ├── Player.meta │ ├── Player │ │ ├── PlayerHealth.cs │ │ ├── PlayerHealth.cs.meta │ │ ├── PlayerMovement.cs │ │ ├── PlayerMovement.cs.meta │ │ ├── PlayerShooting.cs │ │ └── PlayerShooting.cs.meta │ ├── Utils.meta │ ├── Utils │ │ ├── BillboardGizmo.cs │ │ └── BillboardGizmo.cs.meta │ ├── Waypoints.meta │ └── Waypoints │ │ ├── Waypoint.cs │ │ ├── Waypoint.cs.meta │ │ ├── WaypointGenerator.cs │ │ ├── WaypointGenerator.cs.meta │ │ ├── WaypointPathVisualizer.cs │ │ └── WaypointPathVisualizer.cs.meta ├── Utils.meta └── Utils │ ├── DestroyOnAudioComplete.cs │ ├── DestroyOnAudioComplete.cs.meta │ ├── GameTags.cs │ ├── GameTags.cs.meta │ ├── GameUtils.cs │ ├── GameUtils.cs.meta │ ├── Tween.cs │ └── Tween.cs.meta ├── Themes.meta └── Themes ├── ZombieCityTheme.asset ├── ZombieCityTheme.asset.meta ├── ZombieDungeonTheme.asset └── ZombieDungeonTheme.asset.meta /Audio.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f1e3719aa7de349ceb3c767982d43919 3 | folderAsset: yes 4 | timeCreated: 1474641892 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Audio/ZombiePlayerMixer.mixer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Audio/ZombiePlayerMixer.mixer -------------------------------------------------------------------------------- /Audio/ZombiePlayerMixer.mixer.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29647ff89fc244f2ab98316bd6affd10 3 | timeCreated: 1474641906 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Maps.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bcf64abb7a7b147668c51e96a152d1a8 3 | folderAsset: yes 4 | timeCreated: 1474603493 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Maps/ZombieCity.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Maps/ZombieCity.unity -------------------------------------------------------------------------------- /Maps/ZombieCity.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 04b0e964cd1464abc93e9be84cbd6f7e 3 | timeCreated: 1474603849 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Maps/ZombieDungeon.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c7252c1c8ef0cf243a32874f2bcdda4d 3 | folderAsset: yes 4 | timeCreated: 1479020531 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Maps/ZombieDungeon.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Maps/ZombieDungeon.unity -------------------------------------------------------------------------------- /Maps/ZombieDungeon.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d5dfa839717ae424eb93991aa19a1c34 3 | timeCreated: 1474607463 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Maps/ZombieDungeon/LightingData.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Maps/ZombieDungeon/LightingData.asset -------------------------------------------------------------------------------- /Maps/ZombieDungeon/LightingData.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 59d40671b1fabe141a5e57f67c5d6991 3 | timeCreated: 1479020532 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Maps/ZombieDungeon/ReflectionProbe-0.exr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Maps/ZombieDungeon/ReflectionProbe-0.exr -------------------------------------------------------------------------------- /Maps/ZombieDungeon/ReflectionProbe-0.exr.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5774b0285c8fc6c449c9db1bc33584c6 3 | timeCreated: 1479020531 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: 7 | 8900000: generatedCubemap 8 | serializedVersion: 2 9 | mipmaps: 10 | mipMapMode: 0 11 | enableMipMap: 1 12 | linearTexture: 0 13 | correctGamma: 0 14 | fadeOut: 0 15 | borderMipMap: 0 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 | grayScaleToAlpha: 0 25 | generateCubemap: 6 26 | cubemapConvolution: 1 27 | cubemapConvolutionSteps: 7 28 | cubemapConvolutionExponent: 1.5 29 | seamlessCubemap: 1 30 | textureFormat: -1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | filterMode: 2 34 | aniso: 0 35 | mipBias: 0 36 | wrapMode: 1 37 | nPOTScale: 1 38 | lightmap: 0 39 | rGBM: 0 40 | compressionQuality: 100 41 | allowsAlphaSplitting: 0 42 | spriteMode: 0 43 | spriteExtrude: 1 44 | spriteMeshType: 1 45 | alignment: 0 46 | spritePivot: {x: 0.5, y: 0.5} 47 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 48 | spritePixelsToUnits: 100 49 | alphaIsTransparency: 0 50 | spriteTessellationDetail: -1 51 | textureType: 3 52 | buildTargetSettings: [] 53 | spriteSheet: 54 | serializedVersion: 2 55 | sprites: [] 56 | outline: [] 57 | spritePackingTag: 58 | userData: 59 | assetBundleName: 60 | assetBundleVariant: 61 | -------------------------------------------------------------------------------- /Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3545728c504c94a4f9ff9653ae70c9f0 3 | folderAsset: yes 4 | timeCreated: 1479033461 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Materials/FlareParticleMaterial.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 3 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: FlareParticleMaterial 10 | m_Shader: {fileID: 200, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: [] 12 | m_CustomRenderQueue: -1 13 | m_SavedProperties: 14 | serializedVersion: 2 15 | m_TexEnvs: 16 | data: 17 | first: 18 | name: _MainTex 19 | second: 20 | m_Texture: {fileID: 10300, guid: 0000000000000000f000000000000000, type: 0} 21 | m_Scale: {x: 1, y: 1} 22 | m_Offset: {x: 0, y: 0} 23 | m_Floats: 24 | data: 25 | first: 26 | name: _InvFade 27 | second: 1 28 | m_Colors: 29 | data: 30 | first: 31 | name: _Color 32 | second: {r: 1, g: 1, b: 1, a: 1} 33 | data: 34 | first: 35 | name: _TintColor 36 | second: {r: .492647052, g: .492647052, b: .492647052, a: .501960814} 37 | -------------------------------------------------------------------------------- /Materials/FlareParticleMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b75a561f374f89247a62336b50288d40 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Materials/LineRenderMaterial.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_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: LineRenderMaterial 10 | m_Shader: {fileID: 10755, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: _EMISSION _EMISSIONMAP _LIGHTMAPPING_DYNAMIC_LIGHTMAPS _LIGHTMAPPING_REALTIME 12 | _UVSEC_UV1 13 | m_LightmapFlags: 1 14 | m_CustomRenderQueue: -1 15 | stringTagMap: {} 16 | m_SavedProperties: 17 | serializedVersion: 2 18 | m_TexEnvs: 19 | data: 20 | first: 21 | name: _MainTex 22 | second: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | data: 27 | first: 28 | name: _BumpMap 29 | second: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | data: 34 | first: 35 | name: _DetailNormalMap 36 | second: 37 | m_Texture: {fileID: 0} 38 | m_Scale: {x: 1, y: 1} 39 | m_Offset: {x: 0, y: 0} 40 | data: 41 | first: 42 | name: _ParallaxMap 43 | second: 44 | m_Texture: {fileID: 0} 45 | m_Scale: {x: 1, y: 1} 46 | m_Offset: {x: 0, y: 0} 47 | data: 48 | first: 49 | name: _OcclusionMap 50 | second: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | data: 55 | first: 56 | name: _EmissionMap 57 | second: 58 | m_Texture: {fileID: 0} 59 | m_Scale: {x: 1, y: 1} 60 | m_Offset: {x: 0, y: 0} 61 | data: 62 | first: 63 | name: _DetailMask 64 | second: 65 | m_Texture: {fileID: 0} 66 | m_Scale: {x: 1, y: 1} 67 | m_Offset: {x: 0, y: 0} 68 | data: 69 | first: 70 | name: _DetailAlbedoMap 71 | second: 72 | m_Texture: {fileID: 0} 73 | m_Scale: {x: 1, y: 1} 74 | m_Offset: {x: 0, y: 0} 75 | data: 76 | first: 77 | name: _Occlusion 78 | second: 79 | m_Texture: {fileID: 0} 80 | m_Scale: {x: 1, y: 1} 81 | m_Offset: {x: 0, y: 0} 82 | data: 83 | first: 84 | name: _MetallicGlossMap 85 | second: 86 | m_Texture: {fileID: 0} 87 | m_Scale: {x: 1, y: 1} 88 | m_Offset: {x: 0, y: 0} 89 | data: 90 | first: 91 | name: _SpecGlossMap 92 | second: 93 | m_Texture: {fileID: 0} 94 | m_Scale: {x: 1, y: 1} 95 | m_Offset: {x: 0, y: 0} 96 | data: 97 | first: 98 | name: _Illum 99 | second: 100 | m_Texture: {fileID: 0} 101 | m_Scale: {x: 1, y: 1} 102 | m_Offset: {x: 0, y: 0} 103 | m_Floats: 104 | data: 105 | first: 106 | name: _SrcBlend 107 | second: 1 108 | data: 109 | first: 110 | name: _DstBlend 111 | second: 0 112 | data: 113 | first: 114 | name: _Cutoff 115 | second: .5 116 | data: 117 | first: 118 | name: _AlphaTestRef 119 | second: .5 120 | data: 121 | first: 122 | name: _Parallax 123 | second: .0199999996 124 | data: 125 | first: 126 | name: _ZWrite 127 | second: 1 128 | data: 129 | first: 130 | name: _Glossiness 131 | second: 0 132 | data: 133 | first: 134 | name: _BumpScale 135 | second: 1 136 | data: 137 | first: 138 | name: _OcclusionStrength 139 | second: 1 140 | data: 141 | first: 142 | name: _DetailNormalMapScale 143 | second: 1 144 | data: 145 | first: 146 | name: _UVSec 147 | second: 0 148 | data: 149 | first: 150 | name: _Mode 151 | second: 0 152 | data: 153 | first: 154 | name: _Metallic 155 | second: 0 156 | data: 157 | first: 158 | name: _Lightmapping 159 | second: 1 160 | data: 161 | first: 162 | name: _EmissionScaleUI 163 | second: 1 164 | data: 165 | first: 166 | name: _EmissionLM 167 | second: 1 168 | data: 169 | first: 170 | name: _DynamicEmissionLM 171 | second: 0 172 | m_Colors: 173 | data: 174 | first: 175 | name: _EmissionColor 176 | second: {r: .970588148, g: .880715251, b: .378243923, a: .99999994} 177 | data: 178 | first: 179 | name: _Color 180 | second: {r: 1, g: .908823967, b: .640999973, a: 1} 181 | data: 182 | first: 183 | name: _SpecColor 184 | second: {r: .200000003, g: .200000003, b: .200000003, a: 1} 185 | data: 186 | first: 187 | name: _EmissionColorUI 188 | second: {r: .970588207, g: .880715311, b: .378243953, a: 1} 189 | data: 190 | first: 191 | name: _EmissionColorWithMapUI 192 | second: {r: 1, g: 1, b: 1, a: 1} 193 | data: 194 | first: 195 | name: _SpecularColor 196 | second: {r: .200000003, g: .200000003, b: .200000003, a: 1} 197 | -------------------------------------------------------------------------------- /Materials/LineRenderMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 007cd3dce0e6539409edcc484011c877 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d8d38a011afdb44b388601db3a2475ee 3 | folderAsset: yes 4 | timeCreated: 1474603499 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Prefabs/Cliffs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9d0177edf30414a3e9604e0f9b2b6adb 3 | folderAsset: yes 4 | timeCreated: 1474608404 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Prefabs/Cliffs/Cliff_1.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Prefabs/Cliffs/Cliff_1.prefab -------------------------------------------------------------------------------- /Prefabs/Cliffs/Cliff_1.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3391c6d2b135a43239e14fe306ddf6ea 3 | timeCreated: 1474608408 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs/Cliffs/Cliff_2.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Prefabs/Cliffs/Cliff_2.prefab -------------------------------------------------------------------------------- /Prefabs/Cliffs/Cliff_2.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6951bb265677347deabb813d4fc94d8e 3 | timeCreated: 1474608411 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs/Cliffs/Cliff_3.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Prefabs/Cliffs/Cliff_3.prefab -------------------------------------------------------------------------------- /Prefabs/Cliffs/Cliff_3.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 490981c04a5b440559dd10070a71085b 3 | timeCreated: 1474608412 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs/Cliffs/Cliff_4.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Prefabs/Cliffs/Cliff_4.prefab -------------------------------------------------------------------------------- /Prefabs/Cliffs/Cliff_4.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f98fa3273fe16420d8983d7c9d5d634a 3 | timeCreated: 1474608415 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs/Game.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ceb325ab8bd54b1dbfc135026d0559c 3 | folderAsset: yes 4 | timeCreated: 1474644825 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Prefabs/Game/SurvivalGame.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Prefabs/Game/SurvivalGame.prefab -------------------------------------------------------------------------------- /Prefabs/Game/SurvivalGame.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: faf7e8d10d80d4ce19b84f0f8e7f5f65 3 | timeCreated: 1474644829 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs/Roads.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a98ee745cf28455a8faaf3f31ebc46f 3 | folderAsset: yes 4 | timeCreated: 1474604661 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0a7ca7f833ce4b3db4290d0b9e45c95 3 | folderAsset: yes 4 | timeCreated: 1474604668 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_C.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Prefabs/Roads/Asphalt/Road_Asphalt_C.prefab -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_C.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1911e03d0e5544195b7fbd13a8817a42 3 | timeCreated: 1474605087 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_C2.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Prefabs/Roads/Asphalt/Road_Asphalt_C2.prefab -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_C2.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e08e944a6591b4abf829e74d84a86ac6 3 | timeCreated: 1474605086 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_S.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Prefabs/Roads/Asphalt/Road_Asphalt_S.prefab -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_S.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4363cac22ad9643aaa1be79b4f76cda7 3 | timeCreated: 1474605089 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_S2.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Prefabs/Roads/Asphalt/Road_Asphalt_S2.prefab -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_S2.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a72a351e159f04829ada5b4f3606dd5a 3 | timeCreated: 1474605687 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_S3.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Prefabs/Roads/Asphalt/Road_Asphalt_S3.prefab -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_S3.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bfc930a7ce9d84f3daff5f7206383e17 3 | timeCreated: 1474605690 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_S4.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Prefabs/Roads/Asphalt/Road_Asphalt_S4.prefab -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_S4.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c263f27dc30cb4592ae530fb29ba0665 3 | timeCreated: 1474605691 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_S5.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Prefabs/Roads/Asphalt/Road_Asphalt_S5.prefab -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_S5.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7c0e992bad4a04126b6168f1e4b2fc0a 3 | timeCreated: 1474605692 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_S6.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Prefabs/Roads/Asphalt/Road_Asphalt_S6.prefab -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_S6.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33398f9bc58f94aeca850cf5b7e169a2 3 | timeCreated: 1474605694 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_T.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Prefabs/Roads/Asphalt/Road_Asphalt_T.prefab -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_T.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 275c30c89c7244492940e81c1b92675a 3 | timeCreated: 1474605083 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_X.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Prefabs/Roads/Asphalt/Road_Asphalt_X.prefab -------------------------------------------------------------------------------- /Prefabs/Roads/Asphalt/Road_Asphalt_X.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9f7d11f2228147c3b8bbee5a23a344e 3 | timeCreated: 1474605081 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs/Vehicles.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29e3c4fd9d0ac344bb866a1835698f0c 3 | folderAsset: yes 4 | timeCreated: 1479041735 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Prefabs/Vehicles/Vehicle_Buggy.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Prefabs/Vehicles/Vehicle_Buggy.prefab -------------------------------------------------------------------------------- /Prefabs/Vehicles/Vehicle_Buggy.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 382223eaf27ac774f91acbdd6f8a9ce8 3 | timeCreated: 1479041740 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs/Vehicles/Vehicle_BuggyTri.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Prefabs/Vehicles/Vehicle_BuggyTri.prefab -------------------------------------------------------------------------------- /Prefabs/Vehicles/Vehicle_BuggyTri.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b9c756fb15bce5d45ac1ecde5ddaf47a 3 | timeCreated: 1479041740 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs/Vehicles/Vehicle_Truck.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Prefabs/Vehicles/Vehicle_Truck.prefab -------------------------------------------------------------------------------- /Prefabs/Vehicles/Vehicle_Truck.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1987f3ea4f1b5664f8ff9af66f5f9234 3 | timeCreated: 1479041740 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Zombie Story 2 | 3 | Zombie story is a free sample game that uses Dungeon Architect. In this game I demo the various builders and how you can use them in your own game. Feel free to use this game code in your own games. 4 | 5 | 6 | Dependencies: 7 | * Dungeon Architect 8 | * SimpleApocalypse (for art) 9 | * PostApocalypseGuns (for sfx) 10 | 11 | ![Zombie Story](http://i.imgur.com/yEryIQlh.jpg) 12 | ![Zombie Story](http://i.imgur.com/2ici2t0h.jpg) 13 | ![Zombie Story](http://i.imgur.com/VO7Q5kCh.jpg) 14 | 15 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1679cc9a27a3d574382206078cd076ef 3 | timeCreated: 1475828903 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b63fa89f06d224360bcef3230e3028bc 3 | folderAsset: yes 4 | timeCreated: 1474631501 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Scripts/Audio.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 058328b27fbf3294b84c8d6114c93d3e 3 | folderAsset: yes 4 | timeCreated: 1479036374 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Scripts/Audio/PlaySfxAndKill.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class PlaySfxAndKill : MonoBehaviour { 5 | AudioSource source; 6 | void Awake () { 7 | source = GetComponent(); 8 | } 9 | 10 | public void PlayAudio(AudioClip clip, float volumeScale) 11 | { 12 | source.clip = clip; 13 | source.PlayOneShot(clip, volumeScale); 14 | } 15 | 16 | // Update is called once per frame 17 | void Update () { 18 | if (!source.isPlaying) 19 | { 20 | Destroy(gameObject); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Scripts/Audio/PlaySfxAndKill.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e2c12be9e9873be4db85648730657f72 3 | timeCreated: 1479036482 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Audio/SfxPlayer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class SfxPlayer : MonoBehaviour { 5 | public Transform parent; 6 | public UnityEngine.Audio.AudioMixerGroup mixerGroup; 7 | 8 | public void PlayAudio(AudioClip clip, float volumeScale) 9 | { 10 | if (clip != null) 11 | { 12 | var sfx = new GameObject(); 13 | sfx.isStatic = true; 14 | var source = sfx.AddComponent(); 15 | source.outputAudioMixerGroup = mixerGroup; 16 | 17 | var script = sfx.AddComponent(); 18 | script.PlayAudio(clip, volumeScale); 19 | 20 | if (parent != null) 21 | { 22 | sfx.transform.parent = parent; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Scripts/Audio/SfxPlayer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 144d6176b390bca47bbd11beb9baa90f 3 | timeCreated: 1479036384 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Dungeon.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fcd28b2e4e0c447c8a86a3fb251aaccb 3 | folderAsset: yes 4 | timeCreated: 1474622158 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Scripts/Dungeon/Rules.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22269444aa1af45adbc82353585d540f 3 | folderAsset: yes 4 | timeCreated: 1474622162 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Scripts/Dungeon/Rules/GrassTransformRule.cs: -------------------------------------------------------------------------------- 1 | //$ Copyright 2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $// 2 | 3 | using UnityEngine; 4 | using System.Collections; 5 | using DungeonArchitect; 6 | using DungeonArchitect.Utils; 7 | 8 | public class GrassTransformRule : TransformationRule { 9 | 10 | public override void GetTransform(PropSocket socket, DungeonModel model, Matrix4x4 propTransform, System.Random random, out Vector3 outPosition, out Quaternion outRotation, out Vector3 outScale) { 11 | base.GetTransform(socket, model, propTransform, random, out outPosition, out outRotation, out outScale); 12 | 13 | var angle = random.Range(0.0f, Mathf.PI * 2); 14 | var rotation = Quaternion.Euler(0, angle, 0); 15 | outRotation = rotation; 16 | 17 | float cellSize = 20; 18 | float halfCellSize = cellSize / 2.0f; 19 | outPosition.x = random.Range(-halfCellSize, halfCellSize); 20 | outPosition.z = random.Range(-halfCellSize, halfCellSize); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Scripts/Dungeon/Rules/GrassTransformRule.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7c39ffff1d395459bbbbbb05be7fbf48 3 | timeCreated: 1474622171 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Player.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7d58db8ff25bf4bf5a714ae34b26edd0 3 | folderAsset: yes 4 | timeCreated: 1474631507 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Scripts/Player/PlayerController.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using UnityStandardAssets.Vehicles.Car; 4 | 5 | namespace ZombieStory 6 | { 7 | public class PlayerController : MonoBehaviour 8 | { 9 | public string startWeapon; 10 | public Transform weaponOffset; 11 | public WeaponRegistry weaponRegistry; 12 | public float timeToHoster = 2; 13 | public float headTiltTime = 0.2f; 14 | public float maxVehicleMountDistance = 2.0f; 15 | public GameObject playerPawn; 16 | public CameraFollow cameraFollow; 17 | 18 | PlayerShooting shooting; 19 | CharacterController character; 20 | WeaponItem currentWeapon; 21 | Animator anim; 22 | CarUserControl mountedVehicle; 23 | bool weaponAiming = false; 24 | float weaponHeadTilt = 0; 25 | 26 | 27 | 28 | Tween headTilt = new Tween(); 29 | 30 | void Awake() 31 | { 32 | anim = playerPawn.GetComponentInChildren(); 33 | shooting = playerPawn.GetComponentInChildren(); 34 | character = playerPawn.GetComponent(); 35 | Possess(playerPawn); 36 | } 37 | 38 | void Possess(GameObject pawn) 39 | { 40 | cameraFollow.target = pawn.transform; 41 | } 42 | 43 | void OnWeaponAimStart() 44 | { 45 | headTilt.Init(headTilt.Value, weaponHeadTilt, headTiltTime, TweenMode.EaseIn); 46 | } 47 | void OnWeaponAimStop() 48 | { 49 | headTilt.Init(headTilt.Value, 0, headTiltTime, TweenMode.EaseIn); 50 | } 51 | 52 | void Start() 53 | { 54 | SetWeapon(startWeapon); 55 | } 56 | 57 | void Update() 58 | { 59 | if (Input.GetKeyDown(KeyCode.LeftControl)) 60 | { 61 | ChangeToNextWeapon(); 62 | } 63 | 64 | if (Input.GetKeyDown(KeyCode.E)) 65 | { 66 | if (mountedVehicle != null) 67 | { 68 | ExitVehicle(); 69 | } else 70 | { 71 | EnterNearestVehicle(); 72 | } 73 | } 74 | } 75 | 76 | void EnterNearestVehicle() 77 | { 78 | var vehicle = GameUtils.GetNearestObjectWithTag(playerPawn.transform.position, GameTags.Vehicle); 79 | if (vehicle == null) return; 80 | 81 | var distanceToVehicle = (playerPawn.transform.position - vehicle.transform.position).magnitude; 82 | if (distanceToVehicle > maxVehicleMountDistance) 83 | { 84 | // nearest vehicle is too far to mount 85 | return; 86 | } 87 | 88 | // Enter the vehicle 89 | mountedVehicle = vehicle.GetComponent(); 90 | if (mountedVehicle == null) return; 91 | 92 | mountedVehicle.enabled = true; 93 | mountedVehicle.mounted = true; 94 | playerPawn.gameObject.SetActive(false); 95 | Possess(mountedVehicle.gameObject); 96 | cameraFollow.zoomFactor = 2.0f; 97 | } 98 | 99 | void ExitVehicle() 100 | { 101 | mountedVehicle.mounted = false; 102 | // Place the player next to the vehicle 103 | Transform vehicleTransform = mountedVehicle.gameObject.transform; 104 | var newPlayerPosition = vehicleTransform.position + vehicleTransform.rotation * new Vector3(2, 0.25f, 0); 105 | 106 | playerPawn.gameObject.transform.position = newPlayerPosition; 107 | playerPawn.gameObject.SetActive(true); 108 | Possess(playerPawn); 109 | cameraFollow.zoomFactor = 1.0f; 110 | mountedVehicle = null; 111 | } 112 | 113 | 114 | void ChangeToNextWeapon() 115 | { 116 | SetWeapon(weaponRegistry.GetNextWeapon(currentWeapon)); 117 | } 118 | 119 | void SetWeapon(string weaponId) 120 | { 121 | var item = weaponRegistry.GetWeapon(weaponId); 122 | SetWeapon(item); 123 | } 124 | 125 | void SetWeapon(WeaponItem item) 126 | { 127 | var sfx = weaponRegistry.GetWeaponSfx(item.sfxName); 128 | 129 | // Destroy the existing weapon 130 | GameUtils.DestroyAllChildren(weaponOffset); 131 | 132 | if (item.template != null) 133 | { 134 | var weapon = GameObject.Instantiate(item.template); 135 | weapon.transform.SetParent(weaponOffset, false); 136 | } 137 | 138 | currentWeapon = item; 139 | 140 | var weaponAudio = weaponRegistry.GetWeaponSfx(currentWeapon.sfxName); 141 | shooting.OnWeaponChanged(currentWeapon, weaponAudio); 142 | 143 | if (item.roundsPerSecond == 0) 144 | { 145 | item.roundsPerSecond = 1; 146 | } 147 | } 148 | 149 | void FixedUpdate() 150 | { 151 | bool oldAimingState = weaponAiming; 152 | weaponAiming = shooting.TimeSinceLastShot < timeToHoster; 153 | headTilt.Update(Time.fixedDeltaTime); 154 | 155 | int weaponAnimationId = weaponAiming ? currentWeapon.animationIndex : 0; 156 | anim.SetInteger("WeaponType_int", weaponAnimationId); 157 | 158 | float speed = 0.0f; 159 | if (character != null) 160 | { 161 | speed = character.velocity.magnitude; 162 | } 163 | 164 | if (anim != null) 165 | { 166 | anim.SetFloat("Speed_f", speed); 167 | } 168 | 169 | SetupBodyOrientation(speed); 170 | SetupHeadTilt(); 171 | 172 | // Notify if the weapon aim state has changed 173 | if (weaponAiming != oldAimingState) 174 | { 175 | if (weaponAiming) 176 | { 177 | OnWeaponAimStart(); 178 | } 179 | else 180 | { 181 | OnWeaponAimStop(); 182 | } 183 | } 184 | 185 | bool fullAuto = currentWeapon.fullAuto; 186 | anim.SetBool("Shoot_b", shooting.IsShooting); 187 | anim.SetBool("FullAuto_b", fullAuto); 188 | } 189 | 190 | enum PlayerMoveAnimState 191 | { 192 | Idle, 193 | Walk, 194 | Run 195 | } 196 | 197 | public void SetupBodyOrientation(float speed) { 198 | int weaponIndex = currentWeapon.animationIndex; 199 | PlayerMoveAnimState animState = PlayerMoveAnimState.Idle; 200 | if (speed <= 1e-4f) 201 | { 202 | animState = PlayerMoveAnimState.Idle; 203 | } 204 | else if (speed <= 0.1f) 205 | { 206 | animState = PlayerMoveAnimState.Idle; 207 | } 208 | else 209 | { 210 | animState = PlayerMoveAnimState.Run; 211 | } 212 | 213 | float bodyH = 0; 214 | float bodyV = 0; 215 | 216 | if (weaponIndex == (int)WeaponCategory.NoWeapon) 217 | { 218 | bodyH = 0; 219 | bodyV = 0; 220 | } 221 | else if (weaponIndex == (int)WeaponCategory.Pistol) 222 | { 223 | switch(animState) 224 | { 225 | case PlayerMoveAnimState.Idle: bodyH = 0; bodyV = 0; break; 226 | case PlayerMoveAnimState.Walk: bodyH = 0; bodyV = 0; break; 227 | case PlayerMoveAnimState.Run: bodyH = 0.2f; bodyV = 0; break; 228 | } 229 | } 230 | else 231 | { 232 | switch (animState) 233 | { 234 | case PlayerMoveAnimState.Idle: bodyH = 0.6f; bodyV = 0; break; 235 | case PlayerMoveAnimState.Walk: bodyH = 0.6f; bodyV = 0; break; 236 | case PlayerMoveAnimState.Run: bodyH = 0.6f; bodyV = 0.3f; break; 237 | } 238 | } 239 | 240 | anim.SetFloat("Body_Horizontal_f", bodyH); 241 | anim.SetFloat("Body_Vertical_f", bodyV); 242 | } 243 | 244 | public void SetupHeadTilt() 245 | { 246 | if (weaponAiming) 247 | { 248 | int weaponIndex = currentWeapon.animationIndex; 249 | if (weaponIndex == (int)WeaponCategory.NoWeapon) 250 | { 251 | weaponHeadTilt = 0; 252 | } 253 | else if (weaponIndex == (int)WeaponCategory.Pistol) 254 | { 255 | weaponHeadTilt = -0.3f; 256 | } 257 | else if (weaponIndex == (int)WeaponCategory.Grenades) 258 | { 259 | weaponHeadTilt = 0; 260 | } 261 | else 262 | { 263 | weaponHeadTilt = -0.9f; 264 | } 265 | } 266 | 267 | float currentTilt = headTilt.Value; 268 | anim.SetFloat("Head_Horizontal_f", headTilt.Value); 269 | } 270 | } 271 | } 272 | -------------------------------------------------------------------------------- /Scripts/Player/PlayerController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37e0b919f2c2f4a388745c811cbb530c 3 | timeCreated: 1474631515 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Player/WeaponInfo.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class WeaponInfo : MonoBehaviour { 5 | 6 | // Use this for initialization 7 | void Start () { 8 | 9 | } 10 | 11 | // Update is called once per frame 12 | void Update () { 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Scripts/Player/WeaponInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da1a875c5ba3042b188a25459c8fcb14 3 | timeCreated: 1474633876 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Player/WeaponRegistry.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | [System.Serializable] 5 | public struct WeaponItem { 6 | public string weaponId; 7 | public WeaponCategory weaponCategory; 8 | public GameObject template; 9 | public Vector3 barrelOffset; 10 | public float roundsPerSecond; 11 | public bool fullAuto; 12 | public int animationIndex; 13 | public string sfxName; 14 | } 15 | 16 | [System.Serializable] 17 | public struct WeaponSfx { 18 | public string sfxId; 19 | public float volume; 20 | public AudioClip sfx; 21 | } 22 | 23 | public enum WeaponCategory 24 | { 25 | NoWeapon = 0, 26 | Pistol, 27 | AssultRifle01, 28 | AssultRifle02, 29 | Shotgun, 30 | SniperRifle, 31 | Rifle, 32 | SubMachineGun, 33 | RPG, 34 | MiniGun, 35 | Grenades, 36 | Melee 37 | } 38 | 39 | public class WeaponRegistry : MonoBehaviour { 40 | 41 | public WeaponItem[] weapons; 42 | 43 | public WeaponSfx[] weaponSounds; 44 | 45 | public WeaponItem GetWeapon(string weaponId) { 46 | foreach (var weapon in weapons) { 47 | if (weapon.weaponId == weaponId) { 48 | return weapon; 49 | } 50 | } 51 | return new WeaponItem(); 52 | } 53 | 54 | public WeaponItem GetNextWeapon(WeaponItem currentItem) 55 | { 56 | int index = System.Array.FindIndex(weapons, p => p.weaponId == currentItem.weaponId); 57 | if (index == -1) { 58 | return currentItem; 59 | } 60 | int nextIndex = (index + 1) % weapons.Length; 61 | return weapons[nextIndex]; 62 | } 63 | 64 | public WeaponSfx GetWeaponSfx(string sfxId) { 65 | foreach (var sfx in weaponSounds) { 66 | if (sfx.sfxId == sfxId) { 67 | return sfx; 68 | } 69 | } 70 | return new WeaponSfx(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Scripts/Player/WeaponRegistry.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9108ed0f645f146d7ad7507f5bb12b53 3 | timeCreated: 1474634072 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c14e520c76f8b9b41add84bf93bf64fe 3 | folderAsset: yes 4 | timeCreated: 1479023602 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/AI.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 69af9ab3ce04946a599a2ecf54243364 3 | folderAsset: yes 4 | timeCreated: 1452330652 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/AI/AIController.cs: -------------------------------------------------------------------------------- 1 | //$ Copyright 2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $// 2 | 3 | using UnityEngine; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | using DungeonArchitect; 7 | using DungeonArchitect.Navigation; 8 | 9 | namespace ZombieStory 10 | { 11 | public class AIStateBase : StateBase { 12 | protected AIController controller; 13 | 14 | public AIStateBase(AIController controller, float updateDelay) { 15 | this.controller = controller; 16 | 17 | } 18 | 19 | protected virtual void HandleFrameUpdate (float elapsedTime) { 20 | } 21 | 22 | public override void Update() { 23 | 24 | // if we are not already dead, then check for the player health 25 | var isInDeathState = (this is AIStateDead); 26 | if (!isInDeathState) { 27 | if (!controller.enabled) { 28 | // Player is no longer alive. Move to the dead state 29 | var deadState = new AIStateDead(controller); 30 | stateMachine.MoveTo(deadState); 31 | } 32 | } 33 | 34 | HandleFrameUpdate(Time.deltaTime); 35 | } 36 | 37 | protected bool IsWithinPlayerProximity(ref Collider outCollider, float radius) { 38 | return false; 39 | } 40 | 41 | protected GameObject GetPlayer() { 42 | return GameObject.FindGameObjectWithTag(GameTags.Player); 43 | } 44 | 45 | protected bool IsPlayerVisible() { 46 | if (controller.mode2D) { 47 | return IsPlayerVisible2D(); 48 | } else { 49 | return IsPlayerVisible3D(); 50 | } 51 | } 52 | 53 | protected bool IsPlayerVisible2D() { 54 | var source = controller.gameObject.transform.position; 55 | var colliders = Physics2D.OverlapCircleAll(source, controller.maxViewSight); 56 | 57 | Collider2D player = null; 58 | foreach (var collider in colliders) { 59 | if (collider.isTrigger) continue; 60 | if (collider.gameObject.CompareTag(GameTags.Player)) { 61 | player = collider; 62 | break; 63 | } 64 | } 65 | 66 | if (player == null) { 67 | return false; 68 | } 69 | 70 | var target = player.gameObject.transform.position; 71 | 72 | // Check if the player is too close the npc 73 | var distanceSq = (source - target).sqrMagnitude; 74 | if (distanceSq <= controller.playerCloseByDistance * controller.playerCloseByDistance) { 75 | // Player is too close to the npc and will be detected, regardless of whether it sees it or not 76 | return true; 77 | } 78 | 79 | // Check if the player is within the NPC's field of vision 80 | { 81 | var forward3D = controller.Agent.Velocity.normalized; 82 | var forward = new Vector2(forward3D.x, forward3D.z); 83 | var toPlayer = (target - controller.gameObject.transform.position).normalized; 84 | var angle = Vector3.Angle(forward, toPlayer); 85 | if (angle > controller.fieldOfView / 2.0f) { 86 | // Not within the field of vision 87 | return false; 88 | } 89 | } 90 | 91 | 92 | // The player is within the vision cone. 93 | // Make a raycast and check if any objects are obstructing the vision (e.g. walls) 94 | var offset = Vector3.zero; 95 | var direction = (target - source).normalized; 96 | var hits = Physics2D.RaycastAll(source + offset, direction, controller.maxViewSight); 97 | 98 | // Sort the hits based on distance 99 | System.Array.Sort(hits, delegate(RaycastHit2D x, RaycastHit2D y) { 100 | if (x.distance == y.distance) return 0; 101 | return x.distance < y.distance ? -1 : 1; 102 | }); 103 | 104 | var hitPlayer = false; 105 | foreach (var hit in hits) { 106 | if (hit.collider.isTrigger) continue; 107 | //if (hit.collider.gameObject.CompareTag(GameTags.Enemy)) continue; 108 | 109 | if (hit.collider == player) { 110 | hitPlayer = true; 111 | } 112 | break; 113 | } 114 | 115 | return hitPlayer; 116 | } 117 | 118 | protected bool IsPlayerVisible3D() { 119 | var source = controller.gameObject.transform.position; 120 | var colliders = Physics.OverlapSphere(source, controller.maxViewSight); 121 | 122 | Collider player = null; 123 | foreach (var collider in colliders) { 124 | if (collider.isTrigger) continue; 125 | if (collider.gameObject.CompareTag(GameTags.Player)) { 126 | player = collider; 127 | break; 128 | } 129 | } 130 | 131 | if (player == null) { 132 | return false; 133 | } 134 | 135 | var target = player.gameObject.transform.position; 136 | 137 | // Check if the player is too close the npc 138 | var distanceSq = (source - target).sqrMagnitude; 139 | if (distanceSq <= controller.playerCloseByDistance * controller.playerCloseByDistance) { 140 | // Player is too close to the npc and will be detected, regardless of whether it sees it or not 141 | return true; 142 | } 143 | 144 | // Check if the player is within the NPC's field of vision 145 | { 146 | var forward = controller.gameObject.transform.forward; 147 | var toPlayer = (target - controller.gameObject.transform.position).normalized; 148 | var angle = Vector3.Angle(forward, toPlayer); 149 | if (angle > controller.fieldOfView / 2.0f) { 150 | // Not within the field of vision 151 | return false; 152 | } 153 | } 154 | 155 | 156 | // The player is within the vision cone. 157 | // Make a raycast and check if any objects are obstructing the vision (e.g. walls) 158 | var offset = Vector3.up; 159 | var direction = (target - source).normalized; 160 | var hits = Physics.RaycastAll(source + offset, direction, controller.maxViewSight); 161 | 162 | // Sort the hits based on distance 163 | System.Array.Sort(hits, delegate(RaycastHit x, RaycastHit y) { 164 | if (x.distance == y.distance) return 0; 165 | return x.distance < y.distance ? -1 : 1; 166 | }); 167 | 168 | var hitPlayer = false; 169 | foreach (var hit in hits) { 170 | if (hit.collider.isTrigger) continue; 171 | //if (hit.collider.gameObject.CompareTag(GameTags.Enemy.ToLower())) continue; 172 | 173 | if (hit.collider == player) { 174 | hitPlayer = true; 175 | } 176 | break; 177 | } 178 | 179 | return hitPlayer; 180 | } 181 | } 182 | 183 | /** If the player is not visible, it moves to the last know position from the controller's last sighting */ 184 | public class AIStateMoveToLastKnownPosition : AIStateBase { 185 | 186 | public AIStateMoveToLastKnownPosition(AIController controller) : base(controller, 0.1f) {} 187 | 188 | public override void OnEnter() { 189 | var hasSighting = controller.LastSighting.HasSighting(); 190 | if (hasSighting) { 191 | // Start moving to the last know sighting of the player 192 | controller.Agent.Resume(); 193 | controller.Agent.Destination = controller.LastSighting.Position; 194 | } 195 | else { 196 | // Should not happen 197 | // Move to the patrol state if it does 198 | var patrol = new AIStatePatrol(controller); 199 | stateMachine.MoveTo(patrol); 200 | } 201 | } 202 | 203 | public override void Update() { 204 | base.Update(); 205 | } 206 | 207 | protected override void HandleFrameUpdate (float elapsedTime) 208 | { 209 | base.HandleFrameUpdate(elapsedTime); 210 | 211 | // Check if we can see the player 212 | if (IsPlayerVisible()) { 213 | // The player is visible. Start persuit of the player 214 | var persuit = new AIStatePersuit(controller); 215 | stateMachine.MoveTo(persuit); 216 | return; 217 | } 218 | 219 | // Check if we are near the last sighting position; 220 | if (controller.Agent.GetRemainingDistance() < controller.destinationArriveProximity) { 221 | // We have reached the last sighting position and still haven't found the player 222 | // Stand here and wait for a bit before returing to patrolling 223 | var waitAndSearch = new AIStateWaitAndSearch(controller); 224 | stateMachine.MoveTo(waitAndSearch); 225 | } 226 | } 227 | } 228 | 229 | /** If the player is not visible, it moves to the last know position from the controller's last sighting */ 230 | public class AIStateWaitAndSearch : AIStateBase { 231 | public AIStateWaitAndSearch(AIController controller) : base(controller, 0.1f) {} 232 | public float timeSinceStart = 0; 233 | public override void OnEnter() { 234 | base.OnEnter(); 235 | controller.Agent.Stop(); 236 | } 237 | 238 | protected override void HandleFrameUpdate (float elapsedTime) 239 | { 240 | base.HandleFrameUpdate(elapsedTime); 241 | 242 | // Check if the player is visible 243 | if (IsPlayerVisible()) { 244 | // Start persuit of the player 245 | var persuit = new AIStatePersuit(controller); 246 | stateMachine.MoveTo (persuit); 247 | } 248 | 249 | timeSinceStart += elapsedTime; 250 | if (timeSinceStart >= controller.searchWaitTime) { 251 | // The player is not found and is lost. Clear the last sighting variable 252 | controller.LastSighting.ClearSighting(); 253 | 254 | // Return back to the patrol state 255 | var patrol = new AIStatePatrol(controller); 256 | stateMachine.MoveTo(patrol); 257 | } 258 | } 259 | } 260 | 261 | public class AIStatePersuit : AIStateBase { 262 | Transform followTarget; 263 | 264 | public AIStatePersuit(AIController controller) : base(controller, 0.1f) {} 265 | 266 | public override void OnEnter() { 267 | // Find the player 268 | var playerObject = GetPlayer(); 269 | if (playerObject != null) { 270 | followTarget = playerObject.transform; 271 | } 272 | 273 | controller.Agent.Resume(); 274 | } 275 | 276 | public override void OnExit() { 277 | controller.Agent.Stop(); 278 | } 279 | 280 | public override void Update() { 281 | base.Update(); 282 | 283 | } 284 | 285 | protected override void HandleFrameUpdate (float elapsedTime) 286 | { 287 | base.HandleFrameUpdate(elapsedTime); 288 | 289 | Collider playerCollider = null; 290 | if (IsWithinPlayerProximity(ref playerCollider, controller.playerProximityRadius)) { 291 | // close to the player. Move to the attack state 292 | } else { 293 | // Move to the player 294 | controller.Agent.Destination = followTarget.position; 295 | } 296 | 297 | if (!IsPlayerVisible()) { 298 | // Move to the last know position 299 | if (controller.LastSighting.HasSighting()) { 300 | var moveToLastKnown = new AIStateMoveToLastKnownPosition(controller); 301 | stateMachine.MoveTo(moveToLastKnown); 302 | } else { 303 | // We don't have a last know position. Resume patroling 304 | var patrol = new AIStatePatrol(controller); 305 | stateMachine.MoveTo(patrol); 306 | } 307 | return; 308 | } else { 309 | // Player is visible. Update the last sighting 310 | controller.LastSighting.Position = followTarget.position; 311 | } 312 | } 313 | 314 | } 315 | 316 | 317 | public class AIStatePatrol : AIStateBase { 318 | int currentWaypointIndex = 0; 319 | 320 | // Apply some offset to the waypoints so they don't reach the exact waypoint position 321 | Vector3[] waypointOffsets; 322 | 323 | public AIStatePatrol(AIController controller) : base(controller, 0.1f) {} 324 | 325 | public override void OnEnter() { 326 | controller.Agent.Resume(); 327 | 328 | // Since we entered the patrol state, the player is not visible 329 | controller.LastSighting.ClearSighting(); 330 | 331 | { 332 | var offsets = new List(); 333 | var waypoints = controller.Patrol.PatrolPoints; 334 | for(int i = 0; i < waypoints.Length; i++) { 335 | var offset = Random.insideUnitSphere * controller.Patrol.randomOffset; 336 | offset.y = 0; 337 | offsets.Add (offset); 338 | } 339 | waypointOffsets = offsets.ToArray(); 340 | } 341 | } 342 | 343 | void MoveToCurrentPoint() { 344 | var waypoints = controller.Patrol.PatrolPoints; 345 | if (waypoints.Length == 0) return; 346 | 347 | currentWaypointIndex = currentWaypointIndex % waypoints.Length; 348 | var point = waypoints[currentWaypointIndex]; 349 | if (point == null) return; 350 | var offset = waypointOffsets[currentWaypointIndex % waypointOffsets.Length]; 351 | 352 | controller.Agent.Destination = point.gameObject.transform.position + offset; 353 | } 354 | 355 | public override void OnExit() { 356 | } 357 | 358 | public override void Update() { 359 | base.Update(); 360 | } 361 | 362 | protected override void HandleFrameUpdate (float elapsedTime) 363 | { 364 | base.HandleFrameUpdate(elapsedTime); 365 | 366 | if (IsPlayerVisible()) { 367 | var persuit = new AIStatePersuit(controller); 368 | stateMachine.MoveTo(persuit); 369 | return; 370 | } 371 | 372 | // Since the player is not visible while we are patrolling, clear the last sighting 373 | controller.LastSighting.ClearSighting(); 374 | 375 | var agent = controller.Agent; 376 | 377 | if (agent.GetRemainingDistance() < controller.destinationArriveProximity) { 378 | currentWaypointIndex++; 379 | } 380 | MoveToCurrentPoint(); 381 | } 382 | } 383 | 384 | enum AIAttackAnimState { 385 | Requested, 386 | Running, 387 | InterAttackWait 388 | } 389 | 390 | 391 | 392 | public class AIStateDead : AIStateBase { 393 | public AIStateDead(AIController controller) : base(controller, 0.1f) {} 394 | 395 | public override void OnEnter() { 396 | base.OnEnter(); 397 | controller.Agent.Stop(); 398 | controller.Agent.enabled = false; 399 | controller.Capsule.enabled = false; 400 | } 401 | 402 | public override void OnExit() { 403 | base.OnExit(); 404 | } 405 | } 406 | 407 | 408 | public class AIStateIdle : AIStateBase { 409 | public AIStateIdle(AIController controller) : base(controller, 0.1f) {} 410 | 411 | public override void OnEnter() { 412 | base.OnEnter(); 413 | 414 | controller.Agent.Stop(); 415 | 416 | controller.LastSighting.ClearSighting(); 417 | } 418 | 419 | public override void OnExit() { 420 | base.OnExit(); 421 | } 422 | 423 | protected override void HandleFrameUpdate (float elapsedTime) 424 | { 425 | base.HandleFrameUpdate(elapsedTime); 426 | 427 | // Check if the player is visible 428 | if (IsPlayerVisible()) { 429 | // Start persuit of the player 430 | var persuit = new AIStatePersuit(controller); 431 | stateMachine.MoveTo (persuit); 432 | } 433 | } 434 | } 435 | 436 | 437 | public class AIController : CharacterControlScript { 438 | DungeonNavAgent agent; 439 | PatrolPath patrol; 440 | CapsuleCollider capsule; 441 | LastPlayerSighting lastSighting; 442 | 443 | public bool hasPatrolling = true; 444 | public float fieldOfView = 120; 445 | public float maxViewSight = 12; 446 | public float searchWaitTime = 3; 447 | public float playerCloseByDistance = 4; // if the player is too close, the npc should detect it even if not facing the player 448 | public float destinationArriveProximity = 1; // How close should the agent be to the destination to consider it arrived 449 | public float playerProximityRadius = 3.0f; 450 | public bool mode2D = false; 451 | 452 | public DungeonNavAgent Agent { 453 | get { 454 | return agent; 455 | } 456 | } 457 | 458 | public CapsuleCollider Capsule { 459 | get { 460 | return capsule; 461 | } 462 | } 463 | 464 | public PatrolPath Patrol { 465 | get { 466 | return patrol; 467 | } 468 | } 469 | 470 | 471 | public LastPlayerSighting LastSighting { 472 | get { 473 | return lastSighting; 474 | } 475 | } 476 | 477 | protected override void Initialize() { 478 | capsule = GetComponent(); 479 | patrol = GetComponent(); 480 | agent = GetComponent(); 481 | lastSighting = GetComponent(); 482 | 483 | State startState = null; 484 | if (hasPatrolling) { 485 | startState = new AIStatePatrol(this); 486 | } else { 487 | startState = new AIStateIdle(this); 488 | } 489 | 490 | stateMachine.MoveTo(startState); 491 | } 492 | 493 | public override bool GetInputJump() { 494 | return false; 495 | } 496 | public override bool GetInputAttackPrimary() { 497 | return false; 498 | } 499 | 500 | public override bool IsGrounded() { 501 | return true; 502 | } 503 | 504 | public override void ApplyMovement(Vector3 velocity) { 505 | 506 | } 507 | 508 | } 509 | } -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/AI/AIController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0aa3e6f2a08d045e58c92770244b3cc4 3 | timeCreated: 1452330976 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/AI/CharacterControlScript.cs: -------------------------------------------------------------------------------- 1 | //$ Copyright 2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $// 2 | 3 | using UnityEngine; 4 | using System.Collections; 5 | 6 | 7 | namespace ZombieStory 8 | { 9 | public abstract class CharacterControlScript : MonoBehaviour { 10 | protected StateMachine stateMachine; 11 | 12 | 13 | // Use this for initialization 14 | void Start () { 15 | stateMachine = new StateMachine(); 16 | 17 | Initialize (); 18 | } 19 | 20 | protected virtual void Initialize() {} 21 | 22 | // Update is called once per frame 23 | void FixedUpdate () { 24 | 25 | } 26 | 27 | void Update() { 28 | stateMachine.Update(); 29 | } 30 | 31 | public abstract bool GetInputJump(); 32 | public abstract bool GetInputAttackPrimary(); 33 | public abstract bool IsGrounded(); 34 | public abstract void ApplyMovement(Vector3 velocity); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/AI/CharacterControlScript.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2a169cf4e88bd44888fd981085fc7be8 3 | timeCreated: 1452330976 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/AI/LastPlayerSighting.cs: -------------------------------------------------------------------------------- 1 | //$ Copyright 2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $// 2 | 3 | using UnityEngine; 4 | using System.Collections; 5 | 6 | namespace ZombieStory 7 | { 8 | public class LastPlayerSighting : MonoBehaviour { 9 | static readonly Vector3 NO_SIGHTING = new Vector3(-10000, -10000, -10000); 10 | 11 | Vector3 position; 12 | public Vector3 Position { 13 | get { 14 | return position; 15 | } 16 | set { 17 | position = value; 18 | } 19 | } 20 | 21 | public void ClearSighting() { 22 | position = NO_SIGHTING; 23 | } 24 | 25 | public bool HasSighting() { 26 | return position != NO_SIGHTING; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/AI/LastPlayerSighting.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 051e6b348e0794175b58500263b7a753 3 | timeCreated: 1452330652 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/AI/LevelNpcSpawner.cs: -------------------------------------------------------------------------------- 1 | //$ Copyright 2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $// 2 | 3 | using UnityEngine; 4 | using System.Collections.Generic; 5 | using DungeonArchitect; 6 | 7 | namespace ZombieStory 8 | { 9 | public class LevelNpcSpawner : DungeonEventListener { 10 | public GameObject parentObject; 11 | public GameObject[] npcTemplates; 12 | public Vector3 npcOffset = Vector3.zero; 13 | public float spawnProbability = 0.25f; 14 | 15 | public override void OnPostDungeonBuild (Dungeon dungeon, DungeonModel model) 16 | { 17 | RebuildNPCs(); 18 | } 19 | 20 | public void RebuildNPCs() { 21 | DestroyOldNpcs(); 22 | if (npcTemplates.Length == 0) return; 23 | 24 | var waypoints = GameObject.FindObjectsOfType(); 25 | 26 | // Spawn an npc in each waypoint 27 | foreach (var waypoint in waypoints) { 28 | if (Random.value < spawnProbability) 29 | { 30 | var position = waypoint.transform.position + npcOffset; 31 | position = GetValidPointOnNavMesh(position); 32 | var npcIndex = Random.Range(0, npcTemplates.Length); 33 | var template = npcTemplates[npcIndex]; 34 | var npc = Instantiate(template, position, Quaternion.identity) as GameObject; 35 | 36 | if (parentObject != null) 37 | { 38 | npc.transform.parent = parentObject.transform; 39 | } 40 | } 41 | } 42 | } 43 | 44 | Vector3 GetValidPointOnNavMesh(Vector3 position) { 45 | NavMeshHit hit; 46 | if (NavMesh.SamplePosition(position, out hit, 4.0f, NavMesh.AllAreas)) { 47 | return hit.position; 48 | } 49 | return position; 50 | } 51 | 52 | public override void OnDungeonDestroyed(Dungeon dungeon) { 53 | DestroyOldNpcs(); 54 | } 55 | 56 | void DestroyOldNpcs() { 57 | if (parentObject == null) { 58 | return; 59 | } 60 | 61 | var npcs = new List(); 62 | var parentTransform = parentObject.transform; 63 | for(int i = 0; i < parentTransform.childCount; i++) { 64 | var npc = parentObject.transform.GetChild(i).gameObject; 65 | npcs.Add(npc); 66 | } 67 | 68 | foreach (var npc in npcs) { 69 | if (Application.isPlaying) { 70 | Destroy(npc); 71 | } else { 72 | DestroyImmediate(npc); 73 | } 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/AI/LevelNpcSpawner.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b7945c19ca504ea7bdf6ded0382b251 3 | timeCreated: 1452330652 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/AI/PatrolPath.cs: -------------------------------------------------------------------------------- 1 | //$ Copyright 2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $// 2 | 3 | using UnityEngine; 4 | using System.Collections.Generic; 5 | 6 | namespace ZombieStory 7 | { 8 | public class PatrolPath : MonoBehaviour { 9 | public int minPathLength = 5; 10 | public int maxPathLength = 10; 11 | public float randomOffset = 2; 12 | 13 | /// 14 | /// The distance the agent has to come close to this waypoint to consider it as arrived 15 | /// 16 | public float proximityThreshold = 1.0f; 17 | 18 | Waypoint[] patrolPoints = new Waypoint[0]; 19 | bool looped = false; 20 | 21 | public bool Looped { 22 | get { 23 | return looped; 24 | } 25 | } 26 | 27 | public Waypoint[] PatrolPoints { 28 | get { 29 | return patrolPoints; 30 | } 31 | } 32 | 33 | // Use this for initialization 34 | void Awake () { 35 | Build (); 36 | } 37 | 38 | public void Build() { 39 | Build (gameObject.transform.position); 40 | } 41 | 42 | public void Build(Vector3 nearestStartingPoint) { 43 | // Find all the waypoints in the map 44 | var waypoints = GameObject.FindObjectsOfType(); 45 | var nearestWaypoint = FindNearest(waypoints, gameObject.transform.position); 46 | if (nearestWaypoint == null) { 47 | // No waypoints found 48 | Debug.LogWarning("No waypoints found in map for generating patrol path"); 49 | return; 50 | } 51 | 52 | // Build the waypoint lookup 53 | var waypointLookup = new Dictionary(); 54 | foreach (var waypoint in waypoints) { 55 | waypointLookup.Add (waypoint.id, waypoint); 56 | } 57 | var startingWaypoint = nearestWaypoint; 58 | 59 | patrolPoints = FindLoopedPath(startingWaypoint); 60 | if (patrolPoints != null) { 61 | looped = true; 62 | } else { 63 | patrolPoints = FindNonLoopedPath(startingWaypoint); 64 | looped = false; 65 | } 66 | 67 | if (patrolPoints == null) { 68 | Debug.LogWarning("PatrolPath: No suitable waypoint found"); 69 | patrolPoints = new Waypoint[0]; 70 | } 71 | } 72 | 73 | /// 74 | /// Uses DFS to trace the next non-looped path between the path length constraint 75 | /// 76 | /// The non looped path. 77 | /// Starting waypoint. 78 | Waypoint[] FindNonLoopedPath(Waypoint startingWaypoint) { 79 | var stack = new Stack>(); 80 | var startPath = new List(); 81 | startPath.Add(startingWaypoint); 82 | stack.Push(startPath); 83 | 84 | while (stack.Count > 0) { 85 | var topPath = stack.Pop(); 86 | var lastPoint = topPath[topPath.Count - 1]; 87 | 88 | var children = lastPoint.AdjacentWaypoints; 89 | // Suffle the child nodes before iterating for randomness 90 | children = Shuffle (children); 91 | 92 | var nextPathLength = topPath.Count + 1; // Add one to account for the next node that would be added 93 | foreach (var child in children) { 94 | var visited = topPath.Contains(child); 95 | if (visited) continue; 96 | 97 | var nextPath = new List(); 98 | nextPath.AddRange(topPath); 99 | nextPath.Add(child); 100 | 101 | // TODO: Add more randomness here to that the length varies between the min/max path length range 102 | if (nextPathLength >= minPathLength) { 103 | // Found our path with the desired length 104 | return nextPath.ToArray(); 105 | } 106 | stack.Push(nextPath); 107 | } 108 | } 109 | return null; 110 | } 111 | 112 | /// 113 | /// Uses BFS to trace a path back to the starting node, with the length between min/max constraint 114 | /// 115 | /// The looped path. 116 | /// Starting waypoint. 117 | Waypoint[] FindLoopedPath(Waypoint startingWaypoint) { 118 | if (startingWaypoint == null || startingWaypoint.AdjacentWaypoints.Length <= 0) { 119 | // A loop cannot be made when the starting node has only one outgoing path 120 | return null; 121 | } 122 | 123 | // Use BFS to find the nearest path; 124 | var queue = new Queue>(); 125 | var startPath = new List(); 126 | startPath.Add (startingWaypoint); 127 | queue.Enqueue(startPath); 128 | while (queue.Count > 0) { 129 | var topPath = queue.Dequeue(); 130 | 131 | var nextPathLength = topPath.Count + 1; // Add one to account for the next node that would be added 132 | if (nextPathLength > maxPathLength) { 133 | // Path will be too big if more nodes are added. bail out from this branch 134 | continue; 135 | } 136 | 137 | // Suffle the child nodes before iterating for randomness 138 | var validPathLength = (topPath.Count >= minPathLength && topPath.Count <= maxPathLength); 139 | 140 | var lastPoint = topPath[topPath.Count - 1]; 141 | var children = lastPoint.AdjacentWaypoints; 142 | children = Shuffle(children); 143 | foreach (var child in children) { 144 | var visited = topPath.Contains(child); 145 | if (!visited) { 146 | var nextPath = new List(); 147 | nextPath.AddRange(topPath); 148 | nextPath.Add (child); 149 | queue.Enqueue(nextPath); 150 | } 151 | else if (validPathLength && child == startingWaypoint) { 152 | // The path length matches the constraint and the next child connects back to the starting point 153 | return topPath.ToArray(); 154 | } 155 | } 156 | } 157 | // No loops found 158 | return null; 159 | } 160 | 161 | Waypoint[] Shuffle(Waypoint[] data) { 162 | // TODO: Implement 163 | return data; 164 | } 165 | 166 | Waypoint FindNearest(Waypoint[] waypoints, Vector3 startingPoint) { 167 | float nearestDistance = float.MaxValue; 168 | Waypoint bestMatch = null; 169 | 170 | foreach (var waypoint in waypoints) { 171 | var distanceSq = (waypoint.gameObject.transform.position - startingPoint).sqrMagnitude; 172 | if (nearestDistance > distanceSq) { 173 | bestMatch = waypoint; 174 | nearestDistance = distanceSq; 175 | } 176 | } 177 | 178 | return bestMatch; 179 | } 180 | 181 | void OnDrawGizmosSelected() { 182 | VisualizePath(); 183 | } 184 | 185 | void VisualizePath() { 186 | Gizmos.color = new Color(1, 0.5f, 0); 187 | for (int i = 0; i < patrolPoints.Length; i++) { 188 | if (!looped && i == patrolPoints.Length - 1) { 189 | // Dont draw the last line if we dont loop 190 | break; 191 | } 192 | var startPoint = patrolPoints[i]; 193 | var endPoint = patrolPoints[(i + 1) % patrolPoints.Length]; 194 | var start = startPoint.gameObject.transform.position; 195 | var end = endPoint.gameObject.transform.position; 196 | DrawLine(start, end, false); 197 | } 198 | } 199 | void DrawLine(Vector3 a, Vector3 b, bool mode2D) { 200 | if (mode2D) { 201 | Gizmos.DrawLine(FlipYZ(a), FlipYZ(b)); 202 | } 203 | else { 204 | Gizmos.DrawLine(a, b); 205 | } 206 | } 207 | 208 | void DrawPoint(Vector3 p, bool mode2D) { 209 | if (mode2D) { 210 | Gizmos.DrawWireSphere(FlipYZ(p), 0.1f); 211 | } else { 212 | Gizmos.DrawWireSphere(p, 0.1f); 213 | } 214 | } 215 | 216 | Vector3 FlipYZ(Vector3 v) { 217 | return new Vector3(v.x, v.z, v.y); 218 | } 219 | } 220 | } 221 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/AI/PatrolPath.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cebbf487be88f43f2af5a59e47d6a282 3 | timeCreated: 1452330653 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/AI/SpecialRoomFinder.cs: -------------------------------------------------------------------------------- 1 | //$ Copyright 2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $// 2 | 3 | using UnityEngine; 4 | using System.Collections.Generic; 5 | using DungeonArchitect; 6 | using DungeonArchitect.Utils; 7 | using DungeonArchitect.Builders.Grid; 8 | using DungeonArchitect.Builders.SimpleCity; 9 | 10 | namespace ZombieStory 11 | { 12 | public class SpecialRoomFinder : DungeonEventListener { 13 | public GameObject levelEndGoalTemplate; 14 | 15 | /// 16 | /// Called after the dungeon is completely built 17 | /// 18 | /// The dungeon model 19 | public override void OnPostDungeonBuild(Dungeon dungeon, DungeonModel model) { 20 | if (model is GridDungeonModel) 21 | { 22 | // Handle the grid builder 23 | var gridModel = model as GridDungeonModel; 24 | 25 | var furthestCells = GridDungeonModelUtils.FindFurthestRooms(gridModel); 26 | if (furthestCells.Length == 2 && furthestCells[0] != null && furthestCells[1] != null) 27 | { 28 | var startCell = furthestCells[0]; 29 | var endCell = furthestCells[1]; 30 | 31 | SetStartingCell(gridModel, startCell); 32 | SetEndingCell(gridModel, endCell); 33 | } 34 | } 35 | else if (model is SimpleCityDungeonModel) 36 | { 37 | var cityModel = model as SimpleCityDungeonModel; 38 | 39 | // Randomly pick two road tiles 40 | var roadCells = new List(); 41 | for (int x = 0; x < cityModel.Cells.GetLength(0); x++) 42 | { 43 | for (int y = 0; y < cityModel.Cells.GetLength(1); y++) 44 | { 45 | var cell = cityModel.Cells[x, y]; 46 | if (cell.CellType == SimpleCityCellType.Road) 47 | { 48 | roadCells.Add(cell); 49 | } 50 | } 51 | } 52 | 53 | var startCell = roadCells[Random.Range(0, roadCells.Count)]; 54 | roadCells.Remove(startCell); 55 | var endCell = roadCells[Random.Range(0, roadCells.Count)]; 56 | 57 | SetStartingCell(cityModel, startCell); 58 | SetEndingCell(cityModel, endCell); 59 | } 60 | } 61 | 62 | public override void OnDungeonDestroyed(Dungeon dungeon) { 63 | DestroyAllLevelGoals(); 64 | } 65 | 66 | void SetStartingCell(GridDungeonModel model, Cell cell) { 67 | var roomCenter = MathUtils.GridToWorld(model.Config.GridCellSize, cell.CenterF); 68 | TeleportPlayerTo(roomCenter); 69 | } 70 | 71 | void SetStartingCell(SimpleCityDungeonModel model, SimpleCityCell cell) 72 | { 73 | var cellSize = new Vector3(model.Config.CellSize.x, 0, model.Config.CellSize.y); 74 | var position = Vector3.Scale( 75 | new Vector3(cell.Position.x, cell.Position.y, cell.Position.z), 76 | cellSize); 77 | 78 | TeleportPlayerTo(position); 79 | } 80 | 81 | void SetEndingCell(SimpleCityDungeonModel model, SimpleCityCell cell) 82 | { 83 | var cellSize = new Vector3(model.Config.CellSize.x, 0, model.Config.CellSize.y); 84 | var position = Vector3.Scale( 85 | new Vector3(cell.Position.x, cell.Position.y, cell.Position.z), 86 | cellSize); 87 | 88 | CreateLevelGoalAt(position); 89 | } 90 | 91 | 92 | void SetEndingCell(GridDungeonModel model, Cell cell) { 93 | var roomCenter = MathUtils.GridToWorld(model.Config.GridCellSize, cell.CenterF); 94 | CreateLevelGoalAt(roomCenter); 95 | } 96 | 97 | void TeleportPlayerTo(Vector3 position) 98 | { 99 | var player = GameObject.FindGameObjectWithTag(GameTags.Player); 100 | if (player != null) 101 | { 102 | player.transform.position = position; 103 | } 104 | } 105 | 106 | void CreateLevelGoalAt(Vector3 position) { 107 | // Destroy all old level goal objects 108 | DestroyAllLevelGoals(); 109 | 110 | var goal = Instantiate(levelEndGoalTemplate) as GameObject; 111 | goal.transform.position = position; 112 | 113 | if (goal.GetComponent() == null) 114 | { 115 | Debug.LogWarning("No LevelGoal component attached to the Level goal prefab. cleanup will not be proper"); 116 | } 117 | } 118 | 119 | void DestroyAllLevelGoals() 120 | { 121 | var oldGoals = GameObject.FindObjectsOfType(); 122 | foreach (var oldGoal in oldGoals) 123 | { 124 | var oldGoalObj = oldGoal.gameObject; 125 | if (oldGoalObj != null) 126 | { 127 | if (Application.isPlaying) 128 | { 129 | Destroy(oldGoalObj); 130 | } 131 | else 132 | { 133 | DestroyImmediate(oldGoalObj); 134 | } 135 | } 136 | } 137 | } 138 | 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/AI/SpecialRoomFinder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a490008e29f4f4bb0bf81617ea059ef0 3 | timeCreated: 1452420599 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/AI/StateMachine.cs: -------------------------------------------------------------------------------- 1 | //$ Copyright 2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $// 2 | 3 | using UnityEngine; 4 | using System.Collections.Generic; 5 | 6 | namespace ZombieStory 7 | { 8 | public enum GameMessages { 9 | } 10 | 11 | public interface State { 12 | void Update(); 13 | void FixedUpdate(); 14 | void OnEnter(); 15 | void OnExit(); 16 | void TransitionTo(string stateName); 17 | void OnMessage(GameMessages messageType, object userdata); 18 | StateMachine StateMachine { get; set; } 19 | } 20 | 21 | public abstract class StateBase : State { 22 | public virtual void Update() {} 23 | public virtual void FixedUpdate() {} 24 | public virtual void OnEnter() {} 25 | public virtual void OnExit() {} 26 | public virtual void TransitionTo(string stateName) {} 27 | public virtual void OnMessage(GameMessages messageType, object userdata) {} 28 | 29 | protected StateMachine stateMachine; 30 | public StateMachine StateMachine { 31 | get { 32 | return stateMachine; 33 | } 34 | set { 35 | stateMachine = value; 36 | } 37 | } 38 | 39 | } 40 | 41 | public class StateMachine { 42 | Stack stateStack = new Stack(); 43 | 44 | public State ActiveState { 45 | get { 46 | if (stateStack.Count == 0) return null; 47 | return stateStack.Peek(); 48 | } 49 | } 50 | 51 | public void MoveTo(State state) { 52 | if (stateStack.Count > 0) { 53 | var top = stateStack.Pop(); 54 | top.OnExit(); 55 | stateStack.Clear(); 56 | } 57 | state.StateMachine = this; 58 | stateStack.Push(state); 59 | state.OnEnter(); 60 | } 61 | 62 | public void PushTo(State state) { 63 | state.StateMachine = this; 64 | stateStack.Push(state); 65 | state.OnEnter(); 66 | } 67 | 68 | public void Pop() { 69 | if (stateStack.Count <= 1) return; 70 | var state = stateStack.Pop(); 71 | state.OnExit(); 72 | } 73 | 74 | // Update is called once per frame 75 | public void Update () { 76 | if (stateStack.Count == 0) return; 77 | var state = stateStack.Peek(); 78 | state.Update(); 79 | } 80 | 81 | public void SendMessage(GameMessages message, object userdata) { 82 | var state = ActiveState; 83 | if (state != null) { 84 | state.OnMessage(message, userdata); 85 | } 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/AI/StateMachine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8fd1907de2c374ce891c4c3c727110cf 3 | timeCreated: 1452331233 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Audio.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 728b0c6c6b840774dab9adee2ad7bb7e 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Audio/MixLevels.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using UnityEngine.Audio; 4 | 5 | namespace ZombieStory 6 | { 7 | public class MixLevels : MonoBehaviour { 8 | 9 | public AudioMixer masterMixer; 10 | 11 | public void SetSfxLvl(float sfxLvl) 12 | { 13 | masterMixer.SetFloat("sfxVol", sfxLvl); 14 | } 15 | 16 | public void SetMusicLvl (float musicLvl) 17 | { 18 | masterMixer.SetFloat ("musicVol", musicLvl); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Audio/MixLevels.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19ed055c6eb86c94ba753f5adfd3bf80 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Camera.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e32618ec2ce8ff4a888df54701d8903 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Camera/CameraFollow.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace ZombieStory 5 | { 6 | public class CameraFollow : MonoBehaviour 7 | { 8 | public Transform target; // The position that that camera will be following. 9 | public float positionSmoothing = 5f; // The speed with which the camera will be following. 10 | public float lookAtSmoothing = 5f; // The speed with which the camera will be following. 11 | public Vector3 offset; // The initial offset from the target. 12 | 13 | public float zoomFactor = 1.0f; 14 | 15 | Vector3 currentLookAt; 16 | 17 | void Start () 18 | { 19 | // Calculate the initial offset. 20 | //offset = transform.position - target.position; 21 | currentLookAt = target.position; 22 | } 23 | 24 | 25 | void FixedUpdate () 26 | { 27 | // Create a postion the camera is aiming for based on the offset from the target. 28 | Vector3 targetCamPos = target.position + offset * zoomFactor; 29 | 30 | // Smoothly interpolate between the camera's current position and it's target position. 31 | transform.position = Vector3.Lerp (transform.position, targetCamPos, positionSmoothing * Time.deltaTime); 32 | currentLookAt = Vector3.Lerp (currentLookAt, target.position, lookAtSmoothing * Time.deltaTime); 33 | transform.LookAt(currentLookAt); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Camera/CameraFollow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d7bced140059b694e91f0e48210059c7 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 200 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Enemy.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a0fa9ac57cf1a14d8c276eaaf79a8e9 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Enemy/EnemyAttack.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace ZombieStory 5 | { 6 | public class EnemyAttack : MonoBehaviour 7 | { 8 | public float timeBetweenAttacks = 0.5f; // The time in seconds between each attack. 9 | public int attackDamage = 10; // The amount of health taken away per attack. 10 | 11 | 12 | Animator anim; // Reference to the animator component. 13 | GameObject player; // Reference to the player GameObject. 14 | PlayerHealth playerHealth; // Reference to the player's health. 15 | EnemyHealth enemyHealth; // Reference to this enemy's health. 16 | bool playerInRange; // Whether player is within the trigger collider and can be attacked. 17 | float timer; // Timer for counting up to the next attack. 18 | 19 | 20 | void Awake () 21 | { 22 | // Setting up the references. 23 | player = GameObject.FindGameObjectWithTag ("Player"); 24 | playerHealth = player.GetComponent (); 25 | enemyHealth = GetComponent(); 26 | anim = GetComponent (); 27 | } 28 | 29 | 30 | void OnTriggerEnter (Collider other) 31 | { 32 | // If the entering collider is the player... 33 | if(other.gameObject == player) 34 | { 35 | // ... the player is in range. 36 | playerInRange = true; 37 | } 38 | } 39 | 40 | 41 | void OnTriggerExit (Collider other) 42 | { 43 | // If the exiting collider is the player... 44 | if(other.gameObject == player) 45 | { 46 | // ... the player is no longer in range. 47 | playerInRange = false; 48 | } 49 | } 50 | 51 | 52 | void Update () 53 | { 54 | // Add the time since Update was last called to the timer. 55 | timer += Time.deltaTime; 56 | 57 | // If the timer exceeds the time between attacks, the player is in range and this enemy is alive... 58 | if(timer >= timeBetweenAttacks && playerInRange && enemyHealth.currentHealth > 0) 59 | { 60 | // ... attack. 61 | Attack (); 62 | } 63 | 64 | // If the player has zero or less health... 65 | if(playerHealth.currentHealth <= 0) 66 | { 67 | // ... tell the animator the player is dead. 68 | anim.SetTrigger ("PlayerDead"); 69 | } 70 | } 71 | 72 | 73 | void Attack () 74 | { 75 | // Reset the timer. 76 | timer = 0f; 77 | 78 | // If the player has health to lose... 79 | if(playerHealth.currentHealth > 0) 80 | { 81 | // ... damage the player. 82 | playerHealth.TakeDamage (attackDamage); 83 | } 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Enemy/EnemyAttack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bc28e8f7dbbe7494a8d67b6f5f3636bc 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Enemy/EnemyHealth.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using DungeonArchitect; 4 | using DungeonArchitect.Navigation; 5 | 6 | namespace ZombieStory 7 | { 8 | public class EnemyHealth : MonoBehaviour 9 | { 10 | public int startingHealth = 100; // The amount of health the enemy starts the game with. 11 | public int currentHealth; // The current health the enemy has. 12 | public float sinkSpeed = 0.3f; // The speed at which the enemy sinks through the floor when dead. 13 | public int scoreValue = 10; // The amount added to the player's score when the enemy dies. 14 | public AudioClip deathClip; // The sound to play when the enemy dies. 15 | 16 | 17 | Animator anim; // Reference to the animator. 18 | AudioSource enemyAudio; // Reference to the audio source. 19 | ParticleSystem hitParticles; // Reference to the particle system that plays when the enemy is damaged. 20 | CharacterController character; // Reference to the capsule collider. 21 | bool isDead; // Whether the enemy is dead. 22 | bool isSinking; // Whether the enemy has started sinking through the floor. 23 | 24 | 25 | void Awake () 26 | { 27 | // Setting up the references. 28 | anim = GetComponent (); 29 | enemyAudio = GetComponent (); 30 | hitParticles = GetComponentInChildren (); 31 | character = GetComponent (); 32 | 33 | // Setting the current health when the enemy first spawns. 34 | currentHealth = startingHealth; 35 | } 36 | 37 | 38 | void Update () 39 | { 40 | // If the enemy should be sinking... 41 | if(isSinking) 42 | { 43 | // ... move the enemy down by the sinkSpeed per second. 44 | transform.Translate (-Vector3.up * sinkSpeed * Time.deltaTime); 45 | } 46 | } 47 | 48 | 49 | public void TakeDamage (int amount, Vector3 hitPoint) 50 | { 51 | // If the enemy is dead... 52 | if(isDead) 53 | // ... no need to take damage so exit the function. 54 | return; 55 | 56 | // Play the hurt sound effect. 57 | enemyAudio.Play (); 58 | 59 | // Reduce the current health by the amount of damage sustained. 60 | currentHealth -= amount; 61 | 62 | // Set the position of the particle system to where the hit was sustained. 63 | hitParticles.transform.position = hitPoint; 64 | 65 | // And play the particles. 66 | hitParticles.Play(); 67 | 68 | // If the current health is less than or equal to zero... 69 | if(currentHealth <= 0) 70 | { 71 | // ... the enemy is dead. 72 | Death (); 73 | } 74 | } 75 | 76 | 77 | void Death () 78 | { 79 | // The enemy is dead. 80 | isDead = true; 81 | 82 | // Turn the collider into a trigger so shots can pass through it. 83 | character.enabled = false; 84 | 85 | // Tell the animator that the enemy is dead. 86 | anim.SetTrigger ("Dead"); 87 | 88 | // Change the audio clip of the audio source to the death clip and play it (this will stop the hurt clip playing). 89 | enemyAudio.clip = deathClip; 90 | enemyAudio.Play (); 91 | } 92 | 93 | 94 | public void StartSinking () 95 | { 96 | StartCoroutine(StartSinkingAnimation()); 97 | } 98 | 99 | IEnumerator StartSinkingAnimation() { 100 | // Find and disable the Nav Mesh Agent. 101 | GetComponent ().enabled = false; 102 | 103 | // Increase the score by the enemy's score value. 104 | ScoreManager.score += scoreValue; 105 | 106 | // Wait before we start sinking 107 | yield return new WaitForSeconds(2.0f); 108 | 109 | // Start sinking 110 | isSinking = true; 111 | 112 | // Wait until we sink before we destroy 113 | yield return new WaitForSeconds(3.0f); 114 | Destroy (gameObject); 115 | } 116 | } 117 | } -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Enemy/EnemyHealth.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aa10cc87aff30c04dbe0aa648f5b6adc 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Enemy/EnemyMovement.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using DungeonArchitect; 4 | using DungeonArchitect.Navigation; 5 | 6 | namespace ZombieStory 7 | { 8 | public class EnemyMovement : MonoBehaviour 9 | { 10 | Transform player; // Reference to the player's position. 11 | PlayerHealth playerHealth; // Reference to the player's health. 12 | EnemyHealth enemyHealth; // Reference to this enemy's health. 13 | DungeonNavAgent navAgent; 14 | 15 | void Awake () 16 | { 17 | // Set up the references. 18 | player = GameObject.FindGameObjectWithTag ("Player").transform; 19 | playerHealth = player.GetComponent (); 20 | enemyHealth = GetComponent (); 21 | navAgent = GetComponent(); 22 | } 23 | 24 | void Update () 25 | { 26 | // If the enemy and the player have health left... 27 | if(enemyHealth.currentHealth > 0 && playerHealth.currentHealth > 0) 28 | { 29 | // ... set the destination of the nav mesh agent to the player. 30 | navAgent.Destination = player.position; 31 | } 32 | // Otherwise... 33 | else 34 | { 35 | // ... disable the nav mesh agent. 36 | navAgent.enabled = false; 37 | } 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Enemy/EnemyMovement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ea9a6ed18654d14db02bf0076cfe488 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Game.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 39ada3a66bbe4439fbdbba086e5559e0 3 | folderAsset: yes 4 | timeCreated: 1452425123 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Game/GameController.cs: -------------------------------------------------------------------------------- 1 | //$ Copyright 2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $// 2 | 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | using System.Collections; 6 | using DungeonArchitect; 7 | using DungeonArchitect.Utils; 8 | using DungeonArchitect.Navigation; 9 | 10 | namespace ZombieStory 11 | { 12 | public class GameController : MonoBehaviour { 13 | 14 | public AudioSource backgroundMusic; 15 | 16 | private static GameController instance; 17 | public Dungeon dungeon; 18 | public DungeonNavMesh navMesh; 19 | public GameObject minimap; 20 | 21 | public GameObject levelLoadingScreen; 22 | public Text textBuildingLayout; 23 | public Text textBuildingNavMesh; 24 | 25 | LevelNpcSpawner npcSpawner; 26 | string labelBuildingLayout = "Building Layout... "; 27 | string labelBuildingNavmesh = "Building Navmesh... "; 28 | 29 | Tween gameSoundVolume = new Tween(); 30 | 31 | public static GameController Instance { 32 | get { 33 | return instance; 34 | } 35 | } 36 | 37 | void Awake() { 38 | instance = this; 39 | npcSpawner = GetComponent(); 40 | backgroundMusic = GetComponent(); 41 | 42 | CreateNewLevel(); 43 | gameSoundVolume.Init(0, .8f, 2, TweenMode.EaseIn); 44 | } 45 | 46 | void Update() 47 | { 48 | // Update the game volume 49 | HandleAudio(); 50 | } 51 | 52 | void HandleAudio() 53 | { 54 | gameSoundVolume.Update(Time.deltaTime); 55 | backgroundMusic.volume = gameSoundVolume.Value; 56 | } 57 | 58 | public void CreateNewLevel() { 59 | if (dungeon != null) 60 | { 61 | // Assing a different seed to create a new layout 62 | int seed = Mathf.FloorToInt(Random.value * int.MaxValue); 63 | dungeon.Config.Seed = (uint)seed; 64 | 65 | // Rebuild a new dungeon 66 | StartCoroutine(RebuildLevel(dungeon)); 67 | } else 68 | { 69 | Debug.LogWarning("Dungeon references it not assigned"); 70 | } 71 | } 72 | 73 | IEnumerator RebuildLevel(Dungeon dungeon) { 74 | textBuildingNavMesh.gameObject.SetActive(false); 75 | levelLoadingScreen.SetActive(true); 76 | if (minimap != null) 77 | { 78 | minimap.SetActive(false); 79 | } 80 | 81 | textBuildingLayout.text = labelBuildingLayout; 82 | textBuildingLayout.gameObject.SetActive(true); 83 | yield return 0; 84 | 85 | dungeon.DestroyDungeon(); 86 | yield return 0; 87 | 88 | dungeon.Build(); 89 | 90 | textBuildingLayout.text = labelBuildingLayout + "DONE!"; 91 | 92 | textBuildingNavMesh.text = labelBuildingNavmesh; 93 | textBuildingNavMesh.gameObject.SetActive(true); 94 | yield return 0; 95 | 96 | 97 | RebuildNavigation(); 98 | 99 | npcSpawner.OnPostDungeonBuild(dungeon, dungeon.ActiveModel); 100 | 101 | levelLoadingScreen.SetActive(false); 102 | if (minimap != null) 103 | { 104 | minimap.SetActive(true); 105 | } 106 | 107 | // reset player health 108 | var player = GameObject.FindGameObjectWithTag(GameTags.Player); 109 | if (player != null) { 110 | var health = player.GetComponent(); 111 | if (health != null) { 112 | health.currentHealth = health.startingHealth; 113 | } 114 | } 115 | 116 | // Destroy any npc too close to the player 117 | var enemyControllers = GameObject.FindObjectsOfType(); 118 | var playerPosition = player.transform.position; 119 | foreach (var enemyController in enemyControllers) 120 | { 121 | var enemy = enemyController.gameObject; 122 | var distance = (playerPosition - enemy.transform.position).magnitude; 123 | if (distance < 1) { 124 | Destroy (enemy); 125 | } 126 | } 127 | } 128 | 129 | public void RebuildNavigation() { 130 | if (navMesh != null) 131 | { 132 | navMesh.Build(); 133 | } else 134 | { 135 | Debug.LogWarning("Navigation reference it not assigned. Cannot build navigation"); 136 | } 137 | } 138 | } 139 | } -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Game/GameController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a0533d7426ce4e1eacfe0e00720acbc 3 | timeCreated: 1452426447 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Game/LevelGoal.cs: -------------------------------------------------------------------------------- 1 | //$ Copyright 2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $// 2 | 3 | using UnityEngine; 4 | using System.Collections; 5 | using DungeonArchitect; 6 | using DungeonArchitect.Utils; 7 | 8 | namespace ZombieStory 9 | { 10 | public class LevelGoal : MonoBehaviour { 11 | void OnTriggerEnter(Collider other) { 12 | // Create a new level 13 | if (other.gameObject.CompareTag(GameTags.Player)) { 14 | GameController.Instance.CreateNewLevel(); 15 | } 16 | } 17 | 18 | void Update() { 19 | if (Input.GetKeyDown(KeyCode.Space)) { 20 | GameController.Instance.CreateNewLevel(); 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Game/LevelGoal.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 41ed18ecbdd4e4b9b83bac81ddf163c9 3 | timeCreated: 1452425137 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Helpers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bafbb8cb07fedac43948d44f4b380830 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Helpers/BeautyShot.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using UnityEditor; 3 | #endif 4 | 5 | using UnityEngine; 6 | using System.IO; 7 | using System.Collections; 8 | 9 | namespace ZombieStory 10 | { 11 | public class BeautyShot : MonoBehaviour 12 | { 13 | public string generateFilename() 14 | { 15 | //var frame = Backstage.Director.PlayheadInFrames; 16 | //var frame = Backstage.frameCount; 17 | var frame = Time.frameCount; 18 | return string.Format("/{0}.png", frame + frameOffset ); 19 | } 20 | 21 | private string _folder = ""; 22 | private Texture2D _result = null; 23 | 24 | public LayerMask layerMask; 25 | 26 | public int frameRate = 60; 27 | public float duration = 10; 28 | public int frameOffset = 0; 29 | private float numFrames; 30 | 31 | public bool captureUsingScreenshot = false; 32 | 33 | public enum Supersample 34 | { 35 | None = 1, 36 | Two = 2, 37 | Four = 4, 38 | Eight = 8, 39 | Sixteen = 16, 40 | Wtf = 32 41 | }; 42 | 43 | public Supersample supersampleScreenshot = Supersample.None; 44 | 45 | void Start() 46 | { 47 | if( !Application.isPlaying ) 48 | return; 49 | 50 | #if UNITY_EDITOR 51 | Application.runInBackground = true; 52 | Time.captureFramerate = frameRate; 53 | numFrames = duration * frameRate; 54 | 55 | var path = "BeautyShots/scene/{1}"; 56 | 57 | // "640 k ought to be enough for anybody." 58 | for( var count = 0; count < 640000; count++ ) 59 | { 60 | _folder = string.Format( path, count ); 61 | if( !System.IO.Directory.Exists( _folder ) ) 62 | break; 63 | } 64 | 65 | System.IO.Directory.CreateDirectory( _folder ); 66 | _result = new Texture2D( Screen.width, Screen.height, TextureFormat.RGB24, false ); 67 | #endif 68 | } 69 | 70 | #if UNITY_EDITOR 71 | private byte[] captureCam( Camera cam, int w, int h ) 72 | { 73 | var oldcullmask = cam.cullingMask; 74 | cam.cullingMask = layerMask; 75 | RenderTexture rt = RenderTexture.GetTemporary( w, h ); 76 | 77 | var tmp = cam.targetTexture; 78 | cam.targetTexture = rt; 79 | cam.Render(); 80 | 81 | RenderTexture.active = rt; 82 | _result.ReadPixels( new Rect( 0, 0, w, h ), 0, 0, false ); 83 | cam.targetTexture = tmp; 84 | cam.cullingMask = oldcullmask; 85 | return _result.EncodeToPNG(); 86 | } 87 | #endif 88 | 89 | #if UNITY_EDITOR 90 | void OnPostRender() 91 | { 92 | var filename = _folder + generateFilename(); 93 | if( captureUsingScreenshot == false ) 94 | { 95 | #if !UNITY_WEBPLAYER 96 | var cam = Camera.current; 97 | if( cam != null ) 98 | { 99 | System.IO.File.WriteAllBytes( filename, captureCam( cam, Screen.width, Screen.height ) ); 100 | Debug.Log( "File written" ); 101 | } 102 | else 103 | Debug.LogError( "Cam is null?" ); 104 | #endif 105 | } 106 | else 107 | Application.CaptureScreenshot( filename, (int)supersampleScreenshot ); 108 | 109 | if( Time.frameCount % frameRate == 0 ) 110 | Debug.Log( string.Format( "{0} second rendered, {1} total frames.", Time.frameCount / Time.captureFramerate, Time.frameCount ) ); 111 | 112 | if( Time.frameCount > numFrames ) 113 | { 114 | Debug.Log( string.Format( "Capture done, {0} second rendered, {1} total frames.", Time.frameCount / Time.captureFramerate, Time.frameCount ) ); 115 | Application.runInBackground = false; 116 | EditorApplication.isPlaying = false; } 117 | } 118 | #endif 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Helpers/BeautyShot.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f1c5bc40430f33246b7d3d1aeb5ad8f5 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Helpers/RandomAnimationPoint.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace ZombieStory 5 | { 6 | public class RandomAnimationPoint : MonoBehaviour 7 | { 8 | public bool randomize; 9 | [Range(0f, 1f)] public float normalizedTime; 10 | 11 | 12 | void OnValidate () 13 | { 14 | GetComponent ().Update (0f); 15 | GetComponent ().Play ("Walk", 0, randomize ? Random.value : normalizedTime); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Helpers/RandomAnimationPoint.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: de4cc967c8e16fa4cb37cebf3eb501c6 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Helpers/RandomParticlePoint.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace ZombieStory 5 | { 6 | public class RandomParticlePoint : MonoBehaviour 7 | { 8 | [Range(0f, 1f)] 9 | public float normalizedTime; 10 | 11 | 12 | void OnValidate() 13 | { 14 | GetComponent().Simulate (normalizedTime, true, true); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Helpers/RandomParticlePoint.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e29d72814f12624f9c2a9d1b98d6fcf 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Helpers/VolumeHandler.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using UnityEngine.UI; 4 | 5 | 6 | namespace ZombieStory 7 | { 8 | public class VolumeHandler : MonoBehaviour { 9 | 10 | // Use this for initialization 11 | void Start () 12 | { 13 | if(GameObject.Find("EffectsSlider")) 14 | GameObject.Find("EffectsSlider").GetComponent().onValueChanged.AddListener(SetVolume); 15 | } 16 | 17 | void SetVolume(float volume) 18 | { 19 | GetComponent().volume = volume; 20 | } 21 | 22 | void OnDestroy() 23 | { 24 | if(GameObject.Find("EffectsSlider")) 25 | GameObject.Find("EffectsSlider").GetComponent().onValueChanged.RemoveListener(SetVolume); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Helpers/VolumeHandler.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f58c1d9ce56e1749830b8aebe8ba3bf 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Managers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3796e7cb4a0fd844ac3d7800956af7c 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Managers/EnemyManager.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace ZombieStory 4 | { 5 | public class EnemyManager : MonoBehaviour 6 | { 7 | public PlayerHealth playerHealth; // Reference to the player's heatlh. 8 | public GameObject enemy; // The enemy prefab to be spawned. 9 | public float spawnTime = 3f; // How long between each spawn. 10 | public Transform[] spawnPoints; // An array of the spawn points this enemy can spawn from. 11 | 12 | 13 | void Start () 14 | { 15 | // Call the Spawn function after a delay of the spawnTime and then continue to call after the same amount of time. 16 | InvokeRepeating ("Spawn", spawnTime, spawnTime); 17 | } 18 | 19 | 20 | void Spawn () 21 | { 22 | // If the player has no health left... 23 | if(playerHealth.currentHealth <= 0f) 24 | { 25 | // ... exit the function. 26 | return; 27 | } 28 | 29 | // Find a random index between zero and one less than the number of spawn points. 30 | int spawnPointIndex = Random.Range (0, spawnPoints.Length); 31 | 32 | // Create an instance of the enemy prefab at the randomly selected spawn point's position and rotation. 33 | Instantiate (enemy, spawnPoints[spawnPointIndex].position, spawnPoints[spawnPointIndex].rotation); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Managers/EnemyManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8bf862ffeb7e74943a1729f1cff11eb4 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Managers/GameOverManager.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace ZombieStory 4 | { 5 | public class GameOverManager : MonoBehaviour 6 | { 7 | public PlayerHealth playerHealth; // Reference to the player's health. 8 | 9 | 10 | Animator anim; // Reference to the animator component. 11 | 12 | 13 | void Awake () 14 | { 15 | // Set up the reference. 16 | anim = GetComponent (); 17 | } 18 | 19 | 20 | void Update () 21 | { 22 | // If the player has run out of health... 23 | if(playerHealth.currentHealth <= 0) 24 | { 25 | // ... tell the animator the game is over. 26 | anim.SetTrigger ("GameOver"); 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Managers/GameOverManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a210693e63307044a858d1787aacd62c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Managers/PauseManager.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using UnityEngine.UI; 4 | using UnityEngine.Audio; 5 | #if UNITY_EDITOR 6 | using UnityEditor; 7 | #endif 8 | 9 | namespace ZombieStory 10 | { 11 | public class PauseManager : MonoBehaviour { 12 | 13 | public AudioMixerSnapshot paused; 14 | public AudioMixerSnapshot unpaused; 15 | 16 | Canvas canvas; 17 | 18 | void Start() 19 | { 20 | canvas = GetComponent(); 21 | } 22 | 23 | void Update() 24 | { 25 | if (Input.GetKeyDown(KeyCode.Escape)) 26 | { 27 | canvas.enabled = !canvas.enabled; 28 | Pause(); 29 | } 30 | } 31 | 32 | public void Pause() 33 | { 34 | Time.timeScale = Time.timeScale == 0 ? 1 : 0; 35 | Lowpass (); 36 | 37 | } 38 | 39 | void Lowpass() 40 | { 41 | if (Time.timeScale == 0) 42 | { 43 | paused.TransitionTo(.01f); 44 | } 45 | 46 | else 47 | 48 | { 49 | unpaused.TransitionTo(.01f); 50 | } 51 | } 52 | 53 | public void Quit() 54 | { 55 | #if UNITY_EDITOR 56 | EditorApplication.isPlaying = false; 57 | #else 58 | Application.Quit(); 59 | #endif 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Managers/PauseManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 189bfb9c6772b6b4a87e12cd8b9af36f 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Managers/ScoreManager.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | using System.Collections; 4 | 5 | namespace ZombieStory 6 | { 7 | public class ScoreManager : MonoBehaviour 8 | { 9 | public static int score; // The player's score. 10 | 11 | 12 | Text text; // Reference to the Text component. 13 | 14 | 15 | void Awake () 16 | { 17 | // Set up the reference. 18 | text = GetComponent (); 19 | 20 | // Reset the score. 21 | score = 0; 22 | } 23 | 24 | 25 | void Update () 26 | { 27 | // Set the displayed text to be the word "Score" followed by the score value. 28 | text.text = "Score: " + score; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Managers/ScoreManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b4f43bf66218c874d871d02802b6a2db 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/MiniMap.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7f4ab2ff171bf4ea3ace4f91acabd2c2 3 | folderAsset: yes 4 | timeCreated: 1452338812 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/MiniMap/MiniMapCameraTracker.cs: -------------------------------------------------------------------------------- 1 | //$ Copyright 2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $// 2 | 3 | using UnityEngine; 4 | using System.Collections; 5 | using DungeonArchitect; 6 | 7 | 8 | namespace ZombieStory 9 | { 10 | public class MiniMapCameraTracker : MonoBehaviour 11 | { 12 | public Transform trackingTransform; 13 | public Transform baseDungeonTransform; 14 | public Transform dotTransform; 15 | 16 | 17 | // Use this for initialization 18 | void Start() 19 | { 20 | 21 | } 22 | 23 | // Update is called once per frame 24 | void Update() 25 | { 26 | var delta = trackingTransform.position - baseDungeonTransform.position; 27 | gameObject.transform.localPosition = delta; 28 | dotTransform.rotation = trackingTransform.rotation; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/MiniMap/MiniMapCameraTracker.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 06f7368ec7a73456aa3bf71e86ea61cf 3 | timeCreated: 1452342837 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/MiniMap/MiniMapEnemyDots.cs: -------------------------------------------------------------------------------- 1 | //$ Copyright 2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $// 2 | 3 | using UnityEngine; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | 7 | namespace ZombieStory 8 | { 9 | public class MiniMapEnemyDots : MonoBehaviour { 10 | public GameObject enemyDotTemplate; 11 | public Queue dots = new Queue(); 12 | public Transform baseDungeon; 13 | public Transform miniMapDungeon; 14 | 15 | Vector3 offset; 16 | // Use this for initialization 17 | void Start () { 18 | offset = miniMapDungeon.position - baseDungeon.position; 19 | } 20 | 21 | // Update is called once per frame 22 | void Update () { 23 | var enemyControllers = GameObject.FindObjectsOfType(); 24 | var currentDots = new Queue(); 25 | foreach (var enemyController in enemyControllers) { 26 | var enemyObject = enemyController.gameObject; 27 | EnemyHealth health = enemyObject.GetComponent(); 28 | if (health == null) continue; 29 | if (health.currentHealth > 0) { 30 | var dot = BuildDot(enemyObject); 31 | currentDots.Enqueue(dot); 32 | } 33 | } 34 | 35 | // Destroy all unused dots 36 | foreach (var dot in dots) { 37 | Destroy (dot); 38 | } 39 | dots = currentDots; 40 | } 41 | 42 | GameObject BuildDot(GameObject enemy) { 43 | GameObject dot = null; 44 | if (dots.Count == 0) { 45 | // Dot pool exhausted. Build a new one 46 | dot = Instantiate(enemyDotTemplate) as GameObject; 47 | dot.transform.parent = gameObject.transform; 48 | } 49 | else { 50 | // Reuse an existing one 51 | dot = dots.Dequeue(); 52 | } 53 | 54 | dot.transform.position = offset + enemy.transform.position; 55 | dot.transform.rotation = enemy.transform.rotation; 56 | 57 | return dot; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/MiniMap/MiniMapEnemyDots.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 034f0fd1fbbc24ac3bac489c8b75b214 3 | timeCreated: 1452414682 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/MiniMap/MiniMapGenerator.cs: -------------------------------------------------------------------------------- 1 | //$ Copyright 2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $// 2 | 3 | using UnityEngine; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | using DungeonArchitect; 7 | using DungeonArchitect.Utils; 8 | using DungeonArchitect.Graphs; 9 | 10 | using ZombieStory; 11 | 12 | public class MiniMapGenerator : MonoBehaviour { 13 | public List miniMapThemes; 14 | GameObject miniMapDungeonObject; 15 | Dungeon minimapDungeon; 16 | 17 | // Use this for initialization 18 | public void BuildMiniMap(Dungeon baseDungeon) { 19 | if (miniMapDungeonObject == null) { 20 | miniMapDungeonObject = Instantiate(baseDungeon.gameObject); 21 | } 22 | 23 | // Move the mini-map dungeon down 24 | minimapDungeon = miniMapDungeonObject.GetComponent(); 25 | minimapDungeon.transform.position = gameObject.transform.position; 26 | 27 | // Disable unwanted components from the cloned minimap dungeon 28 | DisableComponent(miniMapDungeonObject); 29 | DisableComponent(miniMapDungeonObject); 30 | DisableComponent(miniMapDungeonObject); 31 | DisableComponent(miniMapDungeonObject); 32 | 33 | // Apply the mini-map themes and rebuild 34 | minimapDungeon.dungeonThemes = miniMapThemes; 35 | minimapDungeon.Config.Seed = baseDungeon.Config.Seed; 36 | minimapDungeon.Build(); 37 | } 38 | 39 | public void DestroyDungeon() { 40 | if (minimapDungeon != null) { 41 | minimapDungeon.DestroyDungeon(); 42 | } 43 | 44 | } 45 | 46 | void DisableComponent(GameObject obj) where T : MonoBehaviour { 47 | var component = obj.GetComponent(); 48 | if (component != null) { 49 | component.enabled = false; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/MiniMap/MiniMapGenerator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 11872453ea5b5433a9bce701fde79ddb 3 | timeCreated: 1452338826 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/MiniMap/MiniMapRebuilder.cs: -------------------------------------------------------------------------------- 1 | //$ Copyright 2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $// 2 | 3 | using UnityEngine; 4 | using System.Collections; 5 | using DungeonArchitect; 6 | 7 | namespace ZombieStory 8 | { 9 | public class MiniMapRebuilder : DungeonEventListener 10 | { 11 | public MiniMapGenerator miniMap; 12 | 13 | /// 14 | /// Called after the dungeon is completely built 15 | /// 16 | /// The dungeon model 17 | public override void OnPostDungeonBuild(Dungeon dungeon, DungeonModel model) 18 | { 19 | miniMap.BuildMiniMap(dungeon); 20 | } 21 | 22 | /// 23 | /// Called after the dungeon is destroyed 24 | /// 25 | /// The dungeon model 26 | public override void OnDungeonDestroyed(Dungeon dungeon) 27 | { 28 | miniMap.DestroyDungeon(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/MiniMap/MiniMapRebuilder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb27c2340686e488aa155732a5b30d44 3 | timeCreated: 1452428047 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/MiniMap/MiniMapRenderer.cs: -------------------------------------------------------------------------------- 1 | //$ Copyright 2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $// 2 | 3 | using UnityEngine; 4 | using System.Collections; 5 | 6 | namespace ZombieStory 7 | { 8 | public class MiniMapRenderer : MonoBehaviour 9 | { 10 | public Texture miniMapRtt; 11 | public Material miniMapMat; 12 | public int width = 256; 13 | public int height = 256; 14 | 15 | 16 | // Use this for initialization 17 | void Start() 18 | { 19 | 20 | } 21 | 22 | // Update is called once per frame 23 | void Update() 24 | { 25 | } 26 | 27 | 28 | void OnGUI() 29 | { 30 | if (Event.current.type.Equals(EventType.Repaint)) 31 | { 32 | var padding = 10; 33 | var x = Screen.width - width - padding; 34 | var y = Screen.height - height - padding; 35 | var rect = new Rect(x, y, width, height); 36 | Graphics.DrawTexture(rect, miniMapRtt, miniMapMat); 37 | } 38 | 39 | } 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/MiniMap/MiniMapRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 299ba2a3808694f4c9becebc818b6181 3 | timeCreated: 1452338837 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Player.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1cd2c9641294005428dc356c88d6c0d4 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Player/PlayerHealth.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | using System.Collections; 4 | 5 | namespace ZombieStory 6 | { 7 | public class PlayerHealth : MonoBehaviour 8 | { 9 | public int startingHealth = 100; // The amount of health the player starts the game with. 10 | public int currentHealth; // The current health the player has. 11 | public Slider healthSlider; // Reference to the UI's health bar. 12 | public Image damageImage; // Reference to an image to flash on the screen on being hurt. 13 | public AudioClip deathClip; // The audio clip to play when the player dies. 14 | public float flashSpeed = 5f; // The speed the damageImage will fade at. 15 | public Color flashColour = new Color(1f, 0f, 0f, 0.1f); // The colour the damageImage is set to, to flash. 16 | 17 | 18 | Animator anim; // Reference to the Animator component. 19 | AudioSource playerAudio; // Reference to the AudioSource component. 20 | PlayerMovement playerMovement; // Reference to the player's movement. 21 | PlayerShooting playerShooting; // Reference to the PlayerShooting script. 22 | bool isDead; // Whether the player is dead. 23 | bool damaged; // True when the player gets damaged. 24 | 25 | 26 | void Awake () 27 | { 28 | // Setting up the references. 29 | anim = GetComponent (); 30 | playerAudio = GetComponent (); 31 | playerMovement = GetComponent (); 32 | playerShooting = GetComponentInChildren (); 33 | 34 | // Set the initial health of the player. 35 | currentHealth = startingHealth; 36 | } 37 | 38 | 39 | void Update () 40 | { 41 | // If the player has just been damaged... 42 | if (damageImage != null) { 43 | if (damaged) 44 | { 45 | // ... set the colour of the damageImage to the flash colour. 46 | damageImage.color = flashColour; 47 | } 48 | // Otherwise... 49 | else 50 | { 51 | // ... transition the colour back to clear. 52 | damageImage.color = Color.Lerp(damageImage.color, Color.clear, flashSpeed * Time.deltaTime); 53 | } 54 | } 55 | 56 | 57 | // Reset the damaged flag. 58 | damaged = false; 59 | } 60 | 61 | 62 | public void TakeDamage (int amount) 63 | { 64 | // Set the damaged flag so the screen will flash. 65 | damaged = true; 66 | 67 | // Reduce the current health by the damage amount. 68 | currentHealth -= amount; 69 | 70 | // Set the health bar's value to the current health. 71 | healthSlider.value = currentHealth; 72 | 73 | // Play the hurt sound effect. 74 | playerAudio.Play (); 75 | 76 | // If the player has lost all it's health and the death flag hasn't been set yet... 77 | if(currentHealth <= 0 && !isDead) 78 | { 79 | // ... it should die. 80 | Death (); 81 | } 82 | } 83 | 84 | 85 | void Death () 86 | { 87 | // Set the death flag so this function won't be called again. 88 | isDead = true; 89 | 90 | // Turn off any remaining shooting effects. 91 | playerShooting.DisableEffects (); 92 | 93 | // Tell the animator that the player is dead. 94 | anim.SetTrigger ("Die"); 95 | 96 | // Set the audiosource to play the death clip and play it (this will stop the hurt sound from playing). 97 | playerAudio.clip = deathClip; 98 | playerAudio.Play (); 99 | 100 | // Turn off the movement and shooting scripts. 101 | playerMovement.enabled = false; 102 | playerShooting.enabled = false; 103 | } 104 | 105 | 106 | public void RestartLevel () 107 | { 108 | // Reload the level that is currently loaded. 109 | //Application.LoadLevel (Application.loadedLevel); 110 | var activeScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene(); 111 | UnityEngine.SceneManagement.SceneManager.LoadScene(activeScene.buildIndex); 112 | } 113 | } 114 | } -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Player/PlayerHealth.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c32067ea884548644b13cf9baddd4573 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Player/PlayerMovement.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace ZombieStory 4 | { 5 | public class PlayerMovement : MonoBehaviour 6 | { 7 | public float speed = 6f; // The speed that the player will move at. 8 | public float gravity = -4; 9 | 10 | CharacterController character; 11 | Vector3 movement; // The vector to store the direction of the player's movement. 12 | Animator anim; // Reference to the animator component. 13 | //Rigidbody playerRigidbody; // Reference to the player's rigidbody. 14 | //int floorMask; // A layer mask so that a ray can be cast just at gameobjects on the floor layer. 15 | float camRayLength = 100f; // The length of the ray from the camera into the scene. 16 | 17 | void Awake () 18 | { 19 | 20 | // Set up references. 21 | anim = GetComponentInChildren (); 22 | character = GetComponent(); 23 | //playerRigidbody = GetComponent (); 24 | } 25 | 26 | 27 | void FixedUpdate () 28 | { 29 | // Store the input axes. 30 | float h = Input.GetAxisRaw("Horizontal"); 31 | float v = Input.GetAxisRaw("Vertical"); 32 | 33 | // Move the player around the scene. 34 | Move (h, v); 35 | 36 | // Turn the player to face the mouse cursor. 37 | Turning (); 38 | 39 | // Animate the player. 40 | Animating (h, v); 41 | } 42 | 43 | 44 | void Move (float h, float v) 45 | { 46 | // Set the movement vector based on the axis input. 47 | movement.Set (h, 0f, v); 48 | 49 | // Normalise the movement vector and make it proportional to the speed per second. 50 | movement = movement.normalized * speed * Time.deltaTime; 51 | movement.y += gravity * Time.deltaTime; 52 | 53 | character.Move(movement); 54 | } 55 | 56 | 57 | void Turning () 58 | { 59 | // Create a ray from the mouse cursor on screen in the direction of the camera. 60 | Ray camRay = Camera.main.ScreenPointToRay (Input.mousePosition); 61 | 62 | // Create a RaycastHit variable to store information about what was hit by the ray. 63 | RaycastHit floorHit; 64 | 65 | // Perform the raycast and if it hits something on the floor layer... 66 | if(Physics.Raycast (camRay, out floorHit, camRayLength)) 67 | { 68 | // Create a vector from the player to the point on the floor the raycast from the mouse hit. 69 | Vector3 playerToMouse = floorHit.point - transform.position; 70 | 71 | // Ensure the vector is entirely along the floor plane. 72 | playerToMouse.y = 0f; 73 | 74 | // Create a quaternion (rotation) based on looking down the vector from the player to the mouse. 75 | Quaternion newRotatation = Quaternion.LookRotation (playerToMouse); 76 | 77 | // Set the player's rotation to this new rotation. 78 | transform.rotation = newRotatation; 79 | //playerRigidbody.MoveRotation (newRotatation); 80 | } 81 | } 82 | 83 | 84 | void Animating (float h, float v) 85 | { 86 | float speed = new Vector2(h, v).magnitude; 87 | // Tell the animator whether or not the player is walking. 88 | anim.SetFloat("Speed_f", speed); 89 | } 90 | } 91 | } -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Player/PlayerMovement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9b2268f9c7df8764aa2e92dbf55b5ae1 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 100 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Player/PlayerShooting.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace ZombieStory 4 | { 5 | public delegate void OnShootingStarted(); 6 | public delegate void OnShootingStopped(); 7 | 8 | public class PlayerShooting : MonoBehaviour 9 | { 10 | public int damagePerShot = 20; // The damage inflicted by each bullet. 11 | public float timeBetweenBullets = 0.15f; // The time between each shot. 12 | public float range = 100f; // The distance the gun can fire. 13 | public GameObject gunBarrel; 14 | 15 | public event OnShootingStarted ShootingStarted; 16 | public event OnShootingStopped ShootingStopped; 17 | 18 | float timeSinceLastShot = 100; // A timer to determine when to fire. 19 | public float TimeSinceLastShot 20 | { 21 | get { return timeSinceLastShot; } 22 | } 23 | 24 | public bool IsShooting 25 | { 26 | get { return shooting; } 27 | } 28 | 29 | public Ray shootRay; // A ray from the gun end forwards. 30 | //public Light faceLight; // Duh 31 | 32 | RaycastHit shootHit; // A raycast hit to get information about what was hit. 33 | ParticleSystem gunParticles; // Reference to the particle system. 34 | LineRenderer gunLine; // Reference to the line renderer. 35 | Light gunLight; // Reference to the light component. 36 | SfxPlayer sfxPlayer; 37 | WeaponSfx weaponSfx; 38 | float effectsDisplayTime = 0.2f; // The proportion of the timeBetweenBullets that the effects will display for. 39 | bool shooting = false; 40 | 41 | void Awake () 42 | { 43 | // Set up the references. 44 | gunParticles = gunBarrel.GetComponent (); 45 | gunLine = gunBarrel.GetComponent (); 46 | gunLight = gunBarrel.GetComponent (); 47 | //faceLight = GetComponentInChildren (); 48 | sfxPlayer = GetComponent(); 49 | } 50 | 51 | 52 | void Update () 53 | { 54 | // Add the time since Update was last called to the timer. 55 | timeSinceLastShot += Time.deltaTime; 56 | 57 | bool isShootingThisFrame = shooting; 58 | 59 | // If the Fire1 button is being press and it's time to fire... 60 | if(Input.GetButton ("Fire1") && TimeSinceLastShot >= timeBetweenBullets && Time.timeScale != 0) 61 | { 62 | // ... shoot the gun. 63 | Shoot (); 64 | shooting = true; 65 | } 66 | 67 | // If the timer has exceeded the proportion of timeBetweenBullets that the effects should be displayed for... 68 | if(TimeSinceLastShot >= timeBetweenBullets * effectsDisplayTime) 69 | { 70 | // ... disable the effects. 71 | DisableEffects (); 72 | shooting = false; 73 | } 74 | 75 | if (isShootingThisFrame != shooting) 76 | { 77 | // The state has changed. Notify the listeners 78 | if (shooting && ShootingStarted != null) 79 | { 80 | ShootingStarted(); 81 | } 82 | else if (!shooting && ShootingStopped != null) 83 | { 84 | ShootingStopped(); 85 | } 86 | } 87 | } 88 | 89 | public void OnWeaponChanged(WeaponItem weapon, WeaponSfx weaponSfx) 90 | { 91 | this.weaponSfx = weaponSfx; 92 | gunBarrel.transform.localPosition = weapon.barrelOffset; 93 | timeBetweenBullets = 1.0f / weapon.roundsPerSecond; 94 | } 95 | 96 | public void DisableEffects () 97 | { 98 | // Disable the line renderer and the light. 99 | gunLine.enabled = false; 100 | //faceLight.enabled = false; 101 | gunLight.enabled = false; 102 | } 103 | 104 | 105 | void Shoot () 106 | { 107 | // Reset the timer. 108 | timeSinceLastShot = 0f; 109 | 110 | sfxPlayer.PlayAudio(weaponSfx.sfx, weaponSfx.volume); 111 | 112 | // Enable the lights. 113 | gunLight.enabled = true; 114 | //faceLight.enabled = true; 115 | 116 | // Stop the particles from playing if they were, then start the particles. 117 | gunParticles.Stop (); 118 | gunParticles.Play (); 119 | 120 | // Enable the line renderer and set it's first position to be the end of the gun. 121 | gunLine.enabled = true; 122 | gunLine.SetPosition (0, gunBarrel.transform.position); 123 | 124 | // Set the shootRay so that it starts at the end of the gun and points forward from the barrel. 125 | shootRay.origin = gunBarrel.transform.position; 126 | shootRay.direction = gunBarrel.transform.forward; 127 | 128 | // Perform the raycast against gameobjects on the shootable layer and if it hits something... 129 | if(Physics.Raycast (shootRay, out shootHit, range)) 130 | { 131 | // Try and find an EnemyHealth script on the gameobject hit. 132 | EnemyHealth enemyHealth = shootHit.collider.GetComponent (); 133 | 134 | // If the EnemyHealth component exist... 135 | if(enemyHealth != null) 136 | { 137 | // ... the enemy should take damage. 138 | enemyHealth.TakeDamage (damagePerShot, shootHit.point); 139 | } 140 | 141 | // Set the second position of the line renderer to the point the raycast hit. 142 | gunLine.SetPosition (1, shootHit.point); 143 | } 144 | // If the raycast didn't hit anything on the shootable layer... 145 | else 146 | { 147 | // ... set the second position of the line renderer to the fullest extent of the gun's range. 148 | gunLine.SetPosition (1, shootRay.origin + shootRay.direction * range); 149 | } 150 | } 151 | } 152 | } -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Player/PlayerShooting.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c83720df9acb89488dbf2c0dbd3ad78 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Utils.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 840976060b24242eab49024c4dc5573f 3 | folderAsset: yes 4 | timeCreated: 1452328992 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Utils/BillboardGizmo.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace ZombieStory 5 | { 6 | public class BillboardGizmo : MonoBehaviour 7 | { 8 | public string iconName = "flag_icon.png"; 9 | void OnDrawGizmos() 10 | { 11 | Gizmos.DrawIcon(gameObject.transform.position, iconName, true); 12 | transform.localScale = new Vector3(.2f, .2f, .2f); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Utils/BillboardGizmo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2348b3b29f1114bc094ec839b527b53e 3 | timeCreated: 1452329210 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Waypoints.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8edd98fa9953547729a183e1363b8589 3 | folderAsset: yes 4 | timeCreated: 1452328962 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Waypoints/Waypoint.cs: -------------------------------------------------------------------------------- 1 | //$ Copyright 2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $// 2 | 3 | using UnityEngine; 4 | using System.Collections; 5 | 6 | namespace ZombieStory 7 | { 8 | public class Waypoint : MonoBehaviour { 9 | public int id; 10 | 11 | [SerializeField] 12 | Waypoint[] adjacentWaypoints = new Waypoint[0]; 13 | 14 | public Waypoint[] AdjacentWaypoints { 15 | get { 16 | return adjacentWaypoints; 17 | } 18 | set { 19 | adjacentWaypoints = value; 20 | } 21 | } 22 | 23 | public override string ToString () 24 | { 25 | if (gameObject == null) { 26 | return base.ToString(); 27 | } 28 | return gameObject.transform.position.ToString(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Waypoints/Waypoint.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 960f9ff4181188643b130937ad4e8f92 3 | timeCreated: 1441277855 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Waypoints/WaypointGenerator.cs: -------------------------------------------------------------------------------- 1 | //$ Copyright 2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $// 2 | 3 | using UnityEngine; 4 | using System.Collections.Generic; 5 | using DungeonArchitect; 6 | using DungeonArchitect.Utils; 7 | using DungeonArchitect.Builders.Grid; 8 | using DungeonArchitect.Builders.SimpleCity; 9 | 10 | namespace ZombieStory 11 | { 12 | public class WaypointGenerator : DungeonEventListener { 13 | public GameObject waypointTemplate; 14 | public GameObject waypointParent; 15 | public Vector3 waypointOffset = Vector3.up; 16 | bool mode2D = false; 17 | 18 | public override void OnDungeonMarkersEmitted(Dungeon dungeon, DungeonModel model, List markers) 19 | { 20 | BuildWaypoints(model, markers); 21 | } 22 | 23 | public void BuildWaypoints(DungeonModel model, List markers) 24 | { 25 | // Destroy all existing waypoints 26 | DestroyAllWaypoints(); 27 | 28 | if (model is GridDungeonModel) 29 | { 30 | BuildGridWaypoints(model as GridDungeonModel, markers); 31 | } 32 | else if (model is SimpleCityDungeonModel) 33 | { 34 | BuildCityWaypoints(model as SimpleCityDungeonModel); 35 | } 36 | else 37 | { 38 | Debug.LogWarning("Waypoint generator does not support model of type: " + model.GetType()); 39 | return; 40 | } 41 | } 42 | 43 | void BuildGridWaypoints(GridDungeonModel gridModel, List markers) 44 | { 45 | mode2D = gridModel.Config.Mode2D; 46 | 47 | // Destroy all existing waypoints 48 | DestroyAllWaypoints(); 49 | 50 | var cellToWaypoint = new Dictionary(); 51 | 52 | int idCounter = 1; 53 | 54 | var wall2DPositions = new HashSet(); 55 | if (mode2D) 56 | { 57 | foreach (var marker in markers) 58 | { 59 | if (marker.SocketType == DungeonConstants.ST_WALL2D) 60 | { 61 | wall2DPositions.Add(marker.gridPosition); 62 | } 63 | } 64 | } 65 | 66 | // Create a waypoint on each cell 67 | foreach (var cell in gridModel.Cells) 68 | { 69 | if (mode2D) 70 | { 71 | if (wall2DPositions.Contains(cell.Bounds.Location)) 72 | { 73 | // Don't want to create a waypoint on a wall tile 74 | continue; 75 | } 76 | } 77 | var worldPos = MathUtils.GridToWorld(gridModel.Config.GridCellSize, cell.CenterF); 78 | worldPos += waypointOffset; 79 | if (mode2D) { 80 | worldPos = FlipYZ(worldPos); 81 | } 82 | var waypointObject = Instantiate(waypointTemplate, worldPos, Quaternion.identity) as GameObject; 83 | waypointObject.transform.parent = waypointParent.transform; 84 | 85 | var waypoint = waypointObject.GetComponent(); 86 | waypoint.id = idCounter++; 87 | cellToWaypoint.Add (cell.Id, waypoint); 88 | } 89 | 90 | // Connect adjacent waypoints 91 | foreach (var cellId in cellToWaypoint.Keys) { 92 | var waypoint = cellToWaypoint[cellId]; 93 | var cell = gridModel.GetCell(cellId); 94 | var adjacentWaypoints = new List(); 95 | var visited = new HashSet(); 96 | foreach (var adjacentCellId in cell.AdjacentCells) { 97 | if (visited.Contains(GetHash(cellId, adjacentCellId))) continue; 98 | 99 | var adjacentCell = gridModel.GetCell(adjacentCellId); 100 | // add only if there is a direct path to it (through a door or stair or open space) 101 | bool directPath = HasDirectPath(gridModel, cell, adjacentCell); 102 | if (directPath) { 103 | if (cellToWaypoint.ContainsKey(adjacentCellId)) { 104 | var adjacentWaypoint = cellToWaypoint[adjacentCellId]; 105 | adjacentWaypoints.Add(adjacentWaypoint); 106 | visited.Add(GetHash(cellId, adjacentCellId)); 107 | visited.Add(GetHash(adjacentCellId, cellId)); 108 | } 109 | } 110 | } 111 | waypoint.AdjacentWaypoints = adjacentWaypoints.ToArray(); 112 | } 113 | } 114 | 115 | void BuildCityWaypoints(SimpleCityDungeonModel model) 116 | { 117 | var cells = model.Cells; 118 | var width = cells.GetLength(0); 119 | var height = cells.GetLength(1); 120 | var cellSize = new Vector3(model.Config.CellSize.x, 0, model.Config.CellSize.y); 121 | int idCounter = 1; 122 | var cellToWaypoint = new Dictionary(); 123 | var adjacentWaypoints = new Dictionary>(); 124 | 125 | for (int x = 0; x < width; x++) 126 | { 127 | for (int z = 0; z < height; z++) 128 | { 129 | var cell = cells[x, z]; 130 | if (cell.CellType == SimpleCityCellType.Road) 131 | { 132 | // Create a waypoint here 133 | var worldPos = Vector3.Scale(cellSize, new Vector3(x, 0, z)); 134 | worldPos += waypointOffset; 135 | var waypointObject = Instantiate(waypointTemplate, worldPos, Quaternion.identity) as GameObject; 136 | waypointObject.transform.parent = waypointParent.transform; 137 | 138 | var waypoint = waypointObject.GetComponent(); 139 | adjacentWaypoints.Add(waypoint, new List()); 140 | waypoint.id = idCounter++; 141 | cellToWaypoint.Add(cell, waypoint); 142 | } 143 | } 144 | } 145 | 146 | for (int x = 0; x < width; x++) 147 | { 148 | for (int z = 0; z < height; z++) 149 | { 150 | var cell = cells[x, z]; 151 | // connect to adjacent road tiles 152 | ConnectAdjacentRoadTiles(model, cell, 0, -1, cellToWaypoint, adjacentWaypoints); 153 | ConnectAdjacentRoadTiles(model, cell, -1, 0, cellToWaypoint, adjacentWaypoints); 154 | } 155 | } 156 | 157 | foreach (var waypoint in cellToWaypoint.Values) 158 | { 159 | waypoint.AdjacentWaypoints = adjacentWaypoints[waypoint].ToArray(); 160 | } 161 | } 162 | 163 | void ConnectAdjacentRoadTiles(SimpleCityDungeonModel model, SimpleCityCell cell, int dx, int dz, 164 | Dictionary cellToWaypoint, Dictionary> adjacentWaypoints) 165 | { 166 | int adjacentX = cell.Position.x + dx; 167 | int adjacentZ = cell.Position.z + dz; 168 | if (adjacentX < 0 || adjacentZ < 0) return; 169 | var adjacentCell = model.Cells[adjacentX, adjacentZ]; 170 | if (cell.CellType == SimpleCityCellType.Road && adjacentCell.CellType == SimpleCityCellType.Road) 171 | { 172 | // Connect the two cells 173 | var waypoint1 = cellToWaypoint[cell]; 174 | var waypoint2 = cellToWaypoint[adjacentCell]; 175 | 176 | adjacentWaypoints[waypoint1].Add(waypoint2); 177 | adjacentWaypoints[waypoint2].Add(waypoint1); 178 | } 179 | } 180 | 181 | int GetHash(int a, int b) 182 | { 183 | return a << 16 | b; 184 | } 185 | 186 | bool HasDirectPath(GridDungeonModel gridModel, Cell cellA, Cell cellB) 187 | { 188 | bool directPath = true; 189 | if (cellA.CellType == CellType.Room || cellB.CellType == CellType.Room) { 190 | directPath = gridModel.DoorManager.ContainsDoorBetweenCells(cellA.Id, cellB.Id); 191 | } 192 | else { 193 | // Check if we have a fence separating them if they have different heights 194 | if (cellA.Bounds.Location.y != cellB.Bounds.Location.y) { 195 | directPath = gridModel.ContainsStair(cellA.Id, cellB.Id); 196 | } 197 | } 198 | return directPath; 199 | } 200 | 201 | public override void OnDungeonDestroyed(Dungeon dungeon) { 202 | DestroyAllWaypoints(); 203 | } 204 | 205 | void DestroyAllWaypoints() { 206 | var oldWaypoints = GameObject.FindObjectsOfType(); 207 | foreach (var waypoint in oldWaypoints) { 208 | if (Application.isPlaying) { 209 | Destroy(waypoint.gameObject); 210 | } else { 211 | DestroyImmediate(waypoint.gameObject); 212 | } 213 | } 214 | } 215 | 216 | Vector3 FlipYZ(Vector3 v) { 217 | return new Vector3(v.x, v.z, v.y); 218 | } 219 | } 220 | } 221 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Waypoints/WaypointGenerator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 11b2ce359b65c41489bc810136d562ef 3 | timeCreated: 1441270202 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Waypoints/WaypointPathVisualizer.cs: -------------------------------------------------------------------------------- 1 | //$ Copyright 2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $// 2 | 3 | using UnityEngine; 4 | using System.Collections; 5 | 6 | 7 | namespace ZombieStory 8 | { 9 | public class WaypointPathVisualizer : MonoBehaviour { 10 | public Color pathColor = Color.cyan; 11 | 12 | void OnDrawGizmosSelected() { 13 | DrawWaypointPaths(); 14 | } 15 | 16 | void DrawWaypointPaths() { 17 | Gizmos.color = pathColor; 18 | // Draw the connection of waypoints 19 | var waypoints = GameObject.FindObjectsOfType(); 20 | foreach (var waypoint in waypoints) { 21 | if (waypoint == null) continue; 22 | var startPosition = waypoint.gameObject.transform.position; 23 | DrawPoint(startPosition); 24 | foreach (var adjacentWaypoint in waypoint.AdjacentWaypoints) { 25 | var endPosition = adjacentWaypoint.gameObject.transform.position; 26 | DrawLine(startPosition, endPosition); 27 | } 28 | } 29 | } 30 | 31 | void DrawLine(Vector3 a, Vector3 b) { 32 | /* 33 | if (mode2D) { 34 | Gizmos.DrawLine(FlipYZ(a), FlipYZ(b)); 35 | } 36 | else { 37 | Gizmos.DrawLine(a, b); 38 | } 39 | */ 40 | Gizmos.DrawLine(a, b); 41 | } 42 | 43 | void DrawPoint(Vector3 p) { 44 | /* 45 | if (mode2D) { 46 | Gizmos.DrawWireSphere(FlipYZ(p), 0.1f); 47 | } else { 48 | Gizmos.DrawWireSphere(p, 0.1f); 49 | } 50 | */ 51 | Gizmos.DrawWireSphere(p, 0.1f); 52 | } 53 | 54 | Vector3 FlipYZ(Vector3 v) { 55 | return new Vector3(v.x, v.z, v.y); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Scripts/ShooterDemoLib/Waypoints/WaypointPathVisualizer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c7df0f0abca0c147a685977bc75c19c 3 | timeCreated: 1441279071 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Utils.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0fcca8e81c0db4d51a15a3ca1089cbdd 3 | folderAsset: yes 4 | timeCreated: 1474635254 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Scripts/Utils/DestroyOnAudioComplete.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class DestroyOnAudioComplete : MonoBehaviour { 5 | 6 | public AudioSource audioSource; 7 | 8 | // Use this for initialization 9 | void Awake () { 10 | audioSource = GetComponent(); 11 | } 12 | 13 | // Update is called once per frame 14 | void Update () { 15 | if (!audioSource.isPlaying) { 16 | Destroy(gameObject); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Scripts/Utils/DestroyOnAudioComplete.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: acaae582c63a34d9685cc110dc46cde6 3 | timeCreated: 1474642345 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Utils/GameTags.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | 5 | namespace ZombieStory 6 | { 7 | public class GameTags : MonoBehaviour 8 | { 9 | public static readonly string Player = "Player"; 10 | public static readonly string Vehicle = "Vehicle"; 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Scripts/Utils/GameTags.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 14970b8662b2b416eaf9c8e1c3544244 3 | timeCreated: 1452329014 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Utils/GameUtils.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class GameUtils { 5 | 6 | public static void DestroyAllChildren(Transform transform) { 7 | foreach (Transform child in transform) { 8 | GameObject.Destroy(child.gameObject); 9 | } 10 | } 11 | 12 | public static void PlayAudioAndForget(AudioClip clip, float volume) { 13 | var audioObject = new GameObject(); 14 | AudioSource source = audioObject.AddComponent(); 15 | source.volume = volume; 16 | source.clip = clip; 17 | source.Play(); 18 | 19 | audioObject.AddComponent(); 20 | } 21 | 22 | 23 | public static GameObject GetNearestObjectWithTag(Vector3 position, string tag) 24 | { 25 | var vehicles = GameObject.FindGameObjectsWithTag(tag); 26 | float nearestDistanceSq = float.MaxValue; 27 | GameObject nearestVehicle = null; 28 | foreach (var vehicle in vehicles) 29 | { 30 | var distanceSq = (vehicle.transform.position - position).sqrMagnitude; 31 | if (distanceSq < nearestDistanceSq) 32 | { 33 | nearestDistanceSq = distanceSq; 34 | nearestVehicle = vehicle; 35 | } 36 | } 37 | return nearestVehicle; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Scripts/Utils/GameUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2c7d4ed002d8e458d819643c498fa010 3 | timeCreated: 1474635274 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Utils/Tween.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public enum TweenMode 5 | { 6 | EaseIn, 7 | EaseOut, 8 | EaseInOut 9 | } 10 | 11 | public class Tween where TPolicy : TweenPolicy, new() 12 | { 13 | TPolicy Policy = new TPolicy(); 14 | float elapsedTime = 0; 15 | float transitionTime = 1; 16 | float start = 0; 17 | float end = 0; 18 | TweenMode easeMode; 19 | 20 | 21 | public void Init(float start, float end, float transitionTime, TweenMode easeMode) 22 | { 23 | this.start = start; 24 | this.end = end; 25 | this.transitionTime = transitionTime; 26 | this.easeMode = easeMode; 27 | elapsedTime = 0; 28 | } 29 | 30 | public void Update(float deltaTime) 31 | { 32 | elapsedTime += deltaTime; 33 | } 34 | 35 | public float Value 36 | { 37 | get 38 | { 39 | var t = Mathf.Clamp01(elapsedTime / transitionTime); 40 | float result = 0; 41 | switch(easeMode) 42 | { 43 | case TweenMode.EaseIn: result = Policy.In(t); break; 44 | case TweenMode.EaseOut: result = Policy.Out(t); break; 45 | case TweenMode.EaseInOut: result = Policy.InOut(t); break; 46 | } 47 | return start + (end - start) * result; 48 | } 49 | } 50 | } 51 | 52 | 53 | public interface TweenPolicy 54 | { 55 | float In(float t); 56 | float Out(float t); 57 | float InOut(float t); 58 | } 59 | 60 | public class LinearTweenPolicy : TweenPolicy 61 | { 62 | public float In(float t) 63 | { 64 | return t; 65 | } 66 | 67 | public float Out(float t) 68 | { 69 | return t; 70 | } 71 | 72 | public float InOut(float t) 73 | { 74 | return t; 75 | } 76 | }; 77 | 78 | public class QuadraticTweenPolicy : TweenPolicy 79 | { 80 | public float In(float t) 81 | { 82 | return t * t; 83 | } 84 | 85 | public float Out(float t) 86 | { 87 | return t * (2f - t); 88 | } 89 | 90 | public float InOut(float t) 91 | { 92 | if ((t *= 2f) < 1f) return 0.5f * t * t; 93 | return -0.5f * ((t -= 1f) * (t - 2f) - 1f); 94 | } 95 | }; 96 | 97 | public class CubicTweenPolicy : TweenPolicy 98 | { 99 | public float In(float t) 100 | { 101 | return t * t * t; 102 | } 103 | 104 | public float Out(float t) 105 | { 106 | return 1f + ((t -= 1f) * t * t); 107 | } 108 | 109 | public float InOut(float t) 110 | { 111 | if ((t *= 2f) < 1f) return 0.5f * t * t * t; 112 | return 0.5f * ((t -= 2f) * t * t + 2f); 113 | } 114 | }; 115 | 116 | public class QuarticTweenPolicy : TweenPolicy 117 | { 118 | public float In(float t) 119 | { 120 | return t * t * t * t; 121 | } 122 | 123 | public float Out(float t) 124 | { 125 | return 1f - ((t -= 1f) * t * t * t); 126 | } 127 | 128 | public float InOut(float t) 129 | { 130 | if ((t *= 2f) < 1f) return 0.5f * t * t * t * t; 131 | return -0.5f * ((t -= 2f) * t * t * t - 2f); 132 | } 133 | }; 134 | 135 | public class QuinticTweenPolicy : TweenPolicy 136 | { 137 | public float In(float t) 138 | { 139 | return t * t * t * t * t; 140 | } 141 | 142 | public float Out(float t) 143 | { 144 | return 1f + ((t -= 1f) * t * t * t * t); 145 | } 146 | 147 | public float InOut(float t) 148 | { 149 | if ((t *= 2f) < 1f) return 0.5f * t * t * t * t * t; 150 | return 0.5f * ((t -= 2f) * t * t * t * t + 2f); 151 | } 152 | }; 153 | 154 | public class SinusoidalTweenPolicy : TweenPolicy 155 | { 156 | public float In(float t) 157 | { 158 | return 1f - Mathf.Cos(t * Mathf.PI / 2f); 159 | } 160 | 161 | public float Out(float t) 162 | { 163 | return Mathf.Sin(t * Mathf.PI / 2f); 164 | } 165 | 166 | public float InOut(float t) 167 | { 168 | return 0.5f * (1f - Mathf.Cos(Mathf.PI * t)); 169 | } 170 | }; 171 | 172 | public class ExponentialTweenPolicy : TweenPolicy 173 | { 174 | public float In(float t) 175 | { 176 | return t == 0f ? 0f : Mathf.Pow(1024f, t - 1f); 177 | } 178 | 179 | public float Out(float t) 180 | { 181 | return t == 1f ? 1f : 1f - Mathf.Pow(2f, -10f * t); 182 | } 183 | 184 | public float InOut(float t) 185 | { 186 | if (t == 0f) return 0f; 187 | if (t == 1f) return 1f; 188 | if ((t *= 2f) < 1f) return 0.5f * Mathf.Pow(1024f, t - 1f); 189 | return 0.5f * (-Mathf.Pow(2f, -10f * (t - 1f)) + 2f); 190 | } 191 | }; 192 | 193 | public class CircularTweenPolicy : TweenPolicy 194 | { 195 | public float In(float t) 196 | { 197 | return 1f - Mathf.Sqrt(1f - t * t); 198 | } 199 | 200 | public float Out(float t) 201 | { 202 | return Mathf.Sqrt(1f - ((t -= 1f) * t)); 203 | } 204 | 205 | public float InOut(float t) 206 | { 207 | if ((t *= 2f) < 1f) return -0.5f * (Mathf.Sqrt(1f - t * t) - 1); 208 | return 0.5f * (Mathf.Sqrt(1f - (t -= 2f) * t) + 1f); 209 | } 210 | }; 211 | 212 | public class ElasticTweenPolicy : TweenPolicy 213 | { 214 | public float In(float t) 215 | { 216 | if (t == 0) return 0; 217 | if (t == 1) return 1; 218 | return -Mathf.Pow(2f, 10f * (t -= 1f)) * Mathf.Sin((t - 0.1f) * (2f * Mathf.PI) / 0.4f); 219 | } 220 | 221 | public float Out(float t) 222 | { 223 | if (t == 0) return 0; 224 | if (t == 1) return 1; 225 | return Mathf.Pow(2f, -10f * t) * Mathf.Sin((t - 0.1f) * (2f * Mathf.PI) / 0.4f) + 1f; 226 | } 227 | 228 | public float InOut(float t) 229 | { 230 | if ((t *= 2f) < 1f) return -0.5f * Mathf.Pow(2f, 10f * (t -= 1f)) * Mathf.Sin((t - 0.1f) * (2f * Mathf.PI) / 0.4f); 231 | return Mathf.Pow(2f, -10f * (t -= 1f)) * Mathf.Sin((t - 0.1f) * (2f * Mathf.PI) / 0.4f) * 0.5f + 1f; 232 | } 233 | }; 234 | 235 | public class BackTweenPolicy : TweenPolicy 236 | { 237 | static float s = 1.70158f; 238 | static float s2 = 2.5949095f; 239 | 240 | public float In(float t) 241 | { 242 | return t * t * ((s + 1f) * t - s); 243 | } 244 | 245 | public float Out(float t) 246 | { 247 | return (t -= 1f) * t * ((s + 1f) * t + s) + 1f; 248 | } 249 | 250 | public float InOut(float t) 251 | { 252 | if ((t *= 2f) < 1f) return 0.5f * (t * t * ((s2 + 1f) * t - s2)); 253 | return 0.5f * ((t -= 2f) * t * ((s2 + 1f) * t + s2) + 2f); 254 | } 255 | }; 256 | 257 | public class BounceTweenPolicy : TweenPolicy 258 | { 259 | public float In(float t) 260 | { 261 | return 1f - Out(1f - t); 262 | } 263 | 264 | public float Out(float t) 265 | { 266 | if (t < (1f / 2.75f)) 267 | { 268 | return 7.5625f * t * t; 269 | } 270 | else if (t < (2f / 2.75f)) 271 | { 272 | return 7.5625f * (t -= (1.5f / 2.75f)) * t + 0.75f; 273 | } 274 | else if (t < (2.5f / 2.75f)) 275 | { 276 | return 7.5625f * (t -= (2.25f / 2.75f)) * t + 0.9375f; 277 | } 278 | else 279 | { 280 | return 7.5625f * (t -= (2.625f / 2.75f)) * t + 0.984375f; 281 | } 282 | } 283 | 284 | public float InOut(float t) 285 | { 286 | if (t < 0.5f) return In(t * 2f) * 0.5f; 287 | return Out(t * 2f - 1f) * 0.5f + 0.5f; 288 | } 289 | }; -------------------------------------------------------------------------------- /Scripts/Utils/Tween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8402dd392a9ea744bab1f99e2d5b4faa 3 | timeCreated: 1479029404 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Themes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0b2bcdc12ee540a1a6fc25ebb640517 3 | folderAsset: yes 4 | timeCreated: 1474603878 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Themes/ZombieCityTheme.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Themes/ZombieCityTheme.asset -------------------------------------------------------------------------------- /Themes/ZombieCityTheme.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b7a4a00bf716743eaab09ad667bf17e5 3 | timeCreated: 1474603889 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Themes/ZombieDungeonTheme.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderespawn/zombie_story_unity/d03ca396eb3ae536f8e768bf8c2584108c004bc7/Themes/ZombieDungeonTheme.asset -------------------------------------------------------------------------------- /Themes/ZombieDungeonTheme.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7a7231c8d7a945f49e5434d0d691b4d 3 | timeCreated: 1474607080 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | --------------------------------------------------------------------------------