Add player controls

This commit is contained in:
Patrice Vignola 2016-01-30 09:49:32 -05:00
parent 5fee223ff5
commit dbf913a02f
70 changed files with 2145 additions and 0 deletions

View File

@ -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: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c1d726eedc374be4fb2ebc66c9c5a740
timeCreated: 1454150249
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

9
Assets/Editor.meta Normal file
View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2ca10ed205191f6469b088b753449e2e
folderAsset: yes
timeCreated: 1436647855
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7f51e978f4624ae4794201e436ec39e5
folderAsset: yes
timeCreated: 1435023323
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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<ControllerMapperAsset>();
AssetDatabase.CreateAsset(asset, "Assets/ControllerMapper.asset");
AssetDatabase.SaveAssets();
EditorUtility.FocusProjectWindow();
Selection.activeObject = asset;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 37a276da6a074c149a173094095c1e94
timeCreated: 1434958498
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

9
Assets/Plugins.meta Normal file
View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: f50b7a79572e8f448b6b0bbc449a466c
folderAsset: yes
timeCreated: 1434857820
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
Assets/Plugins/x86.meta Normal file
View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: d5a17b4fbbb9c794fb163e397e963e00
folderAsset: yes
timeCreated: 1434857820
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: c4e96c35cd46f534592ecc07b608e110
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,6 @@
fileFormatVersion: 2
guid: bbceb1b00a2e35849a7020d601589c40
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 19f56f3d79f95da47ae4895f7588c43b
folderAsset: yes
timeCreated: 1434857820
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: b9f05caccaeb48146ae995df3ed431ab
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,6 @@
fileFormatVersion: 2
guid: ea895df4f09804d47ac0a43ce22418cb
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
Assets/UnityVS.meta Normal file
View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 02fe78e962405814a83b8ba6c9471d32
folderAsset: yes
timeCreated: 1434850683
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 6e71a3e2fb5854e43823a9da25b68e21
folderAsset: yes
timeCreated: 1434850683
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
Assets/characters.meta Normal file
View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1a5a66ccc7886c14c853df3dcd5b11c6
folderAsset: yes
timeCreated: 1454164396
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
Assets/prefabs.meta Normal file
View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: d46e4b1657db2724cac4c064621fe701
folderAsset: yes
timeCreated: 1454164396
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d9aa98efb3480c8438047a4565cd1893
timeCreated: 1454164878
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0a3031db8d5701f47984a4267336a83f
timeCreated: 1454165045
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f5d6138960cb5ef41863e6d47f253a3c
timeCreated: 1454148779
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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<Rigidbody>();
}
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;
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0f36f7c8f7d8e03418efcbf2c3645cd8
timeCreated: 1454148812
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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;
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8cb928dc47bb84343830c964dd63c454
timeCreated: 1454148825
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: d6e2ccb4aa280a04297ff5048cde5ee1
folderAsset: yes
timeCreated: 1434183356
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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);
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6e33ba5066fe01747b2722e6f089a2ba
timeCreated: 1436627825
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: -50
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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<int> _mappedKeyboardKeysAxis;
private List<int> _mappedKeyboardKeys;
private List<int> _mappedXboxAxis;
private List<int> _mappedXboxButtons;
// Context -> InputMap
public override Dictionary<string, InputContext> GetMappedContexts()
{
_mappedKeyboardKeys = new List<int>();
_mappedKeyboardKeysAxis = new List<int>();
_mappedXboxButtons = new List<int>();
_mappedXboxAxis = new List<int>();
Dictionary<string, InputContext> mappedContexts = new Dictionary<string, InputContext>();
foreach (XboxContext xboxContext in Contexts)
{
InputMap inputMap = new InputMap();
inputMap.ButtonsToActionsMap = new List<InputToActionMap>[xboxContext.ButtonActions.Length];
inputMap.ButtonsToStatesMap = new List<InputToActionMap>[xboxContext.ButtonStates.Length];
inputMap.AxisToRangesMap = new List<InputToActionMap>[xboxContext.AxisRanges.Length];
for (int i = 0; i < xboxContext.ButtonActions.Length; i++)
{
XboxAction buttonAction = xboxContext.ButtonActions[i];
inputMap.ButtonsToActionsMap[i] = new List<InputToActionMap>();
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<InputToActionMap>();
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<InputToActionMap>();
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<int> GetMappedKeyboardKeysAxis()
{
return _mappedKeyboardKeysAxis;
}
// Utility method to be used by the ControllerManager class
public override List<int> GetMappedKeyboardKeys()
{
return _mappedKeyboardKeys;
}
public override List<int> GetMappedXboxAxis()
{
return _mappedXboxAxis;
}
public override List<int> GetMappedXboxButtons()
{
return _mappedXboxButtons;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 539aad81a9327404e8e67bb53c540d91
timeCreated: 1436387267
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,19 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace InputHandler
{
public struct InputMap
{
public List<InputToActionMap>[] ButtonsToActionsMap;
public List<InputToActionMap>[] ButtonsToStatesMap;
public List<InputToActionMap>[] AxisToRangesMap;
}
public struct InputToActionMap
{
public int input;
public string action;
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: baa0e457a4ff21a4a8eb7d57efeef697
timeCreated: 1434996179
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,70 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
namespace InputHandler
{
public class InputContext
{
private Dictionary<int, string> _mappedButtons;
private Dictionary<int, string> _mappedStates;
private Dictionary<int, string> _mappedAxis;
private string _name;
public string Name
{
get { return _name; }
}
public InputContext(string contextName, InputMap inputMap)
{
_name = contextName;
_mappedButtons = new Dictionary<int, string>();
_mappedStates = new Dictionary<int, string>();
_mappedAxis = new Dictionary<int, string>();
foreach (List<InputToActionMap> buttonsToActionsMap in inputMap.ButtonsToActionsMap)
{
foreach (InputToActionMap buttonToActionMap in buttonsToActionsMap)
{
_mappedButtons.Add(buttonToActionMap.input, buttonToActionMap.action);
}
}
foreach (List<InputToActionMap> buttonsToStatesMap in inputMap.ButtonsToStatesMap)
{
foreach (InputToActionMap buttonToStateMap in buttonsToStatesMap)
{
_mappedStates.Add(buttonToStateMap.input, buttonToStateMap.action);
}
}
foreach (List<InputToActionMap> 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;
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4d99cd0919594864482148f723dfa8e2
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -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<string, InputContext> 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<MappedInput> 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();
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 967b7f4e180b49f4fb6f53702c67aa34
timeCreated: 1436627825
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: -100
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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<string, InputContext> _contexts;
private Stack<InputContext> _activeContexts;
private List<Action<MappedInput>> _callbacks;
private MappedInput _currentFrameMappedInput;
public InputMapper(Dictionary<string, InputContext> contexts, int playerIndex)
{
_contexts = contexts;
_activeContexts = new Stack<InputContext>();
_callbacks = new List<Action<MappedInput>>();
_currentFrameMappedInput = new MappedInput(playerIndex);
}
public void Dispatch()
{
foreach (Action<MappedInput> 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<MappedInput> 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
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 586455317dda0b543a30eff647db722e
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -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<string, InputContext> GetMappedContexts();
// TODO: Probably temporary, until we find a better way and all the classes are refactored
public abstract List<int> GetMappedKeyboardKeysAxis();
public abstract List<int> GetMappedKeyboardKeys();
public abstract List<int> GetMappedXboxAxis();
public abstract List<int> GetMappedXboxButtons();
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3a5ffa04260e8db4a9eab84c1e6b11ae
timeCreated: 1434962375
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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<string> Actions = new HashSet<string>();
public HashSet<string> States = new HashSet<string>();
public Dictionary<string, float> Ranges = new Dictionary<string, float>();
private int _playerIndex;
public int PlayerIndex
{
get { return _playerIndex; }
}
public MappedInput(int playerIndex)
{
_playerIndex = playerIndex;
}
public void Clear()
{
Actions.Clear();
States.Clear();
Ranges.Clear();
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d5fe308a0d85530408827f4357cc1ff5
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -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
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4b46fefecf9412e46bdad7c26a00d537
timeCreated: 1436628179
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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:

View File

@ -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: