diff --git a/Assets/ControllerMapper.asset b/Assets/ControllerMapper.asset new file mode 100644 index 0000000..7f10675 --- /dev/null +++ b/Assets/ControllerMapper.asset @@ -0,0 +1,30 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 539aad81a9327404e8e67bb53c540d91, type: 3} + m_Name: ControllerMapper + m_EditorClassIdentifier: + Contexts: + - name: Normal + ButtonActions: [] + AxisRanges: + - name: MoveLeft + Axis: 00000000 + KeyboardKeys: 00000000 + - name: MoveRight + Axis: 01000000 + KeyboardKeys: + - name: MoveForward + Axis: 02000000 + KeyboardKeys: + - name: MoveBackward + Axis: 03000000 + KeyboardKeys: + ButtonStates: [] diff --git a/Assets/ControllerMapper.asset.meta b/Assets/ControllerMapper.asset.meta new file mode 100644 index 0000000..87c7470 --- /dev/null +++ b/Assets/ControllerMapper.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c1d726eedc374be4fb2ebc66c9c5a740 +timeCreated: 1454150249 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor.meta b/Assets/Editor.meta new file mode 100644 index 0000000..30f1702 --- /dev/null +++ b/Assets/Editor.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 2ca10ed205191f6469b088b753449e2e +folderAsset: yes +timeCreated: 1436647855 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor/InputHandler.meta b/Assets/Editor/InputHandler.meta new file mode 100644 index 0000000..60fef14 --- /dev/null +++ b/Assets/Editor/InputHandler.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 7f51e978f4624ae4794201e436ec39e5 +folderAsset: yes +timeCreated: 1435023323 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor/InputHandler/CreateControllerMapperAsset.cs b/Assets/Editor/InputHandler/CreateControllerMapperAsset.cs new file mode 100644 index 0000000..5ded958 --- /dev/null +++ b/Assets/Editor/InputHandler/CreateControllerMapperAsset.cs @@ -0,0 +1,21 @@ +using UnityEngine; +using System.Collections; +using UnityEditor; + +namespace InputHandler +{ + public class CreateControllerMapperAsset + { + [MenuItem("InputHandler/Create/ControllerMapper")] + public static void CreateInputAsset() + { + ControllerMapperAsset asset = ControllerMapperAsset.CreateInstance(); + AssetDatabase.CreateAsset(asset, "Assets/ControllerMapper.asset"); + AssetDatabase.SaveAssets(); + + EditorUtility.FocusProjectWindow(); + + Selection.activeObject = asset; + } + } +} \ No newline at end of file diff --git a/Assets/Editor/InputHandler/CreateControllerMapperAsset.cs.meta b/Assets/Editor/InputHandler/CreateControllerMapperAsset.cs.meta new file mode 100644 index 0000000..b030eaf --- /dev/null +++ b/Assets/Editor/InputHandler/CreateControllerMapperAsset.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 37a276da6a074c149a173094095c1e94 +timeCreated: 1434958498 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins.meta b/Assets/Plugins.meta new file mode 100644 index 0000000..8620172 --- /dev/null +++ b/Assets/Plugins.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: f50b7a79572e8f448b6b0bbc449a466c +folderAsset: yes +timeCreated: 1434857820 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/x86.meta b/Assets/Plugins/x86.meta new file mode 100644 index 0000000..58e77ae --- /dev/null +++ b/Assets/Plugins/x86.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d5a17b4fbbb9c794fb163e397e963e00 +folderAsset: yes +timeCreated: 1434857820 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/x86/XInputDotNetPure.dll b/Assets/Plugins/x86/XInputDotNetPure.dll new file mode 100644 index 0000000..f44f947 Binary files /dev/null and b/Assets/Plugins/x86/XInputDotNetPure.dll differ diff --git a/Assets/Plugins/x86/XInputDotNetPure.dll.meta b/Assets/Plugins/x86/XInputDotNetPure.dll.meta new file mode 100644 index 0000000..bd05672 --- /dev/null +++ b/Assets/Plugins/x86/XInputDotNetPure.dll.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: c4e96c35cd46f534592ecc07b608e110 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/x86/XInputInterface.dll b/Assets/Plugins/x86/XInputInterface.dll new file mode 100644 index 0000000..7efa8fa Binary files /dev/null and b/Assets/Plugins/x86/XInputInterface.dll differ diff --git a/Assets/Plugins/x86/XInputInterface.dll.meta b/Assets/Plugins/x86/XInputInterface.dll.meta new file mode 100644 index 0000000..6c437d5 --- /dev/null +++ b/Assets/Plugins/x86/XInputInterface.dll.meta @@ -0,0 +1,6 @@ +fileFormatVersion: 2 +guid: bbceb1b00a2e35849a7020d601589c40 +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/x86_64.meta b/Assets/Plugins/x86_64.meta new file mode 100644 index 0000000..f103658 --- /dev/null +++ b/Assets/Plugins/x86_64.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 19f56f3d79f95da47ae4895f7588c43b +folderAsset: yes +timeCreated: 1434857820 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/x86_64/XInputDotNetPure.dll b/Assets/Plugins/x86_64/XInputDotNetPure.dll new file mode 100644 index 0000000..d345520 Binary files /dev/null and b/Assets/Plugins/x86_64/XInputDotNetPure.dll differ diff --git a/Assets/Plugins/x86_64/XInputDotNetPure.dll.meta b/Assets/Plugins/x86_64/XInputDotNetPure.dll.meta new file mode 100644 index 0000000..b1b839c --- /dev/null +++ b/Assets/Plugins/x86_64/XInputDotNetPure.dll.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: b9f05caccaeb48146ae995df3ed431ab +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/x86_64/XInputInterface.dll b/Assets/Plugins/x86_64/XInputInterface.dll new file mode 100644 index 0000000..8a2d764 Binary files /dev/null and b/Assets/Plugins/x86_64/XInputInterface.dll differ diff --git a/Assets/Plugins/x86_64/XInputInterface.dll.meta b/Assets/Plugins/x86_64/XInputInterface.dll.meta new file mode 100644 index 0000000..bae1129 --- /dev/null +++ b/Assets/Plugins/x86_64/XInputInterface.dll.meta @@ -0,0 +1,6 @@ +fileFormatVersion: 2 +guid: ea895df4f09804d47ac0a43ce22418cb +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UnityVS.meta b/Assets/UnityVS.meta new file mode 100644 index 0000000..ff71935 --- /dev/null +++ b/Assets/UnityVS.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 02fe78e962405814a83b8ba6c9471d32 +folderAsset: yes +timeCreated: 1434850683 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UnityVS/Editor.meta b/Assets/UnityVS/Editor.meta new file mode 100644 index 0000000..9068aa4 --- /dev/null +++ b/Assets/UnityVS/Editor.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6e71a3e2fb5854e43823a9da25b68e21 +folderAsset: yes +timeCreated: 1434850683 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/characters.meta b/Assets/characters.meta new file mode 100644 index 0000000..417b866 --- /dev/null +++ b/Assets/characters.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 1a5a66ccc7886c14c853df3dcd5b11c6 +folderAsset: yes +timeCreated: 1454164396 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/characters/Prefabs/BlackBeard.prefab b/Assets/characters/Prefabs/BlackBeard.prefab index 3b90b17..ff2a9da 100644 Binary files a/Assets/characters/Prefabs/BlackBeard.prefab and b/Assets/characters/Prefabs/BlackBeard.prefab differ diff --git a/Assets/characters/Prefabs/RedBeard.prefab b/Assets/characters/Prefabs/RedBeard.prefab index c619f29..e0dacdb 100644 Binary files a/Assets/characters/Prefabs/RedBeard.prefab and b/Assets/characters/Prefabs/RedBeard.prefab differ diff --git a/Assets/characters/Prefabs/YellowBeard.prefab b/Assets/characters/Prefabs/YellowBeard.prefab index f3aa5de..b566aab 100644 Binary files a/Assets/characters/Prefabs/YellowBeard.prefab and b/Assets/characters/Prefabs/YellowBeard.prefab differ diff --git a/Assets/characters/Source/Animator_controllers/Unity_Free_anims.controller b/Assets/characters/Source/Animator_controllers/Unity_Free_anims.controller index ff248fa..af8d723 100644 Binary files a/Assets/characters/Source/Animator_controllers/Unity_Free_anims.controller and b/Assets/characters/Source/Animator_controllers/Unity_Free_anims.controller differ diff --git a/Assets/characters/Source/Custom_Materials/Color_Diffuse/Character_2.mat b/Assets/characters/Source/Custom_Materials/Color_Diffuse/Character_2.mat index 8a684c8..193c945 100644 Binary files a/Assets/characters/Source/Custom_Materials/Color_Diffuse/Character_2.mat and b/Assets/characters/Source/Custom_Materials/Color_Diffuse/Character_2.mat differ diff --git a/Assets/characters/Source/Custom_Materials/Color_Diffuse/Character_3.mat b/Assets/characters/Source/Custom_Materials/Color_Diffuse/Character_3.mat index 5ac58cd..77f7438 100644 Binary files a/Assets/characters/Source/Custom_Materials/Color_Diffuse/Character_3.mat and b/Assets/characters/Source/Custom_Materials/Color_Diffuse/Character_3.mat differ diff --git a/Assets/characters/Source/Custom_Materials/Color_Diffuse/Character_4.mat b/Assets/characters/Source/Custom_Materials/Color_Diffuse/Character_4.mat index f004960..004791b 100644 Binary files a/Assets/characters/Source/Custom_Materials/Color_Diffuse/Character_4.mat and b/Assets/characters/Source/Custom_Materials/Color_Diffuse/Character_4.mat differ diff --git a/Assets/characters/Source/Custom_Materials/Color_Diffuse/Expressions_Mat.mat b/Assets/characters/Source/Custom_Materials/Color_Diffuse/Expressions_Mat.mat index 4c57428..0722875 100644 Binary files a/Assets/characters/Source/Custom_Materials/Color_Diffuse/Expressions_Mat.mat and b/Assets/characters/Source/Custom_Materials/Color_Diffuse/Expressions_Mat.mat differ diff --git a/Assets/characters/Source/FBX_models/Expressions_Mesh/Materials/defaultMat.mat b/Assets/characters/Source/FBX_models/Expressions_Mesh/Materials/defaultMat.mat index 9fdb218..7b3a2ae 100644 Binary files a/Assets/characters/Source/FBX_models/Expressions_Mesh/Materials/defaultMat.mat and b/Assets/characters/Source/FBX_models/Expressions_Mesh/Materials/defaultMat.mat differ diff --git a/Assets/characters/Source/FBX_models/Materials/Color_toon_2.mat b/Assets/characters/Source/FBX_models/Materials/Color_toon_2.mat index 4a1a048..feb3d9e 100644 Binary files a/Assets/characters/Source/FBX_models/Materials/Color_toon_2.mat and b/Assets/characters/Source/FBX_models/Materials/Color_toon_2.mat differ diff --git a/Assets/characters/Source/Unity_Free_Animations/Materials/EyesMaterial.mat b/Assets/characters/Source/Unity_Free_Animations/Materials/EyesMaterial.mat index 8774c69..9d239b5 100644 Binary files a/Assets/characters/Source/Unity_Free_Animations/Materials/EyesMaterial.mat and b/Assets/characters/Source/Unity_Free_Animations/Materials/EyesMaterial.mat differ diff --git a/Assets/characters/Source/Unity_Free_Animations/Materials/SkinMaterial.mat b/Assets/characters/Source/Unity_Free_Animations/Materials/SkinMaterial.mat index 2d9f447..de033c8 100644 Binary files a/Assets/characters/Source/Unity_Free_Animations/Materials/SkinMaterial.mat and b/Assets/characters/Source/Unity_Free_Animations/Materials/SkinMaterial.mat differ diff --git a/Assets/characters/Source/Unity_Free_Animations/Materials/SuitMaterial.mat b/Assets/characters/Source/Unity_Free_Animations/Materials/SuitMaterial.mat index 2301e74..f767ac0 100644 Binary files a/Assets/characters/Source/Unity_Free_Animations/Materials/SuitMaterial.mat and b/Assets/characters/Source/Unity_Free_Animations/Materials/SuitMaterial.mat differ diff --git a/Assets/characters/Source/Unity_Free_Animations/Materials/TeethMaterial.mat b/Assets/characters/Source/Unity_Free_Animations/Materials/TeethMaterial.mat index 76cc56f..4fe95f8 100644 Binary files a/Assets/characters/Source/Unity_Free_Animations/Materials/TeethMaterial.mat and b/Assets/characters/Source/Unity_Free_Animations/Materials/TeethMaterial.mat differ diff --git a/Assets/characters/Source/Unity_Free_Animations/Materials/TongueMaterial.mat b/Assets/characters/Source/Unity_Free_Animations/Materials/TongueMaterial.mat index 06cdc11..4ada5e3 100644 Binary files a/Assets/characters/Source/Unity_Free_Animations/Materials/TongueMaterial.mat and b/Assets/characters/Source/Unity_Free_Animations/Materials/TongueMaterial.mat differ diff --git a/Assets/characters/Source/Unity_Free_Animations/Materials/body_color_map.mat b/Assets/characters/Source/Unity_Free_Animations/Materials/body_color_map.mat index 85ed48b..0557ce5 100644 Binary files a/Assets/characters/Source/Unity_Free_Animations/Materials/body_color_map.mat and b/Assets/characters/Source/Unity_Free_Animations/Materials/body_color_map.mat differ diff --git a/Assets/characters/Source/Unity_Free_Animations/Materials/eyes_color_map.mat b/Assets/characters/Source/Unity_Free_Animations/Materials/eyes_color_map.mat index b89f409..f5d5f7e 100644 Binary files a/Assets/characters/Source/Unity_Free_Animations/Materials/eyes_color_map.mat and b/Assets/characters/Source/Unity_Free_Animations/Materials/eyes_color_map.mat differ diff --git a/Assets/characters/Source/Unity_Free_Animations/Materials/face_color_map.mat b/Assets/characters/Source/Unity_Free_Animations/Materials/face_color_map.mat index 6a99680..966686e 100644 Binary files a/Assets/characters/Source/Unity_Free_Animations/Materials/face_color_map.mat and b/Assets/characters/Source/Unity_Free_Animations/Materials/face_color_map.mat differ diff --git a/Assets/prefabs.meta b/Assets/prefabs.meta new file mode 100644 index 0000000..e51d793 --- /dev/null +++ b/Assets/prefabs.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d46e4b1657db2724cac4c064621fe701 +folderAsset: yes +timeCreated: 1454164396 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/prefabs/Character.prefab b/Assets/prefabs/Character.prefab new file mode 100644 index 0000000..b2edb27 --- /dev/null +++ b/Assets/prefabs/Character.prefab @@ -0,0 +1,222 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &112728 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 445382} + - 33: {fileID: 3343356} + - 65: {fileID: 6548104} + - 23: {fileID: 2321704} + m_Layer: 0 + m_Name: Mesh + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &198196 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 466742} + - 33: {fileID: 3395200} + - 65: {fileID: 6560686} + - 23: {fileID: 2384050} + m_Layer: 0 + m_Name: Arm + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &198936 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 473846} + - 54: {fileID: 5463890} + - 114: {fileID: 11431374} + m_Layer: 0 + m_Name: Character + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &445382 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 112728} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: .529999971, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 466742} + m_Father: {fileID: 473846} + m_RootOrder: 0 +--- !u!4 &466742 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 198196} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: .646000028, y: -.159999996, z: .439999998} + m_LocalScale: {x: .200000003, y: .200000003, z: 1} + m_Children: [] + m_Father: {fileID: 445382} + m_RootOrder: 0 +--- !u!4 &473846 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 198936} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: .569999993, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 445382} + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!23 &2321704 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 112728} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_SubsetIndices: + m_StaticBatchRoot: {fileID: 0} + m_UseLightProbes: 1 + m_ReflectionProbeUsage: 1 + m_ProbeAnchor: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_ImportantGI: 0 + m_AutoUVMaxDistance: .5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!23 &2384050 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 198196} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_SubsetIndices: + m_StaticBatchRoot: {fileID: 0} + m_UseLightProbes: 1 + m_ReflectionProbeUsage: 1 + m_ProbeAnchor: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_ImportantGI: 0 + m_AutoUVMaxDistance: .5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!33 &3343356 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 112728} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!33 &3395200 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 198196} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!54 &5463890 +Rigidbody: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 198936} + serializedVersion: 2 + m_Mass: 1 + m_Drag: 0 + m_AngularDrag: .0500000007 + m_UseGravity: 1 + m_IsKinematic: 0 + m_Interpolate: 0 + m_Constraints: 80 + m_CollisionDetection: 0 +--- !u!65 &6548104 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 112728} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!65 &6560686 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 198196} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &11431374 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 198936} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0f36f7c8f7d8e03418efcbf2c3645cd8, type: 3} + m_Name: + m_EditorClassIdentifier: + MoveSpeed: 5 + TurnSpeed: 400 +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 0} + propertyPath: TurnSpeed + value: 400 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 198936} + m_IsPrefabParent: 1 diff --git a/Assets/prefabs/Character.prefab.meta b/Assets/prefabs/Character.prefab.meta new file mode 100644 index 0000000..35a0265 --- /dev/null +++ b/Assets/prefabs/Character.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d9aa98efb3480c8438047a4565cd1893 +timeCreated: 1454164878 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/prefabs/CharacterController.prefab b/Assets/prefabs/CharacterController.prefab new file mode 100644 index 0000000..d45b147 --- /dev/null +++ b/Assets/prefabs/CharacterController.prefab @@ -0,0 +1,54 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &117118 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 422570} + - 114: {fileID: 11495336} + m_Layer: 0 + m_Name: CharacterController + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &422570 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 117118} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: .666631162, y: .145443216, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11495336 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 117118} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8cb928dc47bb84343830c964dd63c454, type: 3} + m_Name: + m_EditorClassIdentifier: + character: {fileID: 0} + playerNumber: 0 +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 117118} + m_IsPrefabParent: 1 diff --git a/Assets/prefabs/CharacterController.prefab.meta b/Assets/prefabs/CharacterController.prefab.meta new file mode 100644 index 0000000..3d4fe8d --- /dev/null +++ b/Assets/prefabs/CharacterController.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0a3031db8d5701f47984a4267336a83f +timeCreated: 1454165045 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/scenes/PatScene.unity b/Assets/scenes/PatScene.unity new file mode 100644 index 0000000..b8a485b --- /dev/null +++ b/Assets/scenes/PatScene.unity @@ -0,0 +1,519 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: .25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: .5, g: .5, b: .5, a: 1} + m_FogMode: 3 + m_FogDensity: .00999999978 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: .211999997, g: .226999998, b: .259000003, a: 1} + m_AmbientEquatorColor: {r: .114, g: .125, b: .133000001, a: 1} + m_AmbientGroundColor: {r: .0469999984, g: .0430000015, b: .0350000001, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: .5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_GIWorkflowMode: 1 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 0 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_LightmapSnapshot: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: .5 + agentHeight: 2 + agentSlope: 45 + agentClimb: .400000006 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: .166666672 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &745232258 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 745232260} + - 114: {fileID: 745232259} + m_Layer: 0 + m_Name: CharacterController + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &745232259 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 745232258} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8cb928dc47bb84343830c964dd63c454, type: 3} + m_Name: + m_EditorClassIdentifier: + character: {fileID: 1721247737} + playerNumber: 0 +--- !u!4 &745232260 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 745232258} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: .666631162, y: .145443216, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 +--- !u!1 &1008797114 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1008797119} + - 20: {fileID: 1008797118} + - 92: {fileID: 1008797117} + - 124: {fileID: 1008797116} + - 81: {fileID: 1008797115} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &1008797115 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1008797114} + m_Enabled: 1 +--- !u!124 &1008797116 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1008797114} + m_Enabled: 1 +--- !u!92 &1008797117 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1008797114} + m_Enabled: 1 +--- !u!20 &1008797118 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1008797114} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 + m_StereoMirrorMode: 0 +--- !u!4 &1008797119 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1008797114} + m_LocalRotation: {x: .391935796, y: 0, z: 0, w: .919992566} + m_LocalPosition: {x: -.200000003, y: 4.9000001, z: -7.5999999} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!1 &1018231122 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1018231124} + - 114: {fileID: 1018231123} + m_Layer: 0 + m_Name: InputManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1018231123 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1018231122} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6e33ba5066fe01747b2722e6f089a2ba, type: 3} + m_Name: + m_EditorClassIdentifier: + MAX_PLAYER_COUNT: 3 + InputMapperAsset: {fileID: 11400000, guid: c1d726eedc374be4fb2ebc66c9c5a740, type: 2} +--- !u!4 &1018231124 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1018231122} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: .666631162, y: .145443216, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 +--- !u!1 &1052409465 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1052409467} + - 108: {fileID: 1052409466} + m_Layer: 0 + m_Name: Directional light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &1052409466 +Light: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1052409465} + m_Enabled: 1 + serializedVersion: 6 + m_Type: 1 + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_CookieSize: 10 + m_Shadows: + m_Type: 1 + m_Resolution: -1 + m_Strength: 1 + m_Bias: .0500000007 + m_NormalBias: .400000006 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_Lightmapping: 4 + m_BounceIntensity: 1 + m_ShadowRadius: 0 + m_ShadowAngle: 0 + m_AreaSize: {x: 1, y: 1} +--- !u!4 &1052409467 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1052409465} + m_LocalRotation: {x: .167316198, y: -.254906625, z: .0448322445, w: .951324344} + m_LocalPosition: {x: 15.0299997, y: -.0199999809, z: 8.30000019} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 5 +--- !u!1 &1574512656 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1574512657} + - 33: {fileID: 1574512660} + - 65: {fileID: 1574512659} + - 23: {fileID: 1574512658} + m_Layer: 0 + m_Name: Mesh + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1574512657 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1574512656} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: .529999971, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1721247739} + m_RootOrder: 0 +--- !u!23 &1574512658 +MeshRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1574512656} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_SubsetIndices: + m_StaticBatchRoot: {fileID: 0} + m_UseLightProbes: 1 + m_ReflectionProbeUsage: 1 + m_ProbeAnchor: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_ImportantGI: 0 + m_AutoUVMaxDistance: .5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!65 &1574512659 +BoxCollider: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1574512656} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!33 &1574512660 +MeshFilter: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1574512656} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1 &1721247736 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1721247739} + - 54: {fileID: 1721247738} + - 114: {fileID: 1721247737} + m_Layer: 0 + m_Name: Character + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1721247737 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1721247736} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0f36f7c8f7d8e03418efcbf2c3645cd8, type: 3} + m_Name: + m_EditorClassIdentifier: + MoveSpeed: 5 + TurnSpeed: 0 +--- !u!54 &1721247738 +Rigidbody: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1721247736} + serializedVersion: 2 + m_Mass: 1 + m_Drag: 0 + m_AngularDrag: .0500000007 + m_UseGravity: 1 + m_IsKinematic: 0 + m_Interpolate: 0 + m_Constraints: 80 + m_CollisionDetection: 0 +--- !u!4 &1721247739 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1721247736} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: .569999993, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1574512657} + m_Father: {fileID: 0} + m_RootOrder: 2 +--- !u!1 &2024085281 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 2024085285} + - 33: {fileID: 2024085284} + - 64: {fileID: 2024085283} + - 23: {fileID: 2024085282} + m_Layer: 0 + m_Name: Floor + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!23 &2024085282 +MeshRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2024085281} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_SubsetIndices: + m_StaticBatchRoot: {fileID: 0} + m_UseLightProbes: 1 + m_ReflectionProbeUsage: 1 + m_ProbeAnchor: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_ImportantGI: 0 + m_AutoUVMaxDistance: .5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!64 &2024085283 +MeshCollider: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2024085281} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Convex: 0 + m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} +--- !u!33 &2024085284 +MeshFilter: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2024085281} + m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &2024085285 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2024085281} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 5, y: 5, z: 5} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 4 diff --git a/Assets/scenes/PatScene.unity.meta b/Assets/scenes/PatScene.unity.meta new file mode 100644 index 0000000..8ec5354 --- /dev/null +++ b/Assets/scenes/PatScene.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f5d6138960cb5ef41863e6d47f253a3c +timeCreated: 1454148779 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/scripts/Character.cs b/Assets/scripts/Character.cs new file mode 100644 index 0000000..aa078ba --- /dev/null +++ b/Assets/scripts/Character.cs @@ -0,0 +1,46 @@ +using UnityEngine; +using System.Collections; + +[RequireComponent(typeof(Rigidbody))] +public class Character : MonoBehaviour +{ + public float MoveSpeed; + public float TurnSpeed; + + private Rigidbody rb; + private Quaternion targetRot; + + void Awake() + { + rb = GetComponent(); + } + + void Update() + { + rb.rotation = Quaternion.RotateTowards(rb.rotation, targetRot, TurnSpeed * Time.deltaTime); + } + + public void Move(float xValue, float zValue) + { + Vector3 forwardDir = Camera.main.transform.forward; + Vector3 rightDir = Camera.main.transform.right; + + forwardDir.y = 0f; + forwardDir = forwardDir.normalized * zValue; + + rightDir.y = 0f; + rightDir = rightDir.normalized * xValue; + + Vector3 newVelocity = (forwardDir + rightDir) * MoveSpeed; + + if (newVelocity != Vector3.zero) + { + // We rotate to face the new direction + targetRot = Quaternion.LookRotation(newVelocity.normalized); + } + + newVelocity.y = rb.velocity.y; + + rb.velocity = newVelocity; + } +} diff --git a/Assets/scripts/Character.cs.meta b/Assets/scripts/Character.cs.meta new file mode 100644 index 0000000..3f4aa1a --- /dev/null +++ b/Assets/scripts/Character.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0f36f7c8f7d8e03418efcbf2c3645cd8 +timeCreated: 1454148812 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/scripts/CharacterController.cs b/Assets/scripts/CharacterController.cs new file mode 100644 index 0000000..b2c8740 --- /dev/null +++ b/Assets/scripts/CharacterController.cs @@ -0,0 +1,55 @@ +using UnityEngine; +using System.Collections; +using InputHandler; + +public class CharacterController : MonoBehaviour +{ + public enum PlayerNumber { One, Two, Three } + + public Character character; + public PlayerNumber playerNumber; + + // Use this for initialization + void Start () + { + InputManager.Instance.PushActiveContext("Normal", (int)playerNumber); + InputManager.Instance.AddCallback((int)playerNumber, HandlePlayerButtons); + InputManager.Instance.AddCallback((int)playerNumber, HandlePlayerAxis); + } + + private void HandlePlayerAxis(MappedInput input) + { + if (character == null) return; + + float xValue = 0f; + + if (input.Ranges.ContainsKey("MoveLeft")) + { + xValue = -input.Ranges["MoveLeft"]; + } + else if (input.Ranges.ContainsKey("MoveRight")) + { + xValue = input.Ranges["MoveRight"]; + } + + float zValue = 0f; + + if (input.Ranges.ContainsKey("MoveForward")) + { + zValue = input.Ranges["MoveForward"]; + } + else if (input.Ranges.ContainsKey("MoveBackward")) + { + zValue = -input.Ranges["MoveBackward"]; + } + + character.Move(xValue, zValue); + } + + private void HandlePlayerButtons(MappedInput input) + { + if (character == null) return; + + + } +} diff --git a/Assets/scripts/CharacterController.cs.meta b/Assets/scripts/CharacterController.cs.meta new file mode 100644 index 0000000..744e509 --- /dev/null +++ b/Assets/scripts/CharacterController.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8cb928dc47bb84343830c964dd63c454 +timeCreated: 1454148825 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/scripts/InputHandler.meta b/Assets/scripts/InputHandler.meta new file mode 100644 index 0000000..8fe520f --- /dev/null +++ b/Assets/scripts/InputHandler.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d6e2ccb4aa280a04297ff5048cde5ee1 +folderAsset: yes +timeCreated: 1434183356 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/scripts/InputHandler/ControllerManager.cs b/Assets/scripts/InputHandler/ControllerManager.cs new file mode 100644 index 0000000..f911a9e --- /dev/null +++ b/Assets/scripts/InputHandler/ControllerManager.cs @@ -0,0 +1,196 @@ +using UnityEngine; +using System.Collections; +using XInputDotNetPure; +using System.Collections.Generic; + +namespace InputHandler +{ + public class ControllerManager : InputManager + { + private bool[] _initialSetupDone; + private PlayerIndex[] _playerIndexes; + private GamePadState[] _gamePadPreviousStates; + private GamePadState[] _gamePadStates; + + protected override void InitialSetup() + { + _initialSetupDone = new bool[MAX_PLAYER_COUNT]; + _playerIndexes = new PlayerIndex[MAX_PLAYER_COUNT]; + _gamePadPreviousStates = new GamePadState[MAX_PLAYER_COUNT]; + _gamePadStates = new GamePadState[MAX_PLAYER_COUNT]; + + for (int i = 0; i < MAX_PLAYER_COUNT; i++) + { + _gamePadStates[i] = GamePad.GetState(_playerIndexes[i]); + } + } + + protected override void MapInputs() + { + for (int i = 0; i < MAX_PLAYER_COUNT; i++) + { + _gamePadPreviousStates[i] = _gamePadStates[i]; + _gamePadStates[i] = GamePad.GetState(_playerIndexes[i]); + + if (!_gamePadPreviousStates[i].IsConnected || !_initialSetupDone[i]) + { + _initialSetupDone[i] = true; + + if (_gamePadStates[i].IsConnected) + { + _playerIndexes[i] = (PlayerIndex)i; + + Debug.Log(string.Format("GamePad {0} is ready", _playerIndexes[i])); + } + } + + MapPlayerInput(_inputMappers[i], _gamePadStates[i], _gamePadPreviousStates[i]); + } + } + + // TODO: Maybe reduce it to only the inputs actually used in the game? + private void MapPlayerInput(InputMapper inputMapper, GamePadState state, GamePadState previousState) + { + foreach (int axisInt in InputMapperAsset.GetMappedXboxAxis()) + { + MapXboxAxis(axisInt, inputMapper, state); + } + + foreach (int buttonInt in InputMapperAsset.GetMappedXboxButtons()) + { + MapXboxButton(buttonInt, inputMapper, state, previousState); + } + + // TODO: Put the following code into another class, so we can have 2 distinct XboxManager and KeyboardManager classes + + // We map only the keyboard keys that are going to be used in the game + + foreach (int key in InputMapperAsset.GetMappedKeyboardKeys()) + { + inputMapper.SetRawButtonState(100 + key, Input.GetKey((KeyCode)key), Input.GetKey((KeyCode)key) && !Input.GetKeyDown((KeyCode)key)); + } + + foreach (int key in InputMapperAsset.GetMappedKeyboardKeysAxis()) + { + float value = Input.GetKey((KeyCode)key) ? 1f : 0f; + + inputMapper.SetRawAxisValue(100 + key, value); + } + } + + private void MapXboxButton(int buttonInt, InputMapper inputMapper, GamePadState state, GamePadState previousState) + { + XboxInputConstants.Buttons button = (XboxInputConstants.Buttons)buttonInt; + + bool pressed = false; + bool previouslyPressed = false; + + switch (button) + { + case XboxInputConstants.Buttons.A: + pressed = state.Buttons.A == ButtonState.Pressed; + previouslyPressed = previousState.Buttons.A == ButtonState.Pressed; + break; + case XboxInputConstants.Buttons.B: + pressed = state.Buttons.B == ButtonState.Pressed; + previouslyPressed = previousState.Buttons.B == ButtonState.Pressed; + break; + case XboxInputConstants.Buttons.X: + pressed = state.Buttons.X == ButtonState.Pressed; + previouslyPressed = previousState.Buttons.X == ButtonState.Pressed; + break; + case XboxInputConstants.Buttons.Y: + pressed = state.Buttons.Y == ButtonState.Pressed; + previouslyPressed = previousState.Buttons.Y == ButtonState.Pressed; + break; + case XboxInputConstants.Buttons.LeftShoulder: + pressed = state.Buttons.LeftShoulder == ButtonState.Pressed; + previouslyPressed = previousState.Buttons.LeftShoulder == ButtonState.Pressed; + break; + case XboxInputConstants.Buttons.RightShoulder: + pressed = state.Buttons.RightShoulder == ButtonState.Pressed; + previouslyPressed = previousState.Buttons.RightShoulder == ButtonState.Pressed; + break; + case XboxInputConstants.Buttons.Back: + pressed = state.Buttons.Back == ButtonState.Pressed; + previouslyPressed = previousState.Buttons.Back == ButtonState.Pressed; + break; + case XboxInputConstants.Buttons.Start: + pressed = state.Buttons.Start == ButtonState.Pressed; + previouslyPressed = previousState.Buttons.Start == ButtonState.Pressed; + break; + case XboxInputConstants.Buttons.LeftStick: + pressed = state.Buttons.LeftStick == ButtonState.Pressed; + previouslyPressed = previousState.Buttons.LeftStick == ButtonState.Pressed; + break; + case XboxInputConstants.Buttons.RightStick: + pressed = state.Buttons.RightStick == ButtonState.Pressed; + previouslyPressed = previousState.Buttons.RightStick == ButtonState.Pressed; + break; + case XboxInputConstants.Buttons.DPadLeft: + pressed = state.DPad.Left == ButtonState.Pressed; + previouslyPressed = previousState.DPad.Left == ButtonState.Pressed; + break; + case XboxInputConstants.Buttons.DPadRight: + pressed = state.DPad.Right == ButtonState.Pressed; + previouslyPressed = previousState.DPad.Right == ButtonState.Pressed; + break; + case XboxInputConstants.Buttons.DPadUp: + pressed = state.DPad.Up == ButtonState.Pressed; + previouslyPressed = previousState.DPad.Up == ButtonState.Pressed; + break; + case XboxInputConstants.Buttons.DPadDown: + pressed = state.DPad.Down == ButtonState.Pressed; + previouslyPressed = previousState.DPad.Down == ButtonState.Pressed; + break; + } + + inputMapper.SetRawButtonState(buttonInt, pressed, previouslyPressed); + } + + private void MapXboxAxis(int axisInt, InputMapper inputMapper, GamePadState state) + { + XboxInputConstants.Axis axis = (XboxInputConstants.Axis)axisInt; + + float value = 0f; + + switch (axis) + { + case XboxInputConstants.Axis.LeftStickLeft: + // If the left stick X value is negative, we keep it and take its absolute value + value = state.ThumbSticks.Left.X < 0f ? -state.ThumbSticks.Left.X : 0f; + break; + case XboxInputConstants.Axis.LeftStickRight: + // If the left stick X value is positive, we keep it + value = state.ThumbSticks.Left.X > 0f ? state.ThumbSticks.Left.X : 0f; + break; + case XboxInputConstants.Axis.LeftStickDown: + value = state.ThumbSticks.Left.Y < 0f ? -state.ThumbSticks.Left.Y : 0f; + break; + case XboxInputConstants.Axis.LeftStickUp: + value = state.ThumbSticks.Left.Y > 0f ? state.ThumbSticks.Left.Y : 0f; + break; + case XboxInputConstants.Axis.RightStickLeft: + value = state.ThumbSticks.Right.X < 0f ? -state.ThumbSticks.Right.X : 0f; + break; + case XboxInputConstants.Axis.RightStickRight: + value = state.ThumbSticks.Right.X > 0f ? state.ThumbSticks.Right.X : 0f; + break; + case XboxInputConstants.Axis.RightStickDown: + value = state.ThumbSticks.Right.Y < 0f ? -state.ThumbSticks.Right.Y : 0f; + break; + case XboxInputConstants.Axis.RightStickUp: + value = state.ThumbSticks.Right.Y > 0f ? state.ThumbSticks.Right.Y : 0f; + break; + case XboxInputConstants.Axis.TriggerLeft: + value = state.Triggers.Left; + break; + case XboxInputConstants.Axis.TriggerRight: + value = state.Triggers.Right; + break; + } + + inputMapper.SetRawAxisValue(axisInt, value); + } + } +} diff --git a/Assets/scripts/InputHandler/ControllerManager.cs.meta b/Assets/scripts/InputHandler/ControllerManager.cs.meta new file mode 100644 index 0000000..f25f973 --- /dev/null +++ b/Assets/scripts/InputHandler/ControllerManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6e33ba5066fe01747b2722e6f089a2ba +timeCreated: 1436627825 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: -50 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/scripts/InputHandler/ControllerMapperAsset.cs b/Assets/scripts/InputHandler/ControllerMapperAsset.cs new file mode 100644 index 0000000..bf77e1d --- /dev/null +++ b/Assets/scripts/InputHandler/ControllerMapperAsset.cs @@ -0,0 +1,197 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; +using System; + +namespace InputHandler +{ + // TODO: REFACTOR THE WHOLE CLASS, IT STINKS + + [SerializeField] + public class ControllerMapperAsset : InputMapperAsset + { + [Serializable] + public class XboxContext + { + public string name; + public XboxAction[] ButtonActions; + public XboxRange[] AxisRanges; + public XboxState[] ButtonStates; + } + + [Serializable] + public class XboxAction + { + public string name; + public XboxInputConstants.Buttons[] XboxButtons; + public KeyCode[] KeyboardKeys; + } + + [Serializable] + public class XboxRange + { + public string name; + public XboxInputConstants.Axis[] Axis; + public KeyCode[] KeyboardKeys; + } + + [Serializable] + public class XboxState + { + public string name; + public XboxInputConstants.Buttons[] XboxButtons; + public KeyCode[] KeyboardKeys; + } + + public XboxContext[] Contexts; + + // TODO: Temporary + private List _mappedKeyboardKeysAxis; + private List _mappedKeyboardKeys; + private List _mappedXboxAxis; + private List _mappedXboxButtons; + + // Context -> InputMap + public override Dictionary GetMappedContexts() + { + _mappedKeyboardKeys = new List(); + _mappedKeyboardKeysAxis = new List(); + _mappedXboxButtons = new List(); + _mappedXboxAxis = new List(); + + Dictionary mappedContexts = new Dictionary(); + + foreach (XboxContext xboxContext in Contexts) + { + InputMap inputMap = new InputMap(); + + inputMap.ButtonsToActionsMap = new List[xboxContext.ButtonActions.Length]; + inputMap.ButtonsToStatesMap = new List[xboxContext.ButtonStates.Length]; + inputMap.AxisToRangesMap = new List[xboxContext.AxisRanges.Length]; + + for (int i = 0; i < xboxContext.ButtonActions.Length; i++) + { + XboxAction buttonAction = xboxContext.ButtonActions[i]; + + inputMap.ButtonsToActionsMap[i] = new List(); + + foreach (XboxInputConstants.Buttons xboxButton in buttonAction.XboxButtons) + { + // TODO: We need to manage this in the InputMapper side + inputMap.ButtonsToActionsMap[i].Add(new InputToActionMap { action = buttonAction.name, input = (int)xboxButton }); + + if (!_mappedXboxButtons.Contains((int)xboxButton)) + { + _mappedXboxButtons.Add((int)xboxButton); + } + } + + // Keyboard part + foreach (KeyCode key in buttonAction.KeyboardKeys) + { + // TODO: Find a way to not add 100 to the code (for now, it's necessary since there are overlaps with the xbox enum) + inputMap.ButtonsToActionsMap[i].Add(new InputToActionMap { action = buttonAction.name, input = 100 + (int)key }); + + // TODO: Temporary + if (!_mappedKeyboardKeys.Contains((int)key)) + { + _mappedKeyboardKeys.Add((int)key); + } + } + } + + for (int i = 0; i < xboxContext.ButtonStates.Length; i++) + { + XboxState buttonState = xboxContext.ButtonStates[i]; + + inputMap.ButtonsToStatesMap[i] = new List(); + + foreach (XboxInputConstants.Buttons xboxButton in buttonState.XboxButtons) + { + // TODO: We need to manage this in the InputMapper side + inputMap.ButtonsToStatesMap[i].Add(new InputToActionMap() { action = buttonState.name, input = (int)xboxButton }); + + if (!_mappedXboxButtons.Contains((int)xboxButton)) + { + _mappedXboxButtons.Add((int)xboxButton); + } + } + + // Keyboard part + foreach (KeyCode key in buttonState.KeyboardKeys) + { + // TODO: Find a way to not add 100 to the code (for now, it's necessary since there are overlaps with the xbox enum) + inputMap.ButtonsToStatesMap[i].Add(new InputToActionMap { action = buttonState.name, input = 100 + (int)key }); + + // TODO: Temporary + if (!_mappedKeyboardKeys.Contains((int)key)) + { + _mappedKeyboardKeys.Add((int)key); + } + } + } + + for (int i = 0; i < xboxContext.AxisRanges.Length; i++) + { + XboxRange axisRange = xboxContext.AxisRanges[i]; + + inputMap.AxisToRangesMap[i] = new List(); + + foreach (XboxInputConstants.Axis xboxAxis in axisRange.Axis) + { + // TODO: We need to manage this in the InputMapper side + inputMap.AxisToRangesMap[i].Add(new InputToActionMap() { action = axisRange.name, input = (int)xboxAxis }); + + if (!_mappedXboxAxis.Contains((int)xboxAxis)) + { + _mappedXboxAxis.Add((int)xboxAxis); + } + } + + // Keyboard part + foreach (KeyCode key in axisRange.KeyboardKeys) + { + // TODO: Find a way to not add 100 to the code (for now, it's necessary since there are overlaps with the xbox enum) + inputMap.AxisToRangesMap[i].Add(new InputToActionMap { action = axisRange.name, input = 100 + (int)key }); + + // TODO: Temporary + if (!_mappedKeyboardKeysAxis.Contains((int)key)) + { + _mappedKeyboardKeysAxis.Add((int)key); + } + } + } + + InputContext context = new InputContext(xboxContext.name, inputMap); + + mappedContexts.Add(xboxContext.name, context); + } + + return mappedContexts; + } + + // TODO: Probably temporary, until we find a better way and all the classes are refactored + + // Utility method to be used by the ControllerManager class + public override List GetMappedKeyboardKeysAxis() + { + return _mappedKeyboardKeysAxis; + } + + // Utility method to be used by the ControllerManager class + public override List GetMappedKeyboardKeys() + { + return _mappedKeyboardKeys; + } + + public override List GetMappedXboxAxis() + { + return _mappedXboxAxis; + } + + public override List GetMappedXboxButtons() + { + return _mappedXboxButtons; + } + } +} \ No newline at end of file diff --git a/Assets/scripts/InputHandler/ControllerMapperAsset.cs.meta b/Assets/scripts/InputHandler/ControllerMapperAsset.cs.meta new file mode 100644 index 0000000..aedca80 --- /dev/null +++ b/Assets/scripts/InputHandler/ControllerMapperAsset.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 539aad81a9327404e8e67bb53c540d91 +timeCreated: 1436387267 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/scripts/InputHandler/InputConstants.cs b/Assets/scripts/InputHandler/InputConstants.cs new file mode 100644 index 0000000..0b823e8 --- /dev/null +++ b/Assets/scripts/InputHandler/InputConstants.cs @@ -0,0 +1,19 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; + +namespace InputHandler +{ + public struct InputMap + { + public List[] ButtonsToActionsMap; + public List[] ButtonsToStatesMap; + public List[] AxisToRangesMap; + } + + public struct InputToActionMap + { + public int input; + public string action; + } +} diff --git a/Assets/scripts/InputHandler/InputConstants.cs.meta b/Assets/scripts/InputHandler/InputConstants.cs.meta new file mode 100644 index 0000000..5bc8258 --- /dev/null +++ b/Assets/scripts/InputHandler/InputConstants.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: baa0e457a4ff21a4a8eb7d57efeef697 +timeCreated: 1434996179 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/scripts/InputHandler/InputContext.cs b/Assets/scripts/InputHandler/InputContext.cs new file mode 100644 index 0000000..1ca6d92 --- /dev/null +++ b/Assets/scripts/InputHandler/InputContext.cs @@ -0,0 +1,70 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; +using System; + +namespace InputHandler +{ + public class InputContext + { + private Dictionary _mappedButtons; + private Dictionary _mappedStates; + private Dictionary _mappedAxis; + + private string _name; + + public string Name + { + get { return _name; } + } + + + public InputContext(string contextName, InputMap inputMap) + { + _name = contextName; + + _mappedButtons = new Dictionary(); + _mappedStates = new Dictionary(); + _mappedAxis = new Dictionary(); + + foreach (List buttonsToActionsMap in inputMap.ButtonsToActionsMap) + { + foreach (InputToActionMap buttonToActionMap in buttonsToActionsMap) + { + _mappedButtons.Add(buttonToActionMap.input, buttonToActionMap.action); + } + } + + foreach (List buttonsToStatesMap in inputMap.ButtonsToStatesMap) + { + foreach (InputToActionMap buttonToStateMap in buttonsToStatesMap) + { + _mappedStates.Add(buttonToStateMap.input, buttonToStateMap.action); + } + } + + foreach (List axisToRangesMap in inputMap.AxisToRangesMap) + { + foreach (InputToActionMap axisToRangeMap in axisToRangesMap) + { + _mappedAxis.Add(axisToRangeMap.input, axisToRangeMap.action); + } + } + } + + public string GetActionForButton(int button) + { + return _mappedButtons.ContainsKey(button) ? _mappedButtons[button] : null; + } + + public string GetStateForButton(int button) + { + return _mappedStates.ContainsKey(button) ? _mappedStates[button] : null; + } + + public string GetRangeForAxis(int axis) + { + return _mappedAxis.ContainsKey(axis) ? _mappedAxis[axis] : null; + } + } +} \ No newline at end of file diff --git a/Assets/scripts/InputHandler/InputContext.cs.meta b/Assets/scripts/InputHandler/InputContext.cs.meta new file mode 100644 index 0000000..dc2aa61 --- /dev/null +++ b/Assets/scripts/InputHandler/InputContext.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4d99cd0919594864482148f723dfa8e2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/scripts/InputHandler/InputManager.cs b/Assets/scripts/InputHandler/InputManager.cs new file mode 100644 index 0000000..2b259b9 --- /dev/null +++ b/Assets/scripts/InputHandler/InputManager.cs @@ -0,0 +1,98 @@ +using UnityEngine; +using System.Collections; +using XInputDotNetPure; +using System; +using System.Collections.Generic; + +namespace InputHandler +{ + public abstract class InputManager : MonoBehaviour + { + public static InputManager Instance + { + get + { + return _instance; + } + } + + private static InputManager _instance; + + protected InputMapper[] _inputMappers; + + public int MAX_PLAYER_COUNT = 2; + public InputMapperAsset InputMapperAsset; + + protected abstract void InitialSetup(); + protected abstract void MapInputs(); + + void Awake() + { + if (_instance != null) + { + Destroy(gameObject); + } + else + { + _instance = this; + + _inputMappers = new InputMapper[MAX_PLAYER_COUNT]; + + Dictionary mappedContexts = InputMapperAsset.GetMappedContexts(); + + for (int i = 0; i < MAX_PLAYER_COUNT; i++) + { + _inputMappers[i] = new InputMapper(mappedContexts, i); + } + + // Do the needed initial setup in the derived classes + InitialSetup(); + } + } + + void Update() + { + // Do the input mapping here in the derived classes + MapInputs(); + + for (int i = 0; i < _inputMappers.Length; i++) + { + _inputMappers[i].Dispatch(); + } + } + + public void AddCallback(int playerIndex, Action action) + { + _inputMappers[playerIndex].AddCallback(action); + } + + public void PushActiveContext(string name, int playerIndex) + { + _inputMappers[playerIndex].PushActiveContext(name); + } + + public void PopActiveContext(int playerIndex) + { + // TODO: Give the choice to remove an active context not on top + _inputMappers[playerIndex].PopActiveContext(); + } + + public void ClearContexts() + { + // For now, all input mappers are gonna have the same contexts at the same time + + for (int i = 0; i < _inputMappers.Length; i++) + { + _inputMappers[i].ClearActiveContexts(); + } + } + + void LateUpdate() + { + for (int i = 0; i < _inputMappers.Length; i++) + { + _inputMappers[i].ResetInputs(); + } + } + } +} \ No newline at end of file diff --git a/Assets/scripts/InputHandler/InputManager.cs.meta b/Assets/scripts/InputHandler/InputManager.cs.meta new file mode 100644 index 0000000..7e29a63 --- /dev/null +++ b/Assets/scripts/InputHandler/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 967b7f4e180b49f4fb6f53702c67aa34 +timeCreated: 1436627825 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: -100 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/scripts/InputHandler/InputMapper.cs b/Assets/scripts/InputHandler/InputMapper.cs new file mode 100644 index 0000000..a60b1f7 --- /dev/null +++ b/Assets/scripts/InputHandler/InputMapper.cs @@ -0,0 +1,205 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; +using System; + +/* + Strongly inspired from Mike Lewis' excellent post about input handling + http://www.gamedev.net/blog/355/entry-2250186-designing-a-robust-input-handling-system-for-games/ +*/ + +namespace InputHandler +{ + public class InputMapper + { + // Right now, the only active context is the peek of the stack, but when we will need multiple contexts at once, this is going to be useful + private Dictionary _contexts; + private Stack _activeContexts; + + private List> _callbacks; + + private MappedInput _currentFrameMappedInput; + + public InputMapper(Dictionary contexts, int playerIndex) + { + _contexts = contexts; + _activeContexts = new Stack(); + _callbacks = new List>(); + _currentFrameMappedInput = new MappedInput(playerIndex); + } + + public void Dispatch() + { + foreach (Action callback in _callbacks) + { + callback(_currentFrameMappedInput); + } + } + + public void PushActiveContext(string name) + { + InputContext context = _contexts[name]; + + if (_activeContexts.Count == 0 || _activeContexts.Peek().Name != name) + { + _activeContexts.Push(context); + } + } + + public void PopActiveContext() + { + if (_activeContexts.Count != 0) + { + _activeContexts.Pop(); + } + } + + public void ClearActiveContexts() + { + _activeContexts.Clear(); + } + + public void AddCallback(Action callback) + { + _callbacks.Add(callback); + } + + public void SetRawButtonState(int button, bool pressed, bool previouslyPressed) + { + string action = GetActionForButton(button); + string state = GetStateForButton(button); + + if (pressed) + { + if (!previouslyPressed && action != null) + { + _currentFrameMappedInput.Actions.Add(action); + return; + } + + if (state != null) + { + _currentFrameMappedInput.States.Add(state); + return; + } + } + + // Uncomment if we start to have problems + //RemoveButtonFromLists(button); + } + + public void SetRawAxisValue(int axis, float value) + { + // TODO: Have contexts for every single player? + + // TODO: Use the commented code below instead when we will want multiple contexts to be available at the same time (maybe for when the player holds a weapon?). We'll keep it simple for now. + + /* + foreach (InputContext activeContext in _activeContexts) + { + InputConstants.Ranges range = activeContext.GetRangeForAxis(axis); + + if (range != InputConstants.Ranges.None) + { + // We only want the first active "range behaviour" of the player to handle the ranges values, since we don't want multiple actions to react to it + _mappedInputs[playerIndex].Ranges[range] = value; + break; + } + }*/ + + if (value != 0f) + { + string range = null; + + if (_activeContexts.Count != 0) + { + range = _activeContexts.Peek().GetRangeForAxis(axis); + } + + if (range != null) + { + _currentFrameMappedInput.Ranges[range] = value; + } + } + } + + public void ResetInputs() + { + _currentFrameMappedInput.Clear(); + } + + #region Helper methods + + private string GetActionForButton(int button) + { + // TODO: Have contexts for every single player? + + // TODO: Use the commented code below instead when we will want multiple contexts to be available at the same time (maybe for when the player holds a weapon?). We'll keep it simple for now. + + /* + foreach (InputContext activeContext in _activeContexts) + { + InputConstants.Actions action = activeContext.GetActionForButton(button); + + if (action != InputConstants.Actions.None) + { + return action; + } + }*/ + + string action = null; + + if (_activeContexts.Count != 0) + { + action = _activeContexts.Peek().GetActionForButton(button); + } + + return action; + } + + private string GetStateForButton(int button) + { + // TODO: Have contexts for every single player? + + // TODO: Use the commented code below instead when we will want multiple contexts to be available at the same time (maybe for when the player holds a weapon?). We'll keep it simple for now. + + /* + foreach (InputContext activeContext in _activeContexts) + { + InputConstants.States state = activeContext.GetStateForButton(button); + + if (state != InputConstants.States.None) + { + return state; + } + }*/ + + string state = null; + + if (_activeContexts.Count != 0) + { + state = _activeContexts.Peek().GetStateForButton(button); + } + + return state; + } + + private void RemoveButtonFromLists(int button) + { + string action = GetActionForButton(button); + string state = GetStateForButton(button); + + if (action != null) + { + _currentFrameMappedInput.Actions.Remove(action); + } + + if (state != null) + { + _currentFrameMappedInput.States.Remove(state); + } + } + + #endregion + } +} diff --git a/Assets/scripts/InputHandler/InputMapper.cs.meta b/Assets/scripts/InputHandler/InputMapper.cs.meta new file mode 100644 index 0000000..f760acc --- /dev/null +++ b/Assets/scripts/InputHandler/InputMapper.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 586455317dda0b543a30eff647db722e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/scripts/InputHandler/InputMapperAsset.cs b/Assets/scripts/InputHandler/InputMapperAsset.cs new file mode 100644 index 0000000..f9bbbaa --- /dev/null +++ b/Assets/scripts/InputHandler/InputMapperAsset.cs @@ -0,0 +1,20 @@ +using UnityEngine; +using System.Collections; +using System; +using System.Collections.Generic; + +namespace InputHandler +{ + public abstract class InputMapperAsset : ScriptableObject + { + public enum InputTypes { Action, State, Range } + + public abstract Dictionary GetMappedContexts(); + + // TODO: Probably temporary, until we find a better way and all the classes are refactored + public abstract List GetMappedKeyboardKeysAxis(); + public abstract List GetMappedKeyboardKeys(); + public abstract List GetMappedXboxAxis(); + public abstract List GetMappedXboxButtons(); + } +} \ No newline at end of file diff --git a/Assets/scripts/InputHandler/InputMapperAsset.cs.meta b/Assets/scripts/InputHandler/InputMapperAsset.cs.meta new file mode 100644 index 0000000..beec650 --- /dev/null +++ b/Assets/scripts/InputHandler/InputMapperAsset.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3a5ffa04260e8db4a9eab84c1e6b11ae +timeCreated: 1434962375 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/scripts/InputHandler/MappedInput.cs b/Assets/scripts/InputHandler/MappedInput.cs new file mode 100644 index 0000000..704e700 --- /dev/null +++ b/Assets/scripts/InputHandler/MappedInput.cs @@ -0,0 +1,35 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; +using System; + +namespace InputHandler +{ + // Specific to the game + public class MappedInput + { + // We use hashets for the actions and the states because we just need to check if they are in the collection, and not retrieve them + public HashSet Actions = new HashSet(); + public HashSet States = new HashSet(); + public Dictionary Ranges = new Dictionary(); + + private int _playerIndex; + + public int PlayerIndex + { + get { return _playerIndex; } + } + + public MappedInput(int playerIndex) + { + _playerIndex = playerIndex; + } + + public void Clear() + { + Actions.Clear(); + States.Clear(); + Ranges.Clear(); + } + } +} \ No newline at end of file diff --git a/Assets/scripts/InputHandler/MappedInput.cs.meta b/Assets/scripts/InputHandler/MappedInput.cs.meta new file mode 100644 index 0000000..40b9d51 --- /dev/null +++ b/Assets/scripts/InputHandler/MappedInput.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d5fe308a0d85530408827f4357cc1ff5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/scripts/InputHandler/XboxInputConstants.cs b/Assets/scripts/InputHandler/XboxInputConstants.cs new file mode 100644 index 0000000..e5ab19d --- /dev/null +++ b/Assets/scripts/InputHandler/XboxInputConstants.cs @@ -0,0 +1,43 @@ +using UnityEngine; +using System.Collections; + +namespace InputHandler +{ + //TODO: When we will be ready to read raw inputs from a file, we need this to simply be generic "BUTTON_ONE, BUTTON_TWO, etc." + + public class XboxInputConstants + { + // These buttons will eventually map to controls saved in a file + public enum Buttons + { + A, + B, + X, + Y, + LeftShoulder, + RightShoulder, + Back, + Start, + LeftStick, + RightStick, + DPadLeft, + DPadRight, + DPadUp, + DPadDown, + } + + public enum Axis + { + LeftStickLeft, + LeftStickRight, + LeftStickUp, + LeftStickDown, + RightStickLeft, + RightStickRight, + RightStickUp, + RightStickDown, + TriggerLeft, + TriggerRight + } + } +} diff --git a/Assets/scripts/InputHandler/XboxInputConstants.cs.meta b/Assets/scripts/InputHandler/XboxInputConstants.cs.meta new file mode 100644 index 0000000..c9ed15d --- /dev/null +++ b/Assets/scripts/InputHandler/XboxInputConstants.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4b46fefecf9412e46bdad7c26a00d537 +timeCreated: 1436628179 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/UnityAdsSettings.asset b/ProjectSettings/UnityAdsSettings.asset new file mode 100644 index 0000000..224050c --- /dev/null +++ b/ProjectSettings/UnityAdsSettings.asset @@ -0,0 +1,11 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!292 &1 +UnityAdsSettings: + m_ObjectHideFlags: 0 + m_Enabled: 0 + m_InitializeOnStartup: 1 + m_TestMode: 0 + m_EnabledPlatforms: 4294967295 + m_IosGameId: + m_AndroidGameId: diff --git a/ProjectSettings/UnityAnalyticsManager.asset b/ProjectSettings/UnityAnalyticsManager.asset new file mode 100644 index 0000000..4a7b668 --- /dev/null +++ b/ProjectSettings/UnityAnalyticsManager.asset @@ -0,0 +1,10 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!303 &1 +UnityAnalyticsManager: + m_ObjectHideFlags: 0 + m_Enabled: 0 + m_InitializeOnStartup: 1 + m_TestMode: 0 + m_TestEventUrl: + m_TestConfigUrl: