diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta new file mode 100644 index 0000000..2d0e145 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ada75d1768d6fad4eb285bd538323380 +timeCreated: 1472582191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta new file mode 100644 index 0000000..2d0e145 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ada75d1768d6fad4eb285bd538323380 +timeCreated: 1472582191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs new file mode 100644 index 0000000..1106813 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using XboxCtrlrInput; + +namespace PlayerInput +{ + public class XboxControllerInputSource : InputSource where TTarget : MonoBehaviour + { + private static List allControllers; + public static IEnumerable AllControllers { get { return allControllers; } } + static XboxControllerInputSource() + { + allControllers = new List() + { + XboxController.First, + XboxController.Second, + XboxController.Third, + XboxController.Fourth, + }; + } + + private Dictionary buttonMapping; + private Dictionary axisMapping; + + private XboxController controller; + public XboxController Controller { get { return controller; } } + + public XboxControllerInputSource(XboxController controller) + { + this.controller = controller; + + buttonMapping = new Dictionary() + { + { InputButton.MenuSelect, XboxButton.A }, + { InputButton.MenuCancel, XboxButton.B }, + + //{ InputButton.UseItem, XboxButton.A }, + //{ InputButton.PickA, XboxButton.LeftBumper }, + //{ InputButton.PickB, XboxButton.RightBumper }, + + //{ InputButton.AnimalSelector, XboxButton.LeftBumper }, + }; + + axisMapping = new Dictionary() + { + { InputAxis.MenuX, XboxAxis.LeftStickX }, + { InputAxis.MenuY, XboxAxis.LeftStickY }, + + { InputAxis.RakeX, XboxAxis.RightStickX }, + { InputAxis.RakeY, XboxAxis.RightStickY }, + + { InputAxis.MoveX, XboxAxis.LeftStickX }, + { InputAxis.MoveY, XboxAxis.LeftStickY }, + + //{ InputAxis.Throttle, XboxAxis.RightTrigger }, + //{ InputAxis.RevThrottle, XboxAxis.LeftTrigger }, + }; + } + + protected override void VibrateInternal(float left, float right) + { + XCI.SetVibration(controller, left, right); + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + return XCI.GetButtonDown(buttonMapping[button], controller); + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + return XCI.GetButtonUp(buttonMapping[button], controller); + } + + public override bool ButtonDown(InputButton button) + { + return XCI.GetButton(buttonMapping[button], controller); + } + + public override float Axis(InputAxis axis) + { + return XCI.GetAxis(axisMapping[axis], controller); + } + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta new file mode 100644 index 0000000..2d0e145 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ada75d1768d6fad4eb285bd538323380 +timeCreated: 1472582191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs new file mode 100644 index 0000000..1106813 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using XboxCtrlrInput; + +namespace PlayerInput +{ + public class XboxControllerInputSource : InputSource where TTarget : MonoBehaviour + { + private static List allControllers; + public static IEnumerable AllControllers { get { return allControllers; } } + static XboxControllerInputSource() + { + allControllers = new List() + { + XboxController.First, + XboxController.Second, + XboxController.Third, + XboxController.Fourth, + }; + } + + private Dictionary buttonMapping; + private Dictionary axisMapping; + + private XboxController controller; + public XboxController Controller { get { return controller; } } + + public XboxControllerInputSource(XboxController controller) + { + this.controller = controller; + + buttonMapping = new Dictionary() + { + { InputButton.MenuSelect, XboxButton.A }, + { InputButton.MenuCancel, XboxButton.B }, + + //{ InputButton.UseItem, XboxButton.A }, + //{ InputButton.PickA, XboxButton.LeftBumper }, + //{ InputButton.PickB, XboxButton.RightBumper }, + + //{ InputButton.AnimalSelector, XboxButton.LeftBumper }, + }; + + axisMapping = new Dictionary() + { + { InputAxis.MenuX, XboxAxis.LeftStickX }, + { InputAxis.MenuY, XboxAxis.LeftStickY }, + + { InputAxis.RakeX, XboxAxis.RightStickX }, + { InputAxis.RakeY, XboxAxis.RightStickY }, + + { InputAxis.MoveX, XboxAxis.LeftStickX }, + { InputAxis.MoveY, XboxAxis.LeftStickY }, + + //{ InputAxis.Throttle, XboxAxis.RightTrigger }, + //{ InputAxis.RevThrottle, XboxAxis.LeftTrigger }, + }; + } + + protected override void VibrateInternal(float left, float right) + { + XCI.SetVibration(controller, left, right); + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + return XCI.GetButtonDown(buttonMapping[button], controller); + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + return XCI.GetButtonUp(buttonMapping[button], controller); + } + + public override bool ButtonDown(InputButton button) + { + return XCI.GetButton(buttonMapping[button], controller); + } + + public override float Axis(InputAxis axis) + { + return XCI.GetAxis(axisMapping[axis], controller); + } + } +} diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta new file mode 100644 index 0000000..9f6859f --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ec7d070ee2898544aa46811e0e3da197 +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta new file mode 100644 index 0000000..2d0e145 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ada75d1768d6fad4eb285bd538323380 +timeCreated: 1472582191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs new file mode 100644 index 0000000..1106813 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using XboxCtrlrInput; + +namespace PlayerInput +{ + public class XboxControllerInputSource : InputSource where TTarget : MonoBehaviour + { + private static List allControllers; + public static IEnumerable AllControllers { get { return allControllers; } } + static XboxControllerInputSource() + { + allControllers = new List() + { + XboxController.First, + XboxController.Second, + XboxController.Third, + XboxController.Fourth, + }; + } + + private Dictionary buttonMapping; + private Dictionary axisMapping; + + private XboxController controller; + public XboxController Controller { get { return controller; } } + + public XboxControllerInputSource(XboxController controller) + { + this.controller = controller; + + buttonMapping = new Dictionary() + { + { InputButton.MenuSelect, XboxButton.A }, + { InputButton.MenuCancel, XboxButton.B }, + + //{ InputButton.UseItem, XboxButton.A }, + //{ InputButton.PickA, XboxButton.LeftBumper }, + //{ InputButton.PickB, XboxButton.RightBumper }, + + //{ InputButton.AnimalSelector, XboxButton.LeftBumper }, + }; + + axisMapping = new Dictionary() + { + { InputAxis.MenuX, XboxAxis.LeftStickX }, + { InputAxis.MenuY, XboxAxis.LeftStickY }, + + { InputAxis.RakeX, XboxAxis.RightStickX }, + { InputAxis.RakeY, XboxAxis.RightStickY }, + + { InputAxis.MoveX, XboxAxis.LeftStickX }, + { InputAxis.MoveY, XboxAxis.LeftStickY }, + + //{ InputAxis.Throttle, XboxAxis.RightTrigger }, + //{ InputAxis.RevThrottle, XboxAxis.LeftTrigger }, + }; + } + + protected override void VibrateInternal(float left, float right) + { + XCI.SetVibration(controller, left, right); + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + return XCI.GetButtonDown(buttonMapping[button], controller); + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + return XCI.GetButtonUp(buttonMapping[button], controller); + } + + public override bool ButtonDown(InputButton button) + { + return XCI.GetButton(buttonMapping[button], controller); + } + + public override float Axis(InputAxis axis) + { + return XCI.GetAxis(axisMapping[axis], controller); + } + } +} diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta new file mode 100644 index 0000000..9f6859f --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ec7d070ee2898544aa46811e0e3da197 +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins.meta b/FallUnity/Assets/Plugins.meta new file mode 100644 index 0000000..b7025e8 --- /dev/null +++ b/FallUnity/Assets/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: dca2b803c244eb540bbf437959ae5f51 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta new file mode 100644 index 0000000..2d0e145 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ada75d1768d6fad4eb285bd538323380 +timeCreated: 1472582191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs new file mode 100644 index 0000000..1106813 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using XboxCtrlrInput; + +namespace PlayerInput +{ + public class XboxControllerInputSource : InputSource where TTarget : MonoBehaviour + { + private static List allControllers; + public static IEnumerable AllControllers { get { return allControllers; } } + static XboxControllerInputSource() + { + allControllers = new List() + { + XboxController.First, + XboxController.Second, + XboxController.Third, + XboxController.Fourth, + }; + } + + private Dictionary buttonMapping; + private Dictionary axisMapping; + + private XboxController controller; + public XboxController Controller { get { return controller; } } + + public XboxControllerInputSource(XboxController controller) + { + this.controller = controller; + + buttonMapping = new Dictionary() + { + { InputButton.MenuSelect, XboxButton.A }, + { InputButton.MenuCancel, XboxButton.B }, + + //{ InputButton.UseItem, XboxButton.A }, + //{ InputButton.PickA, XboxButton.LeftBumper }, + //{ InputButton.PickB, XboxButton.RightBumper }, + + //{ InputButton.AnimalSelector, XboxButton.LeftBumper }, + }; + + axisMapping = new Dictionary() + { + { InputAxis.MenuX, XboxAxis.LeftStickX }, + { InputAxis.MenuY, XboxAxis.LeftStickY }, + + { InputAxis.RakeX, XboxAxis.RightStickX }, + { InputAxis.RakeY, XboxAxis.RightStickY }, + + { InputAxis.MoveX, XboxAxis.LeftStickX }, + { InputAxis.MoveY, XboxAxis.LeftStickY }, + + //{ InputAxis.Throttle, XboxAxis.RightTrigger }, + //{ InputAxis.RevThrottle, XboxAxis.LeftTrigger }, + }; + } + + protected override void VibrateInternal(float left, float right) + { + XCI.SetVibration(controller, left, right); + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + return XCI.GetButtonDown(buttonMapping[button], controller); + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + return XCI.GetButtonUp(buttonMapping[button], controller); + } + + public override bool ButtonDown(InputButton button) + { + return XCI.GetButton(buttonMapping[button], controller); + } + + public override float Axis(InputAxis axis) + { + return XCI.GetAxis(axisMapping[axis], controller); + } + } +} diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta new file mode 100644 index 0000000..9f6859f --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ec7d070ee2898544aa46811e0e3da197 +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins.meta b/FallUnity/Assets/Plugins.meta new file mode 100644 index 0000000..b7025e8 --- /dev/null +++ b/FallUnity/Assets/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: dca2b803c244eb540bbf437959ae5f51 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll b/FallUnity/Assets/Plugins/XInputDotNetPure.dll new file mode 100644 index 0000000..d345520 --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll Binary files differ diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta new file mode 100644 index 0000000..2d0e145 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ada75d1768d6fad4eb285bd538323380 +timeCreated: 1472582191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs new file mode 100644 index 0000000..1106813 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using XboxCtrlrInput; + +namespace PlayerInput +{ + public class XboxControllerInputSource : InputSource where TTarget : MonoBehaviour + { + private static List allControllers; + public static IEnumerable AllControllers { get { return allControllers; } } + static XboxControllerInputSource() + { + allControllers = new List() + { + XboxController.First, + XboxController.Second, + XboxController.Third, + XboxController.Fourth, + }; + } + + private Dictionary buttonMapping; + private Dictionary axisMapping; + + private XboxController controller; + public XboxController Controller { get { return controller; } } + + public XboxControllerInputSource(XboxController controller) + { + this.controller = controller; + + buttonMapping = new Dictionary() + { + { InputButton.MenuSelect, XboxButton.A }, + { InputButton.MenuCancel, XboxButton.B }, + + //{ InputButton.UseItem, XboxButton.A }, + //{ InputButton.PickA, XboxButton.LeftBumper }, + //{ InputButton.PickB, XboxButton.RightBumper }, + + //{ InputButton.AnimalSelector, XboxButton.LeftBumper }, + }; + + axisMapping = new Dictionary() + { + { InputAxis.MenuX, XboxAxis.LeftStickX }, + { InputAxis.MenuY, XboxAxis.LeftStickY }, + + { InputAxis.RakeX, XboxAxis.RightStickX }, + { InputAxis.RakeY, XboxAxis.RightStickY }, + + { InputAxis.MoveX, XboxAxis.LeftStickX }, + { InputAxis.MoveY, XboxAxis.LeftStickY }, + + //{ InputAxis.Throttle, XboxAxis.RightTrigger }, + //{ InputAxis.RevThrottle, XboxAxis.LeftTrigger }, + }; + } + + protected override void VibrateInternal(float left, float right) + { + XCI.SetVibration(controller, left, right); + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + return XCI.GetButtonDown(buttonMapping[button], controller); + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + return XCI.GetButtonUp(buttonMapping[button], controller); + } + + public override bool ButtonDown(InputButton button) + { + return XCI.GetButton(buttonMapping[button], controller); + } + + public override float Axis(InputAxis axis) + { + return XCI.GetAxis(axisMapping[axis], controller); + } + } +} diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta new file mode 100644 index 0000000..9f6859f --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ec7d070ee2898544aa46811e0e3da197 +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins.meta b/FallUnity/Assets/Plugins.meta new file mode 100644 index 0000000..b7025e8 --- /dev/null +++ b/FallUnity/Assets/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: dca2b803c244eb540bbf437959ae5f51 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll b/FallUnity/Assets/Plugins/XInputDotNetPure.dll new file mode 100644 index 0000000..d345520 --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta new file mode 100644 index 0000000..c87585b --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: a05c5d8086133f648a3dd3229d764a63 +timeCreated: 1572134134 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta new file mode 100644 index 0000000..2d0e145 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ada75d1768d6fad4eb285bd538323380 +timeCreated: 1472582191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs new file mode 100644 index 0000000..1106813 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using XboxCtrlrInput; + +namespace PlayerInput +{ + public class XboxControllerInputSource : InputSource where TTarget : MonoBehaviour + { + private static List allControllers; + public static IEnumerable AllControllers { get { return allControllers; } } + static XboxControllerInputSource() + { + allControllers = new List() + { + XboxController.First, + XboxController.Second, + XboxController.Third, + XboxController.Fourth, + }; + } + + private Dictionary buttonMapping; + private Dictionary axisMapping; + + private XboxController controller; + public XboxController Controller { get { return controller; } } + + public XboxControllerInputSource(XboxController controller) + { + this.controller = controller; + + buttonMapping = new Dictionary() + { + { InputButton.MenuSelect, XboxButton.A }, + { InputButton.MenuCancel, XboxButton.B }, + + //{ InputButton.UseItem, XboxButton.A }, + //{ InputButton.PickA, XboxButton.LeftBumper }, + //{ InputButton.PickB, XboxButton.RightBumper }, + + //{ InputButton.AnimalSelector, XboxButton.LeftBumper }, + }; + + axisMapping = new Dictionary() + { + { InputAxis.MenuX, XboxAxis.LeftStickX }, + { InputAxis.MenuY, XboxAxis.LeftStickY }, + + { InputAxis.RakeX, XboxAxis.RightStickX }, + { InputAxis.RakeY, XboxAxis.RightStickY }, + + { InputAxis.MoveX, XboxAxis.LeftStickX }, + { InputAxis.MoveY, XboxAxis.LeftStickY }, + + //{ InputAxis.Throttle, XboxAxis.RightTrigger }, + //{ InputAxis.RevThrottle, XboxAxis.LeftTrigger }, + }; + } + + protected override void VibrateInternal(float left, float right) + { + XCI.SetVibration(controller, left, right); + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + return XCI.GetButtonDown(buttonMapping[button], controller); + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + return XCI.GetButtonUp(buttonMapping[button], controller); + } + + public override bool ButtonDown(InputButton button) + { + return XCI.GetButton(buttonMapping[button], controller); + } + + public override float Axis(InputAxis axis) + { + return XCI.GetAxis(axisMapping[axis], controller); + } + } +} diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta new file mode 100644 index 0000000..9f6859f --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ec7d070ee2898544aa46811e0e3da197 +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins.meta b/FallUnity/Assets/Plugins.meta new file mode 100644 index 0000000..b7025e8 --- /dev/null +++ b/FallUnity/Assets/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: dca2b803c244eb540bbf437959ae5f51 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll b/FallUnity/Assets/Plugins/XInputDotNetPure.dll new file mode 100644 index 0000000..d345520 --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta new file mode 100644 index 0000000..c87585b --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: a05c5d8086133f648a3dd3229d764a63 +timeCreated: 1572134134 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs new file mode 100644 index 0000000..69ee3a8 --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs @@ -0,0 +1,1969 @@ +using UnityEngine; +using UnityEngine.SceneManagement; + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN +using XInputDotNetPure; +#endif + +namespace XboxCtrlrInput +{ + + // ================= Enumerations ==================== // + + /// + /// List of enumerated identifiers for Xbox controllers. + /// + /// + /// Do NOT change enum values + /// + public enum XboxController + { + /// + /// "All" Controllers is deprecated! Use "Any" instead. + /// + [System.Obsolete("Instead use XboxController.Any")] + All = 0, + + Any = 0, + + First = 1, + Second = 2, + Third = 3, + Fourth = 4 + } + + /// + /// List of enumerated identifiers for Xbox buttons. + /// + public enum XboxButton + { + A, + B, + X, + Y, + Start, + Back, + LeftStick, + RightStick, + LeftBumper, + RightBumper, + DPadUp, + DPadDown, + DPadLeft, + DPadRight + } + + /// + /// List of enumerated identifiers for Xbox D-Pad directions. + /// + public enum XboxDPad + { + Up, + Down, + Left, + Right + } + + /// + /// List of enumerated identifiers for Xbox axis. + /// + public enum XboxAxis + { + LeftStickX, + LeftStickY, + RightStickX, + RightStickY, + LeftTrigger, + RightTrigger + } + + // ================ Classes =================== // + + public static class XCI + { + // ------------ Public Methods --------------- // + + public static bool SetVibration(XboxController controller, float left, float right) + { + + int controllerNumber = (int)controller; + + if (OnWindowsNative()) + { + GamePad.SetVibration((PlayerIndex)(controllerNumber - 1), left, right); + } + else + { + + } + + return false; + } + + // >>> For Buttons <<< // + + /// + /// Returns true if the specified button is held down by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButton(XboxButton button) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true if the specified button is held down by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButton(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButton(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonDown(XboxButton button) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonDown(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonDown(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonUp(XboxButton button) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonUp(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonUp(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + // >>> For D-Pad <<< // + + /// + /// Returns true if the specified D-Pad direction is pressed down by any controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + public static bool GetDPad(XboxDPad padDirection) + { + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, 0); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + /// + /// Returns true if the specified D-Pad direction is pressed down by a specified controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + /// + /// An identifier for the specific controller on which to test the D-Pad. + /// + public static bool GetDPad(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPad(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, controllerNumber); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadUp(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadUp(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadUp(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadDown(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadDown(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadDown(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // >>> For Axis <<< // + + /// + /// Returns the analog number of the specified axis from any controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxis(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxis(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxis(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from any controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxisRaw(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxisRaw(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxisRaw(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + // >>> Other important functions <<< // + + /// + /// Returns the number of Xbox controllers plugged to the computer. + /// + public static int GetNumPluggedCtrlrs() + { + int r = 0; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!xiNumOfCtrlrsQueried || !XInputStillInCurrFrame()) + { + xiNumOfCtrlrsQueried = true; + XInputUpdateAllStates(); + } + + for(int i = 0; i < 4; i++) + { + if(xInputCtrlrs[i].IsConnected) + { + r++; + } + } + #endif + } + + else + { + string[] ctrlrNames = Input.GetJoystickNames(); + for(int i = 0; i < ctrlrNames.Length; i++) + { + if(ctrlrNames[i].Contains("Xbox") || ctrlrNames[i].Contains("XBOX") || ctrlrNames[i].Contains("Microsoft")) + { + r++; + } + } + } + + return r; + } + + /// + /// DEBUG function. Log all controller names to Unity's console. + /// + public static void DEBUG_LogControllerNames() + { + string[] cNames = Input.GetJoystickNames(); + + for(int i = 0; i < cNames.Length; i++) + { + Debug.Log("Ctrlr " + i.ToString() + ": " + cNames[i]); + } + } + + + + + + // From @xoorath + /// + /// DEPRECATED: + /// Determines if the controller is plugged in the specified controllerNumber. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. An int between 1 and 4. + /// + [System.Obsolete("Instead use IsPluggedIn(XboxController)")] + public static bool IsPluggedIn(int controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + return ctrlrState.IsConnected; + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + // Based off @xoorath 's implementation + /// + /// Determines if the controller is plugged in the specified controllerNumber. + /// Passing Any will evaluate if any controller is connected. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// Passing Any will evaluate if any controller is connected. + /// + public static bool IsPluggedIn(XboxController controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + { + if (OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState; + + + // If inquiring about any controller + + // TODO: Remove condition for XboxController.All when the time comes + // Users of XCI: Feel free to remove XboxController.All if you like having no warnings + if(controllerNumber == XboxController.Any || controllerNumber == XboxController.All) + { + // Examine all controllers it see if any are connected + for(int i = 1; i <= 4; i++) + { + ctrlrState = XInputGetPaticularState(i); + if(ctrlrState.IsConnected) + { + return true; + } + } + } + + + // If specifying a specific controller + + // Note: Casting only works if XboxController enums are values 1 to 4 (First, Second, Third, Fourth) + ctrlrState = XInputGetPaticularState((int)controllerNumber); + + return ctrlrState.IsConnected; + } + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + + + //// + // ------------- Private -------------- // + //// + + // ------------ Methods --------------- // + + private static bool OnMac() + { + // All Mac mappings are based off TattieBogle Xbox Controller drivers + // http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver + // http://wiki.unity3d.com/index.php?title=Xbox360Controller + return (Application.platform == RuntimePlatform.OSXEditor || + Application.platform == RuntimePlatform.OSXPlayer ); + } + + private static bool OnWindows() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnWindowsNative() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnLinux() + { + // Linux mapping based on observation of mapping from default drivers on Ubuntu 13.04 + return Application.platform == RuntimePlatform.LinuxPlayer; + } + + private static bool IsControllerWireless() + { + // 0 means for any controller + return IsControllerWireless(0); + } + + private static bool IsControllerWireless(int ctrlNum) + { + if (ctrlNum < 0 || ctrlNum > 4) return false; + + // If 0 is passed in, that assumes that only 1 controller is plugged in. + if(ctrlNum == 0) + { + return ( (string) Input.GetJoystickNames()[0]).Contains("Wireless"); + } + + return ( (string) Input.GetJoystickNames()[ctrlNum-1]).Contains("Wireless"); + } + + private static bool IsControllerNumberValid(int ctrlrNum) + { + if(ctrlrNum > 0 && ctrlrNum <= 4) + { + return true; + } + else + { + Debug.LogError("XCI.IsControllerNumberValid(): " + + "Invalid contoller number! Should be between 1 and 4."); + } + return false; + } + + private static float RefactorRange(float oldRangeValue, int ctrlrNum, XboxAxis axis) + { + // HACK: On OS X, Left and right trigger under OSX return 0.5 until touched + // Issue #16 on Github: https://github.com/JISyed/Unity-XboxCtrlrInput/issues/16 + if(XCI.OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + else if(axis == XboxAxis.RightTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + } + + // Assumes you want to take a number from -1 to 1 range + // And turn it into a number from a 0 to 1 range + return ((oldRangeValue + 1.0f) / 2.0f ); + } + + private static string DetermineButtonCode(XboxButton btn, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sKeyCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + if(OnMac()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "16"; break; + case XboxButton.B: sKeyCode = "17"; break; + case XboxButton.X: sKeyCode = "18"; break; + case XboxButton.Y: sKeyCode = "19"; break; + case XboxButton.Start: sKeyCode = "9"; break; + case XboxButton.Back: sKeyCode = "10"; break; + case XboxButton.LeftStick: sKeyCode = "11"; break; + case XboxButton.RightStick: sKeyCode = "12"; break; + case XboxButton.LeftBumper: sKeyCode = "13"; break; + case XboxButton.RightBumper: sKeyCode = "14"; break; + + default: invalidCode = true; break; + } + } + else if (OnLinux()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "9"; break; + case XboxButton.RightStick: sKeyCode = "10"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "8"; break; + case XboxButton.RightStick: sKeyCode = "9"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + + r = "joystick" + sJoyCode + " button " + sKeyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineAxisCode(XboxAxis axs, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sAxisCode = ""; + bool invalidCode = false; + + + if(OnMac()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "3"; break; + case XboxAxis.RightStickY: sAxisCode = "4"; break; + case XboxAxis.LeftTrigger: sAxisCode = "5"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else if(OnLinux()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "3"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "9"; break; + case XboxAxis.RightTrigger: sAxisCode = "10"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sAxisCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static float AdjustAxisValues(float axisValue, XboxAxis axis, int ctrlrNum) + { + float newAxisValue = axisValue; + + if(OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = -newAxisValue; + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightStickY) + { + newAxisValue = -newAxisValue; + } + } + else if(OnLinux()) + { + if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + } + + return newAxisValue; + } + + private static string DetermineDPad(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sPadCode = ""; + bool invalidCode = false; + + if(OnLinux()) + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "8"; break; + case XboxDPad.Down: sPadCode = "8"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "7"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "7"; break; + case XboxDPad.Down: sPadCode = "7"; break; + case XboxDPad.Left: sPadCode = "6"; break; + case XboxDPad.Right: sPadCode = "6"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sPadCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadMac(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "5"; break; + case XboxDPad.Down: sPadCode = "6"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "8"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadWirelessLinux(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "13"; break; + case XboxDPad.Down: sPadCode = "14"; break; + case XboxDPad.Left: sPadCode = "11"; break; + case XboxDPad.Right: sPadCode = "12"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + + // ------------- Private XInput Wrappers (for Windows Native player and editor only) -------------- // + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + + // ------------ Inner Class ------------// + + // Used to setup XInput for Windows + class XciXInputInitializer + { + // Ctor + public XciXInputInitializer() + { + // Only runs once. + // Setup XInput here... + + + // Call input states twice in order to make sure that + // the previous states and current states are the same. + // This is needed to prevent errors where GetButtonUp will trigger unexpectledly + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + } + + public void Dummy() + { + // Intentionally does nothing to prevent warnings + } + } + + + + // ------------ Members --------------- // + + // Windows variables + private static GamePadState[] xInputCtrlrs = new GamePadState[4]; + private static GamePadState[] xInputCtrlrsPrev = new GamePadState[4]; + private static int xiPrevFrameCount = -1; + private static bool xiUpdateAlreadyCalled = false; + private static bool xiNumOfCtrlrsQueried = false; + private static XciXInputInitializer xinputInitalizer = new XCI.XciXInputInitializer(); + + + + // This can be set to something different if you want + private const GamePadDeadZone WindowsDeadzoneMethod = GamePadDeadZone.Circular; + + + + // ------------ Methods --------------- // + + //>> For updating states << + + private static void XInputUpdateAllStates() + { + if(xiUpdateAlreadyCalled) return; + + for(int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex) i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + xiUpdateAlreadyCalled = true; + } + + + //>> For getting states << + private static GamePadState XInputGetSingleState() + { + return xInputCtrlrs[0]; + } + + private static GamePadState XInputGetPaticularState(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrs[0]; + + return xInputCtrlrs[ctrlNum-1]; + } + + private static GamePadState XInputGetSingleStatePrev() + { + return xInputCtrlrsPrev[0]; + } + + private static GamePadState XInputGetPaticularStatePrev(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrsPrev[0]; + + return xInputCtrlrsPrev[ctrlNum-1]; + } + + //>> For getting input << + private static ButtonState XInputGetButtonState(GamePadButtons xiButtons, XboxButton xciBtn) + { + ButtonState stateToReturn = ButtonState.Pressed; + + switch(xciBtn) + { + case XboxButton.A: stateToReturn = xiButtons.A; break; + case XboxButton.B: stateToReturn = xiButtons.B; break; + case XboxButton.X: stateToReturn = xiButtons.X; break; + case XboxButton.Y: stateToReturn = xiButtons.Y; break; + case XboxButton.Start: stateToReturn = xiButtons.Start; break; + case XboxButton.Back: stateToReturn = xiButtons.Back; break; + case XboxButton.LeftBumper: stateToReturn = xiButtons.LeftShoulder; break; + case XboxButton.RightBumper: stateToReturn = xiButtons.RightShoulder; break; + case XboxButton.LeftStick: stateToReturn = xiButtons.LeftStick; break; + case XboxButton.RightStick: stateToReturn = xiButtons.RightStick; break; + } + + return stateToReturn; + } + + private static ButtonState XInputGetDPadState(GamePadDPad xiDPad, XboxDPad xciDPad) + { + ButtonState stateToReturn = ButtonState.Released; + + switch(xciDPad) + { + case XboxDPad.Up: stateToReturn = xiDPad.Up; break; + case XboxDPad.Down: stateToReturn = xiDPad.Down; break; + case XboxDPad.Left: stateToReturn = xiDPad.Left; break; + case XboxDPad.Right: stateToReturn = xiDPad.Right; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadTriggers xiTriggers, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftTrigger: stateToReturn = xiTriggers.Left; break; + case XboxAxis.RightTrigger: stateToReturn = xiTriggers.Right; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadThumbSticks xiThumbSticks, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftStickX: stateToReturn = xiThumbSticks.Left.X; break; + case XboxAxis.LeftStickY: stateToReturn = xiThumbSticks.Left.Y; break; + case XboxAxis.RightStickX: stateToReturn = xiThumbSticks.Right.X; break; + case XboxAxis.RightStickY: stateToReturn = xiThumbSticks.Right.Y; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static bool XInputStillInCurrFrame() + { + bool r = false; + xinputInitalizer.Dummy(); // Stop warnings about not using the initilaizer + + // Get the current frame + int currFrame = Time.frameCount; + + // Are we still in the current frame? + if(xiPrevFrameCount == currFrame) + { + r = true; + } + else + { + r = false; + xiUpdateAlreadyCalled = false; + } + + // Assign the previous frame count regardless of whether it's the same or not. + xiPrevFrameCount = currFrame; + + return r; + } + + + #endif + + // END of Windows only subsystem ========================================== + + + + // -------------------------- Handler Script ------------------- + + // Secret Private Script that does some maintainace work for XCI states. User should not use this script at all. + private class XciHandler : MonoBehaviour + { + private static XciHandler instance = null; + + public bool u3dTrigger0LeftIsTouched = false; + public bool u3dTrigger0RightIsTouched = false; + public bool u3dTrigger1LeftIsTouched = false; + public bool u3dTrigger1RightIsTouched = false; + public bool u3dTrigger2LeftIsTouched = false; + public bool u3dTrigger2RightIsTouched = false; + public bool u3dTrigger3LeftIsTouched = false; + public bool u3dTrigger3RightIsTouched = false; + public bool u3dTrigger4LeftIsTouched = false; + public bool u3dTrigger4RightIsTouched = false; + + void Awake() + { + if(XciHandler.instance != null) + { + GameObject.Destroy(this.gameObject); + } + + XciHandler.instance = this; + + // Lives for the life of the game + DontDestroyOnLoad(this.gameObject); + } + + void OnEnable() + { + SceneManager.sceneLoaded += OnSceneFinishedLoading; + } + + void OnDisable() + { + SceneManager.sceneLoaded -= OnSceneFinishedLoading; + } + + // Callback made to replace obsolete method OnLevelWasLoaded(int) + void OnSceneFinishedLoading(Scene currentScene, LoadSceneMode mode) + { + this.ResetTriggerTouches(); + } + + void OnApplicationFocus(bool isWindowInFocusNow) + { + if(!isWindowInFocusNow) + { + this.ResetTriggerTouches(); + } + } + + private void ResetTriggerTouches() + { + this.u3dTrigger0LeftIsTouched = false; + this.u3dTrigger0RightIsTouched = false; + this.u3dTrigger1LeftIsTouched = false; + this.u3dTrigger1RightIsTouched = false; + this.u3dTrigger2LeftIsTouched = false; + this.u3dTrigger2RightIsTouched = false; + this.u3dTrigger3LeftIsTouched = false; + this.u3dTrigger3RightIsTouched = false; + this.u3dTrigger4LeftIsTouched = false; + this.u3dTrigger4RightIsTouched = false; + } + + public static XciHandler Instance + { + get + { + if(XciHandler.instance == null) + { + GameObject xciHandleObj = new GameObject("XboxCtrlrInput Handler Object"); + xciHandleObj.AddComponent(); + } + + return XciHandler.instance; + } + } + } // end of XciHandler + } // end of XCI + + public static class XboxButtonExtensions + { + public static bool IsDPad(this XboxButton button) + { + return (button == XboxButton.DPadUp || + button == XboxButton.DPadDown || + button == XboxButton.DPadLeft || + button == XboxButton.DPadRight); + } + + public static XboxDPad ToDPad(this XboxButton button) + { + if (button == XboxButton.DPadUp) + return XboxDPad.Up; + if (button == XboxButton.DPadDown) + return XboxDPad.Down; + if (button == XboxButton.DPadLeft) + return XboxDPad.Left; + if (button == XboxButton.DPadRight) + return XboxDPad.Right; + return default(XboxDPad); + } + + + } + + +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta new file mode 100644 index 0000000..2d0e145 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ada75d1768d6fad4eb285bd538323380 +timeCreated: 1472582191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs new file mode 100644 index 0000000..1106813 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using XboxCtrlrInput; + +namespace PlayerInput +{ + public class XboxControllerInputSource : InputSource where TTarget : MonoBehaviour + { + private static List allControllers; + public static IEnumerable AllControllers { get { return allControllers; } } + static XboxControllerInputSource() + { + allControllers = new List() + { + XboxController.First, + XboxController.Second, + XboxController.Third, + XboxController.Fourth, + }; + } + + private Dictionary buttonMapping; + private Dictionary axisMapping; + + private XboxController controller; + public XboxController Controller { get { return controller; } } + + public XboxControllerInputSource(XboxController controller) + { + this.controller = controller; + + buttonMapping = new Dictionary() + { + { InputButton.MenuSelect, XboxButton.A }, + { InputButton.MenuCancel, XboxButton.B }, + + //{ InputButton.UseItem, XboxButton.A }, + //{ InputButton.PickA, XboxButton.LeftBumper }, + //{ InputButton.PickB, XboxButton.RightBumper }, + + //{ InputButton.AnimalSelector, XboxButton.LeftBumper }, + }; + + axisMapping = new Dictionary() + { + { InputAxis.MenuX, XboxAxis.LeftStickX }, + { InputAxis.MenuY, XboxAxis.LeftStickY }, + + { InputAxis.RakeX, XboxAxis.RightStickX }, + { InputAxis.RakeY, XboxAxis.RightStickY }, + + { InputAxis.MoveX, XboxAxis.LeftStickX }, + { InputAxis.MoveY, XboxAxis.LeftStickY }, + + //{ InputAxis.Throttle, XboxAxis.RightTrigger }, + //{ InputAxis.RevThrottle, XboxAxis.LeftTrigger }, + }; + } + + protected override void VibrateInternal(float left, float right) + { + XCI.SetVibration(controller, left, right); + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + return XCI.GetButtonDown(buttonMapping[button], controller); + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + return XCI.GetButtonUp(buttonMapping[button], controller); + } + + public override bool ButtonDown(InputButton button) + { + return XCI.GetButton(buttonMapping[button], controller); + } + + public override float Axis(InputAxis axis) + { + return XCI.GetAxis(axisMapping[axis], controller); + } + } +} diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta new file mode 100644 index 0000000..9f6859f --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ec7d070ee2898544aa46811e0e3da197 +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins.meta b/FallUnity/Assets/Plugins.meta new file mode 100644 index 0000000..b7025e8 --- /dev/null +++ b/FallUnity/Assets/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: dca2b803c244eb540bbf437959ae5f51 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll b/FallUnity/Assets/Plugins/XInputDotNetPure.dll new file mode 100644 index 0000000..d345520 --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta new file mode 100644 index 0000000..c87585b --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: a05c5d8086133f648a3dd3229d764a63 +timeCreated: 1572134134 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs new file mode 100644 index 0000000..69ee3a8 --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs @@ -0,0 +1,1969 @@ +using UnityEngine; +using UnityEngine.SceneManagement; + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN +using XInputDotNetPure; +#endif + +namespace XboxCtrlrInput +{ + + // ================= Enumerations ==================== // + + /// + /// List of enumerated identifiers for Xbox controllers. + /// + /// + /// Do NOT change enum values + /// + public enum XboxController + { + /// + /// "All" Controllers is deprecated! Use "Any" instead. + /// + [System.Obsolete("Instead use XboxController.Any")] + All = 0, + + Any = 0, + + First = 1, + Second = 2, + Third = 3, + Fourth = 4 + } + + /// + /// List of enumerated identifiers for Xbox buttons. + /// + public enum XboxButton + { + A, + B, + X, + Y, + Start, + Back, + LeftStick, + RightStick, + LeftBumper, + RightBumper, + DPadUp, + DPadDown, + DPadLeft, + DPadRight + } + + /// + /// List of enumerated identifiers for Xbox D-Pad directions. + /// + public enum XboxDPad + { + Up, + Down, + Left, + Right + } + + /// + /// List of enumerated identifiers for Xbox axis. + /// + public enum XboxAxis + { + LeftStickX, + LeftStickY, + RightStickX, + RightStickY, + LeftTrigger, + RightTrigger + } + + // ================ Classes =================== // + + public static class XCI + { + // ------------ Public Methods --------------- // + + public static bool SetVibration(XboxController controller, float left, float right) + { + + int controllerNumber = (int)controller; + + if (OnWindowsNative()) + { + GamePad.SetVibration((PlayerIndex)(controllerNumber - 1), left, right); + } + else + { + + } + + return false; + } + + // >>> For Buttons <<< // + + /// + /// Returns true if the specified button is held down by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButton(XboxButton button) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true if the specified button is held down by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButton(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButton(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonDown(XboxButton button) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonDown(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonDown(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonUp(XboxButton button) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonUp(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonUp(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + // >>> For D-Pad <<< // + + /// + /// Returns true if the specified D-Pad direction is pressed down by any controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + public static bool GetDPad(XboxDPad padDirection) + { + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, 0); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + /// + /// Returns true if the specified D-Pad direction is pressed down by a specified controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + /// + /// An identifier for the specific controller on which to test the D-Pad. + /// + public static bool GetDPad(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPad(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, controllerNumber); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadUp(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadUp(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadUp(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadDown(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadDown(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadDown(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // >>> For Axis <<< // + + /// + /// Returns the analog number of the specified axis from any controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxis(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxis(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxis(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from any controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxisRaw(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxisRaw(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxisRaw(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + // >>> Other important functions <<< // + + /// + /// Returns the number of Xbox controllers plugged to the computer. + /// + public static int GetNumPluggedCtrlrs() + { + int r = 0; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!xiNumOfCtrlrsQueried || !XInputStillInCurrFrame()) + { + xiNumOfCtrlrsQueried = true; + XInputUpdateAllStates(); + } + + for(int i = 0; i < 4; i++) + { + if(xInputCtrlrs[i].IsConnected) + { + r++; + } + } + #endif + } + + else + { + string[] ctrlrNames = Input.GetJoystickNames(); + for(int i = 0; i < ctrlrNames.Length; i++) + { + if(ctrlrNames[i].Contains("Xbox") || ctrlrNames[i].Contains("XBOX") || ctrlrNames[i].Contains("Microsoft")) + { + r++; + } + } + } + + return r; + } + + /// + /// DEBUG function. Log all controller names to Unity's console. + /// + public static void DEBUG_LogControllerNames() + { + string[] cNames = Input.GetJoystickNames(); + + for(int i = 0; i < cNames.Length; i++) + { + Debug.Log("Ctrlr " + i.ToString() + ": " + cNames[i]); + } + } + + + + + + // From @xoorath + /// + /// DEPRECATED: + /// Determines if the controller is plugged in the specified controllerNumber. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. An int between 1 and 4. + /// + [System.Obsolete("Instead use IsPluggedIn(XboxController)")] + public static bool IsPluggedIn(int controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + return ctrlrState.IsConnected; + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + // Based off @xoorath 's implementation + /// + /// Determines if the controller is plugged in the specified controllerNumber. + /// Passing Any will evaluate if any controller is connected. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// Passing Any will evaluate if any controller is connected. + /// + public static bool IsPluggedIn(XboxController controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + { + if (OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState; + + + // If inquiring about any controller + + // TODO: Remove condition for XboxController.All when the time comes + // Users of XCI: Feel free to remove XboxController.All if you like having no warnings + if(controllerNumber == XboxController.Any || controllerNumber == XboxController.All) + { + // Examine all controllers it see if any are connected + for(int i = 1; i <= 4; i++) + { + ctrlrState = XInputGetPaticularState(i); + if(ctrlrState.IsConnected) + { + return true; + } + } + } + + + // If specifying a specific controller + + // Note: Casting only works if XboxController enums are values 1 to 4 (First, Second, Third, Fourth) + ctrlrState = XInputGetPaticularState((int)controllerNumber); + + return ctrlrState.IsConnected; + } + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + + + //// + // ------------- Private -------------- // + //// + + // ------------ Methods --------------- // + + private static bool OnMac() + { + // All Mac mappings are based off TattieBogle Xbox Controller drivers + // http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver + // http://wiki.unity3d.com/index.php?title=Xbox360Controller + return (Application.platform == RuntimePlatform.OSXEditor || + Application.platform == RuntimePlatform.OSXPlayer ); + } + + private static bool OnWindows() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnWindowsNative() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnLinux() + { + // Linux mapping based on observation of mapping from default drivers on Ubuntu 13.04 + return Application.platform == RuntimePlatform.LinuxPlayer; + } + + private static bool IsControllerWireless() + { + // 0 means for any controller + return IsControllerWireless(0); + } + + private static bool IsControllerWireless(int ctrlNum) + { + if (ctrlNum < 0 || ctrlNum > 4) return false; + + // If 0 is passed in, that assumes that only 1 controller is plugged in. + if(ctrlNum == 0) + { + return ( (string) Input.GetJoystickNames()[0]).Contains("Wireless"); + } + + return ( (string) Input.GetJoystickNames()[ctrlNum-1]).Contains("Wireless"); + } + + private static bool IsControllerNumberValid(int ctrlrNum) + { + if(ctrlrNum > 0 && ctrlrNum <= 4) + { + return true; + } + else + { + Debug.LogError("XCI.IsControllerNumberValid(): " + + "Invalid contoller number! Should be between 1 and 4."); + } + return false; + } + + private static float RefactorRange(float oldRangeValue, int ctrlrNum, XboxAxis axis) + { + // HACK: On OS X, Left and right trigger under OSX return 0.5 until touched + // Issue #16 on Github: https://github.com/JISyed/Unity-XboxCtrlrInput/issues/16 + if(XCI.OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + else if(axis == XboxAxis.RightTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + } + + // Assumes you want to take a number from -1 to 1 range + // And turn it into a number from a 0 to 1 range + return ((oldRangeValue + 1.0f) / 2.0f ); + } + + private static string DetermineButtonCode(XboxButton btn, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sKeyCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + if(OnMac()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "16"; break; + case XboxButton.B: sKeyCode = "17"; break; + case XboxButton.X: sKeyCode = "18"; break; + case XboxButton.Y: sKeyCode = "19"; break; + case XboxButton.Start: sKeyCode = "9"; break; + case XboxButton.Back: sKeyCode = "10"; break; + case XboxButton.LeftStick: sKeyCode = "11"; break; + case XboxButton.RightStick: sKeyCode = "12"; break; + case XboxButton.LeftBumper: sKeyCode = "13"; break; + case XboxButton.RightBumper: sKeyCode = "14"; break; + + default: invalidCode = true; break; + } + } + else if (OnLinux()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "9"; break; + case XboxButton.RightStick: sKeyCode = "10"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "8"; break; + case XboxButton.RightStick: sKeyCode = "9"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + + r = "joystick" + sJoyCode + " button " + sKeyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineAxisCode(XboxAxis axs, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sAxisCode = ""; + bool invalidCode = false; + + + if(OnMac()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "3"; break; + case XboxAxis.RightStickY: sAxisCode = "4"; break; + case XboxAxis.LeftTrigger: sAxisCode = "5"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else if(OnLinux()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "3"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "9"; break; + case XboxAxis.RightTrigger: sAxisCode = "10"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sAxisCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static float AdjustAxisValues(float axisValue, XboxAxis axis, int ctrlrNum) + { + float newAxisValue = axisValue; + + if(OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = -newAxisValue; + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightStickY) + { + newAxisValue = -newAxisValue; + } + } + else if(OnLinux()) + { + if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + } + + return newAxisValue; + } + + private static string DetermineDPad(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sPadCode = ""; + bool invalidCode = false; + + if(OnLinux()) + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "8"; break; + case XboxDPad.Down: sPadCode = "8"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "7"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "7"; break; + case XboxDPad.Down: sPadCode = "7"; break; + case XboxDPad.Left: sPadCode = "6"; break; + case XboxDPad.Right: sPadCode = "6"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sPadCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadMac(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "5"; break; + case XboxDPad.Down: sPadCode = "6"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "8"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadWirelessLinux(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "13"; break; + case XboxDPad.Down: sPadCode = "14"; break; + case XboxDPad.Left: sPadCode = "11"; break; + case XboxDPad.Right: sPadCode = "12"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + + // ------------- Private XInput Wrappers (for Windows Native player and editor only) -------------- // + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + + // ------------ Inner Class ------------// + + // Used to setup XInput for Windows + class XciXInputInitializer + { + // Ctor + public XciXInputInitializer() + { + // Only runs once. + // Setup XInput here... + + + // Call input states twice in order to make sure that + // the previous states and current states are the same. + // This is needed to prevent errors where GetButtonUp will trigger unexpectledly + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + } + + public void Dummy() + { + // Intentionally does nothing to prevent warnings + } + } + + + + // ------------ Members --------------- // + + // Windows variables + private static GamePadState[] xInputCtrlrs = new GamePadState[4]; + private static GamePadState[] xInputCtrlrsPrev = new GamePadState[4]; + private static int xiPrevFrameCount = -1; + private static bool xiUpdateAlreadyCalled = false; + private static bool xiNumOfCtrlrsQueried = false; + private static XciXInputInitializer xinputInitalizer = new XCI.XciXInputInitializer(); + + + + // This can be set to something different if you want + private const GamePadDeadZone WindowsDeadzoneMethod = GamePadDeadZone.Circular; + + + + // ------------ Methods --------------- // + + //>> For updating states << + + private static void XInputUpdateAllStates() + { + if(xiUpdateAlreadyCalled) return; + + for(int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex) i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + xiUpdateAlreadyCalled = true; + } + + + //>> For getting states << + private static GamePadState XInputGetSingleState() + { + return xInputCtrlrs[0]; + } + + private static GamePadState XInputGetPaticularState(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrs[0]; + + return xInputCtrlrs[ctrlNum-1]; + } + + private static GamePadState XInputGetSingleStatePrev() + { + return xInputCtrlrsPrev[0]; + } + + private static GamePadState XInputGetPaticularStatePrev(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrsPrev[0]; + + return xInputCtrlrsPrev[ctrlNum-1]; + } + + //>> For getting input << + private static ButtonState XInputGetButtonState(GamePadButtons xiButtons, XboxButton xciBtn) + { + ButtonState stateToReturn = ButtonState.Pressed; + + switch(xciBtn) + { + case XboxButton.A: stateToReturn = xiButtons.A; break; + case XboxButton.B: stateToReturn = xiButtons.B; break; + case XboxButton.X: stateToReturn = xiButtons.X; break; + case XboxButton.Y: stateToReturn = xiButtons.Y; break; + case XboxButton.Start: stateToReturn = xiButtons.Start; break; + case XboxButton.Back: stateToReturn = xiButtons.Back; break; + case XboxButton.LeftBumper: stateToReturn = xiButtons.LeftShoulder; break; + case XboxButton.RightBumper: stateToReturn = xiButtons.RightShoulder; break; + case XboxButton.LeftStick: stateToReturn = xiButtons.LeftStick; break; + case XboxButton.RightStick: stateToReturn = xiButtons.RightStick; break; + } + + return stateToReturn; + } + + private static ButtonState XInputGetDPadState(GamePadDPad xiDPad, XboxDPad xciDPad) + { + ButtonState stateToReturn = ButtonState.Released; + + switch(xciDPad) + { + case XboxDPad.Up: stateToReturn = xiDPad.Up; break; + case XboxDPad.Down: stateToReturn = xiDPad.Down; break; + case XboxDPad.Left: stateToReturn = xiDPad.Left; break; + case XboxDPad.Right: stateToReturn = xiDPad.Right; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadTriggers xiTriggers, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftTrigger: stateToReturn = xiTriggers.Left; break; + case XboxAxis.RightTrigger: stateToReturn = xiTriggers.Right; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadThumbSticks xiThumbSticks, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftStickX: stateToReturn = xiThumbSticks.Left.X; break; + case XboxAxis.LeftStickY: stateToReturn = xiThumbSticks.Left.Y; break; + case XboxAxis.RightStickX: stateToReturn = xiThumbSticks.Right.X; break; + case XboxAxis.RightStickY: stateToReturn = xiThumbSticks.Right.Y; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static bool XInputStillInCurrFrame() + { + bool r = false; + xinputInitalizer.Dummy(); // Stop warnings about not using the initilaizer + + // Get the current frame + int currFrame = Time.frameCount; + + // Are we still in the current frame? + if(xiPrevFrameCount == currFrame) + { + r = true; + } + else + { + r = false; + xiUpdateAlreadyCalled = false; + } + + // Assign the previous frame count regardless of whether it's the same or not. + xiPrevFrameCount = currFrame; + + return r; + } + + + #endif + + // END of Windows only subsystem ========================================== + + + + // -------------------------- Handler Script ------------------- + + // Secret Private Script that does some maintainace work for XCI states. User should not use this script at all. + private class XciHandler : MonoBehaviour + { + private static XciHandler instance = null; + + public bool u3dTrigger0LeftIsTouched = false; + public bool u3dTrigger0RightIsTouched = false; + public bool u3dTrigger1LeftIsTouched = false; + public bool u3dTrigger1RightIsTouched = false; + public bool u3dTrigger2LeftIsTouched = false; + public bool u3dTrigger2RightIsTouched = false; + public bool u3dTrigger3LeftIsTouched = false; + public bool u3dTrigger3RightIsTouched = false; + public bool u3dTrigger4LeftIsTouched = false; + public bool u3dTrigger4RightIsTouched = false; + + void Awake() + { + if(XciHandler.instance != null) + { + GameObject.Destroy(this.gameObject); + } + + XciHandler.instance = this; + + // Lives for the life of the game + DontDestroyOnLoad(this.gameObject); + } + + void OnEnable() + { + SceneManager.sceneLoaded += OnSceneFinishedLoading; + } + + void OnDisable() + { + SceneManager.sceneLoaded -= OnSceneFinishedLoading; + } + + // Callback made to replace obsolete method OnLevelWasLoaded(int) + void OnSceneFinishedLoading(Scene currentScene, LoadSceneMode mode) + { + this.ResetTriggerTouches(); + } + + void OnApplicationFocus(bool isWindowInFocusNow) + { + if(!isWindowInFocusNow) + { + this.ResetTriggerTouches(); + } + } + + private void ResetTriggerTouches() + { + this.u3dTrigger0LeftIsTouched = false; + this.u3dTrigger0RightIsTouched = false; + this.u3dTrigger1LeftIsTouched = false; + this.u3dTrigger1RightIsTouched = false; + this.u3dTrigger2LeftIsTouched = false; + this.u3dTrigger2RightIsTouched = false; + this.u3dTrigger3LeftIsTouched = false; + this.u3dTrigger3RightIsTouched = false; + this.u3dTrigger4LeftIsTouched = false; + this.u3dTrigger4RightIsTouched = false; + } + + public static XciHandler Instance + { + get + { + if(XciHandler.instance == null) + { + GameObject xciHandleObj = new GameObject("XboxCtrlrInput Handler Object"); + xciHandleObj.AddComponent(); + } + + return XciHandler.instance; + } + } + } // end of XciHandler + } // end of XCI + + public static class XboxButtonExtensions + { + public static bool IsDPad(this XboxButton button) + { + return (button == XboxButton.DPadUp || + button == XboxButton.DPadDown || + button == XboxButton.DPadLeft || + button == XboxButton.DPadRight); + } + + public static XboxDPad ToDPad(this XboxButton button) + { + if (button == XboxButton.DPadUp) + return XboxDPad.Up; + if (button == XboxButton.DPadDown) + return XboxDPad.Down; + if (button == XboxButton.DPadLeft) + return XboxDPad.Left; + if (button == XboxButton.DPadRight) + return XboxDPad.Right; + return default(XboxDPad); + } + + + } + + +} diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta new file mode 100644 index 0000000..25d63aa --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 928025f6ea24748418044e4479b4c446 +timeCreated: 1572134135 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta new file mode 100644 index 0000000..2d0e145 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ada75d1768d6fad4eb285bd538323380 +timeCreated: 1472582191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs new file mode 100644 index 0000000..1106813 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using XboxCtrlrInput; + +namespace PlayerInput +{ + public class XboxControllerInputSource : InputSource where TTarget : MonoBehaviour + { + private static List allControllers; + public static IEnumerable AllControllers { get { return allControllers; } } + static XboxControllerInputSource() + { + allControllers = new List() + { + XboxController.First, + XboxController.Second, + XboxController.Third, + XboxController.Fourth, + }; + } + + private Dictionary buttonMapping; + private Dictionary axisMapping; + + private XboxController controller; + public XboxController Controller { get { return controller; } } + + public XboxControllerInputSource(XboxController controller) + { + this.controller = controller; + + buttonMapping = new Dictionary() + { + { InputButton.MenuSelect, XboxButton.A }, + { InputButton.MenuCancel, XboxButton.B }, + + //{ InputButton.UseItem, XboxButton.A }, + //{ InputButton.PickA, XboxButton.LeftBumper }, + //{ InputButton.PickB, XboxButton.RightBumper }, + + //{ InputButton.AnimalSelector, XboxButton.LeftBumper }, + }; + + axisMapping = new Dictionary() + { + { InputAxis.MenuX, XboxAxis.LeftStickX }, + { InputAxis.MenuY, XboxAxis.LeftStickY }, + + { InputAxis.RakeX, XboxAxis.RightStickX }, + { InputAxis.RakeY, XboxAxis.RightStickY }, + + { InputAxis.MoveX, XboxAxis.LeftStickX }, + { InputAxis.MoveY, XboxAxis.LeftStickY }, + + //{ InputAxis.Throttle, XboxAxis.RightTrigger }, + //{ InputAxis.RevThrottle, XboxAxis.LeftTrigger }, + }; + } + + protected override void VibrateInternal(float left, float right) + { + XCI.SetVibration(controller, left, right); + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + return XCI.GetButtonDown(buttonMapping[button], controller); + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + return XCI.GetButtonUp(buttonMapping[button], controller); + } + + public override bool ButtonDown(InputButton button) + { + return XCI.GetButton(buttonMapping[button], controller); + } + + public override float Axis(InputAxis axis) + { + return XCI.GetAxis(axisMapping[axis], controller); + } + } +} diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta new file mode 100644 index 0000000..9f6859f --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ec7d070ee2898544aa46811e0e3da197 +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins.meta b/FallUnity/Assets/Plugins.meta new file mode 100644 index 0000000..b7025e8 --- /dev/null +++ b/FallUnity/Assets/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: dca2b803c244eb540bbf437959ae5f51 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll b/FallUnity/Assets/Plugins/XInputDotNetPure.dll new file mode 100644 index 0000000..d345520 --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta new file mode 100644 index 0000000..c87585b --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: a05c5d8086133f648a3dd3229d764a63 +timeCreated: 1572134134 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs new file mode 100644 index 0000000..69ee3a8 --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs @@ -0,0 +1,1969 @@ +using UnityEngine; +using UnityEngine.SceneManagement; + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN +using XInputDotNetPure; +#endif + +namespace XboxCtrlrInput +{ + + // ================= Enumerations ==================== // + + /// + /// List of enumerated identifiers for Xbox controllers. + /// + /// + /// Do NOT change enum values + /// + public enum XboxController + { + /// + /// "All" Controllers is deprecated! Use "Any" instead. + /// + [System.Obsolete("Instead use XboxController.Any")] + All = 0, + + Any = 0, + + First = 1, + Second = 2, + Third = 3, + Fourth = 4 + } + + /// + /// List of enumerated identifiers for Xbox buttons. + /// + public enum XboxButton + { + A, + B, + X, + Y, + Start, + Back, + LeftStick, + RightStick, + LeftBumper, + RightBumper, + DPadUp, + DPadDown, + DPadLeft, + DPadRight + } + + /// + /// List of enumerated identifiers for Xbox D-Pad directions. + /// + public enum XboxDPad + { + Up, + Down, + Left, + Right + } + + /// + /// List of enumerated identifiers for Xbox axis. + /// + public enum XboxAxis + { + LeftStickX, + LeftStickY, + RightStickX, + RightStickY, + LeftTrigger, + RightTrigger + } + + // ================ Classes =================== // + + public static class XCI + { + // ------------ Public Methods --------------- // + + public static bool SetVibration(XboxController controller, float left, float right) + { + + int controllerNumber = (int)controller; + + if (OnWindowsNative()) + { + GamePad.SetVibration((PlayerIndex)(controllerNumber - 1), left, right); + } + else + { + + } + + return false; + } + + // >>> For Buttons <<< // + + /// + /// Returns true if the specified button is held down by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButton(XboxButton button) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true if the specified button is held down by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButton(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButton(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonDown(XboxButton button) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonDown(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonDown(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonUp(XboxButton button) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonUp(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonUp(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + // >>> For D-Pad <<< // + + /// + /// Returns true if the specified D-Pad direction is pressed down by any controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + public static bool GetDPad(XboxDPad padDirection) + { + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, 0); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + /// + /// Returns true if the specified D-Pad direction is pressed down by a specified controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + /// + /// An identifier for the specific controller on which to test the D-Pad. + /// + public static bool GetDPad(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPad(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, controllerNumber); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadUp(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadUp(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadUp(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadDown(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadDown(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadDown(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // >>> For Axis <<< // + + /// + /// Returns the analog number of the specified axis from any controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxis(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxis(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxis(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from any controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxisRaw(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxisRaw(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxisRaw(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + // >>> Other important functions <<< // + + /// + /// Returns the number of Xbox controllers plugged to the computer. + /// + public static int GetNumPluggedCtrlrs() + { + int r = 0; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!xiNumOfCtrlrsQueried || !XInputStillInCurrFrame()) + { + xiNumOfCtrlrsQueried = true; + XInputUpdateAllStates(); + } + + for(int i = 0; i < 4; i++) + { + if(xInputCtrlrs[i].IsConnected) + { + r++; + } + } + #endif + } + + else + { + string[] ctrlrNames = Input.GetJoystickNames(); + for(int i = 0; i < ctrlrNames.Length; i++) + { + if(ctrlrNames[i].Contains("Xbox") || ctrlrNames[i].Contains("XBOX") || ctrlrNames[i].Contains("Microsoft")) + { + r++; + } + } + } + + return r; + } + + /// + /// DEBUG function. Log all controller names to Unity's console. + /// + public static void DEBUG_LogControllerNames() + { + string[] cNames = Input.GetJoystickNames(); + + for(int i = 0; i < cNames.Length; i++) + { + Debug.Log("Ctrlr " + i.ToString() + ": " + cNames[i]); + } + } + + + + + + // From @xoorath + /// + /// DEPRECATED: + /// Determines if the controller is plugged in the specified controllerNumber. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. An int between 1 and 4. + /// + [System.Obsolete("Instead use IsPluggedIn(XboxController)")] + public static bool IsPluggedIn(int controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + return ctrlrState.IsConnected; + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + // Based off @xoorath 's implementation + /// + /// Determines if the controller is plugged in the specified controllerNumber. + /// Passing Any will evaluate if any controller is connected. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// Passing Any will evaluate if any controller is connected. + /// + public static bool IsPluggedIn(XboxController controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + { + if (OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState; + + + // If inquiring about any controller + + // TODO: Remove condition for XboxController.All when the time comes + // Users of XCI: Feel free to remove XboxController.All if you like having no warnings + if(controllerNumber == XboxController.Any || controllerNumber == XboxController.All) + { + // Examine all controllers it see if any are connected + for(int i = 1; i <= 4; i++) + { + ctrlrState = XInputGetPaticularState(i); + if(ctrlrState.IsConnected) + { + return true; + } + } + } + + + // If specifying a specific controller + + // Note: Casting only works if XboxController enums are values 1 to 4 (First, Second, Third, Fourth) + ctrlrState = XInputGetPaticularState((int)controllerNumber); + + return ctrlrState.IsConnected; + } + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + + + //// + // ------------- Private -------------- // + //// + + // ------------ Methods --------------- // + + private static bool OnMac() + { + // All Mac mappings are based off TattieBogle Xbox Controller drivers + // http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver + // http://wiki.unity3d.com/index.php?title=Xbox360Controller + return (Application.platform == RuntimePlatform.OSXEditor || + Application.platform == RuntimePlatform.OSXPlayer ); + } + + private static bool OnWindows() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnWindowsNative() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnLinux() + { + // Linux mapping based on observation of mapping from default drivers on Ubuntu 13.04 + return Application.platform == RuntimePlatform.LinuxPlayer; + } + + private static bool IsControllerWireless() + { + // 0 means for any controller + return IsControllerWireless(0); + } + + private static bool IsControllerWireless(int ctrlNum) + { + if (ctrlNum < 0 || ctrlNum > 4) return false; + + // If 0 is passed in, that assumes that only 1 controller is plugged in. + if(ctrlNum == 0) + { + return ( (string) Input.GetJoystickNames()[0]).Contains("Wireless"); + } + + return ( (string) Input.GetJoystickNames()[ctrlNum-1]).Contains("Wireless"); + } + + private static bool IsControllerNumberValid(int ctrlrNum) + { + if(ctrlrNum > 0 && ctrlrNum <= 4) + { + return true; + } + else + { + Debug.LogError("XCI.IsControllerNumberValid(): " + + "Invalid contoller number! Should be between 1 and 4."); + } + return false; + } + + private static float RefactorRange(float oldRangeValue, int ctrlrNum, XboxAxis axis) + { + // HACK: On OS X, Left and right trigger under OSX return 0.5 until touched + // Issue #16 on Github: https://github.com/JISyed/Unity-XboxCtrlrInput/issues/16 + if(XCI.OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + else if(axis == XboxAxis.RightTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + } + + // Assumes you want to take a number from -1 to 1 range + // And turn it into a number from a 0 to 1 range + return ((oldRangeValue + 1.0f) / 2.0f ); + } + + private static string DetermineButtonCode(XboxButton btn, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sKeyCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + if(OnMac()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "16"; break; + case XboxButton.B: sKeyCode = "17"; break; + case XboxButton.X: sKeyCode = "18"; break; + case XboxButton.Y: sKeyCode = "19"; break; + case XboxButton.Start: sKeyCode = "9"; break; + case XboxButton.Back: sKeyCode = "10"; break; + case XboxButton.LeftStick: sKeyCode = "11"; break; + case XboxButton.RightStick: sKeyCode = "12"; break; + case XboxButton.LeftBumper: sKeyCode = "13"; break; + case XboxButton.RightBumper: sKeyCode = "14"; break; + + default: invalidCode = true; break; + } + } + else if (OnLinux()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "9"; break; + case XboxButton.RightStick: sKeyCode = "10"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "8"; break; + case XboxButton.RightStick: sKeyCode = "9"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + + r = "joystick" + sJoyCode + " button " + sKeyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineAxisCode(XboxAxis axs, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sAxisCode = ""; + bool invalidCode = false; + + + if(OnMac()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "3"; break; + case XboxAxis.RightStickY: sAxisCode = "4"; break; + case XboxAxis.LeftTrigger: sAxisCode = "5"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else if(OnLinux()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "3"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "9"; break; + case XboxAxis.RightTrigger: sAxisCode = "10"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sAxisCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static float AdjustAxisValues(float axisValue, XboxAxis axis, int ctrlrNum) + { + float newAxisValue = axisValue; + + if(OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = -newAxisValue; + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightStickY) + { + newAxisValue = -newAxisValue; + } + } + else if(OnLinux()) + { + if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + } + + return newAxisValue; + } + + private static string DetermineDPad(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sPadCode = ""; + bool invalidCode = false; + + if(OnLinux()) + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "8"; break; + case XboxDPad.Down: sPadCode = "8"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "7"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "7"; break; + case XboxDPad.Down: sPadCode = "7"; break; + case XboxDPad.Left: sPadCode = "6"; break; + case XboxDPad.Right: sPadCode = "6"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sPadCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadMac(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "5"; break; + case XboxDPad.Down: sPadCode = "6"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "8"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadWirelessLinux(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "13"; break; + case XboxDPad.Down: sPadCode = "14"; break; + case XboxDPad.Left: sPadCode = "11"; break; + case XboxDPad.Right: sPadCode = "12"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + + // ------------- Private XInput Wrappers (for Windows Native player and editor only) -------------- // + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + + // ------------ Inner Class ------------// + + // Used to setup XInput for Windows + class XciXInputInitializer + { + // Ctor + public XciXInputInitializer() + { + // Only runs once. + // Setup XInput here... + + + // Call input states twice in order to make sure that + // the previous states and current states are the same. + // This is needed to prevent errors where GetButtonUp will trigger unexpectledly + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + } + + public void Dummy() + { + // Intentionally does nothing to prevent warnings + } + } + + + + // ------------ Members --------------- // + + // Windows variables + private static GamePadState[] xInputCtrlrs = new GamePadState[4]; + private static GamePadState[] xInputCtrlrsPrev = new GamePadState[4]; + private static int xiPrevFrameCount = -1; + private static bool xiUpdateAlreadyCalled = false; + private static bool xiNumOfCtrlrsQueried = false; + private static XciXInputInitializer xinputInitalizer = new XCI.XciXInputInitializer(); + + + + // This can be set to something different if you want + private const GamePadDeadZone WindowsDeadzoneMethod = GamePadDeadZone.Circular; + + + + // ------------ Methods --------------- // + + //>> For updating states << + + private static void XInputUpdateAllStates() + { + if(xiUpdateAlreadyCalled) return; + + for(int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex) i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + xiUpdateAlreadyCalled = true; + } + + + //>> For getting states << + private static GamePadState XInputGetSingleState() + { + return xInputCtrlrs[0]; + } + + private static GamePadState XInputGetPaticularState(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrs[0]; + + return xInputCtrlrs[ctrlNum-1]; + } + + private static GamePadState XInputGetSingleStatePrev() + { + return xInputCtrlrsPrev[0]; + } + + private static GamePadState XInputGetPaticularStatePrev(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrsPrev[0]; + + return xInputCtrlrsPrev[ctrlNum-1]; + } + + //>> For getting input << + private static ButtonState XInputGetButtonState(GamePadButtons xiButtons, XboxButton xciBtn) + { + ButtonState stateToReturn = ButtonState.Pressed; + + switch(xciBtn) + { + case XboxButton.A: stateToReturn = xiButtons.A; break; + case XboxButton.B: stateToReturn = xiButtons.B; break; + case XboxButton.X: stateToReturn = xiButtons.X; break; + case XboxButton.Y: stateToReturn = xiButtons.Y; break; + case XboxButton.Start: stateToReturn = xiButtons.Start; break; + case XboxButton.Back: stateToReturn = xiButtons.Back; break; + case XboxButton.LeftBumper: stateToReturn = xiButtons.LeftShoulder; break; + case XboxButton.RightBumper: stateToReturn = xiButtons.RightShoulder; break; + case XboxButton.LeftStick: stateToReturn = xiButtons.LeftStick; break; + case XboxButton.RightStick: stateToReturn = xiButtons.RightStick; break; + } + + return stateToReturn; + } + + private static ButtonState XInputGetDPadState(GamePadDPad xiDPad, XboxDPad xciDPad) + { + ButtonState stateToReturn = ButtonState.Released; + + switch(xciDPad) + { + case XboxDPad.Up: stateToReturn = xiDPad.Up; break; + case XboxDPad.Down: stateToReturn = xiDPad.Down; break; + case XboxDPad.Left: stateToReturn = xiDPad.Left; break; + case XboxDPad.Right: stateToReturn = xiDPad.Right; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadTriggers xiTriggers, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftTrigger: stateToReturn = xiTriggers.Left; break; + case XboxAxis.RightTrigger: stateToReturn = xiTriggers.Right; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadThumbSticks xiThumbSticks, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftStickX: stateToReturn = xiThumbSticks.Left.X; break; + case XboxAxis.LeftStickY: stateToReturn = xiThumbSticks.Left.Y; break; + case XboxAxis.RightStickX: stateToReturn = xiThumbSticks.Right.X; break; + case XboxAxis.RightStickY: stateToReturn = xiThumbSticks.Right.Y; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static bool XInputStillInCurrFrame() + { + bool r = false; + xinputInitalizer.Dummy(); // Stop warnings about not using the initilaizer + + // Get the current frame + int currFrame = Time.frameCount; + + // Are we still in the current frame? + if(xiPrevFrameCount == currFrame) + { + r = true; + } + else + { + r = false; + xiUpdateAlreadyCalled = false; + } + + // Assign the previous frame count regardless of whether it's the same or not. + xiPrevFrameCount = currFrame; + + return r; + } + + + #endif + + // END of Windows only subsystem ========================================== + + + + // -------------------------- Handler Script ------------------- + + // Secret Private Script that does some maintainace work for XCI states. User should not use this script at all. + private class XciHandler : MonoBehaviour + { + private static XciHandler instance = null; + + public bool u3dTrigger0LeftIsTouched = false; + public bool u3dTrigger0RightIsTouched = false; + public bool u3dTrigger1LeftIsTouched = false; + public bool u3dTrigger1RightIsTouched = false; + public bool u3dTrigger2LeftIsTouched = false; + public bool u3dTrigger2RightIsTouched = false; + public bool u3dTrigger3LeftIsTouched = false; + public bool u3dTrigger3RightIsTouched = false; + public bool u3dTrigger4LeftIsTouched = false; + public bool u3dTrigger4RightIsTouched = false; + + void Awake() + { + if(XciHandler.instance != null) + { + GameObject.Destroy(this.gameObject); + } + + XciHandler.instance = this; + + // Lives for the life of the game + DontDestroyOnLoad(this.gameObject); + } + + void OnEnable() + { + SceneManager.sceneLoaded += OnSceneFinishedLoading; + } + + void OnDisable() + { + SceneManager.sceneLoaded -= OnSceneFinishedLoading; + } + + // Callback made to replace obsolete method OnLevelWasLoaded(int) + void OnSceneFinishedLoading(Scene currentScene, LoadSceneMode mode) + { + this.ResetTriggerTouches(); + } + + void OnApplicationFocus(bool isWindowInFocusNow) + { + if(!isWindowInFocusNow) + { + this.ResetTriggerTouches(); + } + } + + private void ResetTriggerTouches() + { + this.u3dTrigger0LeftIsTouched = false; + this.u3dTrigger0RightIsTouched = false; + this.u3dTrigger1LeftIsTouched = false; + this.u3dTrigger1RightIsTouched = false; + this.u3dTrigger2LeftIsTouched = false; + this.u3dTrigger2RightIsTouched = false; + this.u3dTrigger3LeftIsTouched = false; + this.u3dTrigger3RightIsTouched = false; + this.u3dTrigger4LeftIsTouched = false; + this.u3dTrigger4RightIsTouched = false; + } + + public static XciHandler Instance + { + get + { + if(XciHandler.instance == null) + { + GameObject xciHandleObj = new GameObject("XboxCtrlrInput Handler Object"); + xciHandleObj.AddComponent(); + } + + return XciHandler.instance; + } + } + } // end of XciHandler + } // end of XCI + + public static class XboxButtonExtensions + { + public static bool IsDPad(this XboxButton button) + { + return (button == XboxButton.DPadUp || + button == XboxButton.DPadDown || + button == XboxButton.DPadLeft || + button == XboxButton.DPadRight); + } + + public static XboxDPad ToDPad(this XboxButton button) + { + if (button == XboxButton.DPadUp) + return XboxDPad.Up; + if (button == XboxButton.DPadDown) + return XboxDPad.Down; + if (button == XboxButton.DPadLeft) + return XboxDPad.Left; + if (button == XboxButton.DPadRight) + return XboxDPad.Right; + return default(XboxDPad); + } + + + } + + +} diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta new file mode 100644 index 0000000..25d63aa --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 928025f6ea24748418044e4479b4c446 +timeCreated: 1572134135 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64.meta b/FallUnity/Assets/Plugins/x86_64.meta new file mode 100644 index 0000000..fb502ad --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9cd457a246db3a2458768c6d00ed39e6 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta new file mode 100644 index 0000000..2d0e145 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ada75d1768d6fad4eb285bd538323380 +timeCreated: 1472582191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs new file mode 100644 index 0000000..1106813 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using XboxCtrlrInput; + +namespace PlayerInput +{ + public class XboxControllerInputSource : InputSource where TTarget : MonoBehaviour + { + private static List allControllers; + public static IEnumerable AllControllers { get { return allControllers; } } + static XboxControllerInputSource() + { + allControllers = new List() + { + XboxController.First, + XboxController.Second, + XboxController.Third, + XboxController.Fourth, + }; + } + + private Dictionary buttonMapping; + private Dictionary axisMapping; + + private XboxController controller; + public XboxController Controller { get { return controller; } } + + public XboxControllerInputSource(XboxController controller) + { + this.controller = controller; + + buttonMapping = new Dictionary() + { + { InputButton.MenuSelect, XboxButton.A }, + { InputButton.MenuCancel, XboxButton.B }, + + //{ InputButton.UseItem, XboxButton.A }, + //{ InputButton.PickA, XboxButton.LeftBumper }, + //{ InputButton.PickB, XboxButton.RightBumper }, + + //{ InputButton.AnimalSelector, XboxButton.LeftBumper }, + }; + + axisMapping = new Dictionary() + { + { InputAxis.MenuX, XboxAxis.LeftStickX }, + { InputAxis.MenuY, XboxAxis.LeftStickY }, + + { InputAxis.RakeX, XboxAxis.RightStickX }, + { InputAxis.RakeY, XboxAxis.RightStickY }, + + { InputAxis.MoveX, XboxAxis.LeftStickX }, + { InputAxis.MoveY, XboxAxis.LeftStickY }, + + //{ InputAxis.Throttle, XboxAxis.RightTrigger }, + //{ InputAxis.RevThrottle, XboxAxis.LeftTrigger }, + }; + } + + protected override void VibrateInternal(float left, float right) + { + XCI.SetVibration(controller, left, right); + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + return XCI.GetButtonDown(buttonMapping[button], controller); + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + return XCI.GetButtonUp(buttonMapping[button], controller); + } + + public override bool ButtonDown(InputButton button) + { + return XCI.GetButton(buttonMapping[button], controller); + } + + public override float Axis(InputAxis axis) + { + return XCI.GetAxis(axisMapping[axis], controller); + } + } +} diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta new file mode 100644 index 0000000..9f6859f --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ec7d070ee2898544aa46811e0e3da197 +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins.meta b/FallUnity/Assets/Plugins.meta new file mode 100644 index 0000000..b7025e8 --- /dev/null +++ b/FallUnity/Assets/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: dca2b803c244eb540bbf437959ae5f51 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll b/FallUnity/Assets/Plugins/XInputDotNetPure.dll new file mode 100644 index 0000000..d345520 --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta new file mode 100644 index 0000000..c87585b --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: a05c5d8086133f648a3dd3229d764a63 +timeCreated: 1572134134 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs new file mode 100644 index 0000000..69ee3a8 --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs @@ -0,0 +1,1969 @@ +using UnityEngine; +using UnityEngine.SceneManagement; + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN +using XInputDotNetPure; +#endif + +namespace XboxCtrlrInput +{ + + // ================= Enumerations ==================== // + + /// + /// List of enumerated identifiers for Xbox controllers. + /// + /// + /// Do NOT change enum values + /// + public enum XboxController + { + /// + /// "All" Controllers is deprecated! Use "Any" instead. + /// + [System.Obsolete("Instead use XboxController.Any")] + All = 0, + + Any = 0, + + First = 1, + Second = 2, + Third = 3, + Fourth = 4 + } + + /// + /// List of enumerated identifiers for Xbox buttons. + /// + public enum XboxButton + { + A, + B, + X, + Y, + Start, + Back, + LeftStick, + RightStick, + LeftBumper, + RightBumper, + DPadUp, + DPadDown, + DPadLeft, + DPadRight + } + + /// + /// List of enumerated identifiers for Xbox D-Pad directions. + /// + public enum XboxDPad + { + Up, + Down, + Left, + Right + } + + /// + /// List of enumerated identifiers for Xbox axis. + /// + public enum XboxAxis + { + LeftStickX, + LeftStickY, + RightStickX, + RightStickY, + LeftTrigger, + RightTrigger + } + + // ================ Classes =================== // + + public static class XCI + { + // ------------ Public Methods --------------- // + + public static bool SetVibration(XboxController controller, float left, float right) + { + + int controllerNumber = (int)controller; + + if (OnWindowsNative()) + { + GamePad.SetVibration((PlayerIndex)(controllerNumber - 1), left, right); + } + else + { + + } + + return false; + } + + // >>> For Buttons <<< // + + /// + /// Returns true if the specified button is held down by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButton(XboxButton button) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true if the specified button is held down by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButton(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButton(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonDown(XboxButton button) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonDown(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonDown(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonUp(XboxButton button) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonUp(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonUp(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + // >>> For D-Pad <<< // + + /// + /// Returns true if the specified D-Pad direction is pressed down by any controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + public static bool GetDPad(XboxDPad padDirection) + { + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, 0); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + /// + /// Returns true if the specified D-Pad direction is pressed down by a specified controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + /// + /// An identifier for the specific controller on which to test the D-Pad. + /// + public static bool GetDPad(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPad(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, controllerNumber); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadUp(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadUp(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadUp(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadDown(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadDown(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadDown(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // >>> For Axis <<< // + + /// + /// Returns the analog number of the specified axis from any controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxis(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxis(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxis(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from any controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxisRaw(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxisRaw(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxisRaw(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + // >>> Other important functions <<< // + + /// + /// Returns the number of Xbox controllers plugged to the computer. + /// + public static int GetNumPluggedCtrlrs() + { + int r = 0; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!xiNumOfCtrlrsQueried || !XInputStillInCurrFrame()) + { + xiNumOfCtrlrsQueried = true; + XInputUpdateAllStates(); + } + + for(int i = 0; i < 4; i++) + { + if(xInputCtrlrs[i].IsConnected) + { + r++; + } + } + #endif + } + + else + { + string[] ctrlrNames = Input.GetJoystickNames(); + for(int i = 0; i < ctrlrNames.Length; i++) + { + if(ctrlrNames[i].Contains("Xbox") || ctrlrNames[i].Contains("XBOX") || ctrlrNames[i].Contains("Microsoft")) + { + r++; + } + } + } + + return r; + } + + /// + /// DEBUG function. Log all controller names to Unity's console. + /// + public static void DEBUG_LogControllerNames() + { + string[] cNames = Input.GetJoystickNames(); + + for(int i = 0; i < cNames.Length; i++) + { + Debug.Log("Ctrlr " + i.ToString() + ": " + cNames[i]); + } + } + + + + + + // From @xoorath + /// + /// DEPRECATED: + /// Determines if the controller is plugged in the specified controllerNumber. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. An int between 1 and 4. + /// + [System.Obsolete("Instead use IsPluggedIn(XboxController)")] + public static bool IsPluggedIn(int controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + return ctrlrState.IsConnected; + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + // Based off @xoorath 's implementation + /// + /// Determines if the controller is plugged in the specified controllerNumber. + /// Passing Any will evaluate if any controller is connected. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// Passing Any will evaluate if any controller is connected. + /// + public static bool IsPluggedIn(XboxController controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + { + if (OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState; + + + // If inquiring about any controller + + // TODO: Remove condition for XboxController.All when the time comes + // Users of XCI: Feel free to remove XboxController.All if you like having no warnings + if(controllerNumber == XboxController.Any || controllerNumber == XboxController.All) + { + // Examine all controllers it see if any are connected + for(int i = 1; i <= 4; i++) + { + ctrlrState = XInputGetPaticularState(i); + if(ctrlrState.IsConnected) + { + return true; + } + } + } + + + // If specifying a specific controller + + // Note: Casting only works if XboxController enums are values 1 to 4 (First, Second, Third, Fourth) + ctrlrState = XInputGetPaticularState((int)controllerNumber); + + return ctrlrState.IsConnected; + } + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + + + //// + // ------------- Private -------------- // + //// + + // ------------ Methods --------------- // + + private static bool OnMac() + { + // All Mac mappings are based off TattieBogle Xbox Controller drivers + // http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver + // http://wiki.unity3d.com/index.php?title=Xbox360Controller + return (Application.platform == RuntimePlatform.OSXEditor || + Application.platform == RuntimePlatform.OSXPlayer ); + } + + private static bool OnWindows() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnWindowsNative() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnLinux() + { + // Linux mapping based on observation of mapping from default drivers on Ubuntu 13.04 + return Application.platform == RuntimePlatform.LinuxPlayer; + } + + private static bool IsControllerWireless() + { + // 0 means for any controller + return IsControllerWireless(0); + } + + private static bool IsControllerWireless(int ctrlNum) + { + if (ctrlNum < 0 || ctrlNum > 4) return false; + + // If 0 is passed in, that assumes that only 1 controller is plugged in. + if(ctrlNum == 0) + { + return ( (string) Input.GetJoystickNames()[0]).Contains("Wireless"); + } + + return ( (string) Input.GetJoystickNames()[ctrlNum-1]).Contains("Wireless"); + } + + private static bool IsControllerNumberValid(int ctrlrNum) + { + if(ctrlrNum > 0 && ctrlrNum <= 4) + { + return true; + } + else + { + Debug.LogError("XCI.IsControllerNumberValid(): " + + "Invalid contoller number! Should be between 1 and 4."); + } + return false; + } + + private static float RefactorRange(float oldRangeValue, int ctrlrNum, XboxAxis axis) + { + // HACK: On OS X, Left and right trigger under OSX return 0.5 until touched + // Issue #16 on Github: https://github.com/JISyed/Unity-XboxCtrlrInput/issues/16 + if(XCI.OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + else if(axis == XboxAxis.RightTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + } + + // Assumes you want to take a number from -1 to 1 range + // And turn it into a number from a 0 to 1 range + return ((oldRangeValue + 1.0f) / 2.0f ); + } + + private static string DetermineButtonCode(XboxButton btn, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sKeyCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + if(OnMac()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "16"; break; + case XboxButton.B: sKeyCode = "17"; break; + case XboxButton.X: sKeyCode = "18"; break; + case XboxButton.Y: sKeyCode = "19"; break; + case XboxButton.Start: sKeyCode = "9"; break; + case XboxButton.Back: sKeyCode = "10"; break; + case XboxButton.LeftStick: sKeyCode = "11"; break; + case XboxButton.RightStick: sKeyCode = "12"; break; + case XboxButton.LeftBumper: sKeyCode = "13"; break; + case XboxButton.RightBumper: sKeyCode = "14"; break; + + default: invalidCode = true; break; + } + } + else if (OnLinux()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "9"; break; + case XboxButton.RightStick: sKeyCode = "10"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "8"; break; + case XboxButton.RightStick: sKeyCode = "9"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + + r = "joystick" + sJoyCode + " button " + sKeyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineAxisCode(XboxAxis axs, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sAxisCode = ""; + bool invalidCode = false; + + + if(OnMac()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "3"; break; + case XboxAxis.RightStickY: sAxisCode = "4"; break; + case XboxAxis.LeftTrigger: sAxisCode = "5"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else if(OnLinux()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "3"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "9"; break; + case XboxAxis.RightTrigger: sAxisCode = "10"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sAxisCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static float AdjustAxisValues(float axisValue, XboxAxis axis, int ctrlrNum) + { + float newAxisValue = axisValue; + + if(OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = -newAxisValue; + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightStickY) + { + newAxisValue = -newAxisValue; + } + } + else if(OnLinux()) + { + if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + } + + return newAxisValue; + } + + private static string DetermineDPad(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sPadCode = ""; + bool invalidCode = false; + + if(OnLinux()) + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "8"; break; + case XboxDPad.Down: sPadCode = "8"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "7"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "7"; break; + case XboxDPad.Down: sPadCode = "7"; break; + case XboxDPad.Left: sPadCode = "6"; break; + case XboxDPad.Right: sPadCode = "6"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sPadCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadMac(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "5"; break; + case XboxDPad.Down: sPadCode = "6"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "8"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadWirelessLinux(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "13"; break; + case XboxDPad.Down: sPadCode = "14"; break; + case XboxDPad.Left: sPadCode = "11"; break; + case XboxDPad.Right: sPadCode = "12"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + + // ------------- Private XInput Wrappers (for Windows Native player and editor only) -------------- // + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + + // ------------ Inner Class ------------// + + // Used to setup XInput for Windows + class XciXInputInitializer + { + // Ctor + public XciXInputInitializer() + { + // Only runs once. + // Setup XInput here... + + + // Call input states twice in order to make sure that + // the previous states and current states are the same. + // This is needed to prevent errors where GetButtonUp will trigger unexpectledly + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + } + + public void Dummy() + { + // Intentionally does nothing to prevent warnings + } + } + + + + // ------------ Members --------------- // + + // Windows variables + private static GamePadState[] xInputCtrlrs = new GamePadState[4]; + private static GamePadState[] xInputCtrlrsPrev = new GamePadState[4]; + private static int xiPrevFrameCount = -1; + private static bool xiUpdateAlreadyCalled = false; + private static bool xiNumOfCtrlrsQueried = false; + private static XciXInputInitializer xinputInitalizer = new XCI.XciXInputInitializer(); + + + + // This can be set to something different if you want + private const GamePadDeadZone WindowsDeadzoneMethod = GamePadDeadZone.Circular; + + + + // ------------ Methods --------------- // + + //>> For updating states << + + private static void XInputUpdateAllStates() + { + if(xiUpdateAlreadyCalled) return; + + for(int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex) i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + xiUpdateAlreadyCalled = true; + } + + + //>> For getting states << + private static GamePadState XInputGetSingleState() + { + return xInputCtrlrs[0]; + } + + private static GamePadState XInputGetPaticularState(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrs[0]; + + return xInputCtrlrs[ctrlNum-1]; + } + + private static GamePadState XInputGetSingleStatePrev() + { + return xInputCtrlrsPrev[0]; + } + + private static GamePadState XInputGetPaticularStatePrev(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrsPrev[0]; + + return xInputCtrlrsPrev[ctrlNum-1]; + } + + //>> For getting input << + private static ButtonState XInputGetButtonState(GamePadButtons xiButtons, XboxButton xciBtn) + { + ButtonState stateToReturn = ButtonState.Pressed; + + switch(xciBtn) + { + case XboxButton.A: stateToReturn = xiButtons.A; break; + case XboxButton.B: stateToReturn = xiButtons.B; break; + case XboxButton.X: stateToReturn = xiButtons.X; break; + case XboxButton.Y: stateToReturn = xiButtons.Y; break; + case XboxButton.Start: stateToReturn = xiButtons.Start; break; + case XboxButton.Back: stateToReturn = xiButtons.Back; break; + case XboxButton.LeftBumper: stateToReturn = xiButtons.LeftShoulder; break; + case XboxButton.RightBumper: stateToReturn = xiButtons.RightShoulder; break; + case XboxButton.LeftStick: stateToReturn = xiButtons.LeftStick; break; + case XboxButton.RightStick: stateToReturn = xiButtons.RightStick; break; + } + + return stateToReturn; + } + + private static ButtonState XInputGetDPadState(GamePadDPad xiDPad, XboxDPad xciDPad) + { + ButtonState stateToReturn = ButtonState.Released; + + switch(xciDPad) + { + case XboxDPad.Up: stateToReturn = xiDPad.Up; break; + case XboxDPad.Down: stateToReturn = xiDPad.Down; break; + case XboxDPad.Left: stateToReturn = xiDPad.Left; break; + case XboxDPad.Right: stateToReturn = xiDPad.Right; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadTriggers xiTriggers, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftTrigger: stateToReturn = xiTriggers.Left; break; + case XboxAxis.RightTrigger: stateToReturn = xiTriggers.Right; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadThumbSticks xiThumbSticks, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftStickX: stateToReturn = xiThumbSticks.Left.X; break; + case XboxAxis.LeftStickY: stateToReturn = xiThumbSticks.Left.Y; break; + case XboxAxis.RightStickX: stateToReturn = xiThumbSticks.Right.X; break; + case XboxAxis.RightStickY: stateToReturn = xiThumbSticks.Right.Y; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static bool XInputStillInCurrFrame() + { + bool r = false; + xinputInitalizer.Dummy(); // Stop warnings about not using the initilaizer + + // Get the current frame + int currFrame = Time.frameCount; + + // Are we still in the current frame? + if(xiPrevFrameCount == currFrame) + { + r = true; + } + else + { + r = false; + xiUpdateAlreadyCalled = false; + } + + // Assign the previous frame count regardless of whether it's the same or not. + xiPrevFrameCount = currFrame; + + return r; + } + + + #endif + + // END of Windows only subsystem ========================================== + + + + // -------------------------- Handler Script ------------------- + + // Secret Private Script that does some maintainace work for XCI states. User should not use this script at all. + private class XciHandler : MonoBehaviour + { + private static XciHandler instance = null; + + public bool u3dTrigger0LeftIsTouched = false; + public bool u3dTrigger0RightIsTouched = false; + public bool u3dTrigger1LeftIsTouched = false; + public bool u3dTrigger1RightIsTouched = false; + public bool u3dTrigger2LeftIsTouched = false; + public bool u3dTrigger2RightIsTouched = false; + public bool u3dTrigger3LeftIsTouched = false; + public bool u3dTrigger3RightIsTouched = false; + public bool u3dTrigger4LeftIsTouched = false; + public bool u3dTrigger4RightIsTouched = false; + + void Awake() + { + if(XciHandler.instance != null) + { + GameObject.Destroy(this.gameObject); + } + + XciHandler.instance = this; + + // Lives for the life of the game + DontDestroyOnLoad(this.gameObject); + } + + void OnEnable() + { + SceneManager.sceneLoaded += OnSceneFinishedLoading; + } + + void OnDisable() + { + SceneManager.sceneLoaded -= OnSceneFinishedLoading; + } + + // Callback made to replace obsolete method OnLevelWasLoaded(int) + void OnSceneFinishedLoading(Scene currentScene, LoadSceneMode mode) + { + this.ResetTriggerTouches(); + } + + void OnApplicationFocus(bool isWindowInFocusNow) + { + if(!isWindowInFocusNow) + { + this.ResetTriggerTouches(); + } + } + + private void ResetTriggerTouches() + { + this.u3dTrigger0LeftIsTouched = false; + this.u3dTrigger0RightIsTouched = false; + this.u3dTrigger1LeftIsTouched = false; + this.u3dTrigger1RightIsTouched = false; + this.u3dTrigger2LeftIsTouched = false; + this.u3dTrigger2RightIsTouched = false; + this.u3dTrigger3LeftIsTouched = false; + this.u3dTrigger3RightIsTouched = false; + this.u3dTrigger4LeftIsTouched = false; + this.u3dTrigger4RightIsTouched = false; + } + + public static XciHandler Instance + { + get + { + if(XciHandler.instance == null) + { + GameObject xciHandleObj = new GameObject("XboxCtrlrInput Handler Object"); + xciHandleObj.AddComponent(); + } + + return XciHandler.instance; + } + } + } // end of XciHandler + } // end of XCI + + public static class XboxButtonExtensions + { + public static bool IsDPad(this XboxButton button) + { + return (button == XboxButton.DPadUp || + button == XboxButton.DPadDown || + button == XboxButton.DPadLeft || + button == XboxButton.DPadRight); + } + + public static XboxDPad ToDPad(this XboxButton button) + { + if (button == XboxButton.DPadUp) + return XboxDPad.Up; + if (button == XboxButton.DPadDown) + return XboxDPad.Down; + if (button == XboxButton.DPadLeft) + return XboxDPad.Left; + if (button == XboxButton.DPadRight) + return XboxDPad.Right; + return default(XboxDPad); + } + + + } + + +} diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta new file mode 100644 index 0000000..25d63aa --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 928025f6ea24748418044e4479b4c446 +timeCreated: 1572134135 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64.meta b/FallUnity/Assets/Plugins/x86_64.meta new file mode 100644 index 0000000..fb502ad --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9cd457a246db3a2458768c6d00ed39e6 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll new file mode 100644 index 0000000..8a2d764 --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll Binary files differ diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta new file mode 100644 index 0000000..2d0e145 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ada75d1768d6fad4eb285bd538323380 +timeCreated: 1472582191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs new file mode 100644 index 0000000..1106813 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using XboxCtrlrInput; + +namespace PlayerInput +{ + public class XboxControllerInputSource : InputSource where TTarget : MonoBehaviour + { + private static List allControllers; + public static IEnumerable AllControllers { get { return allControllers; } } + static XboxControllerInputSource() + { + allControllers = new List() + { + XboxController.First, + XboxController.Second, + XboxController.Third, + XboxController.Fourth, + }; + } + + private Dictionary buttonMapping; + private Dictionary axisMapping; + + private XboxController controller; + public XboxController Controller { get { return controller; } } + + public XboxControllerInputSource(XboxController controller) + { + this.controller = controller; + + buttonMapping = new Dictionary() + { + { InputButton.MenuSelect, XboxButton.A }, + { InputButton.MenuCancel, XboxButton.B }, + + //{ InputButton.UseItem, XboxButton.A }, + //{ InputButton.PickA, XboxButton.LeftBumper }, + //{ InputButton.PickB, XboxButton.RightBumper }, + + //{ InputButton.AnimalSelector, XboxButton.LeftBumper }, + }; + + axisMapping = new Dictionary() + { + { InputAxis.MenuX, XboxAxis.LeftStickX }, + { InputAxis.MenuY, XboxAxis.LeftStickY }, + + { InputAxis.RakeX, XboxAxis.RightStickX }, + { InputAxis.RakeY, XboxAxis.RightStickY }, + + { InputAxis.MoveX, XboxAxis.LeftStickX }, + { InputAxis.MoveY, XboxAxis.LeftStickY }, + + //{ InputAxis.Throttle, XboxAxis.RightTrigger }, + //{ InputAxis.RevThrottle, XboxAxis.LeftTrigger }, + }; + } + + protected override void VibrateInternal(float left, float right) + { + XCI.SetVibration(controller, left, right); + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + return XCI.GetButtonDown(buttonMapping[button], controller); + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + return XCI.GetButtonUp(buttonMapping[button], controller); + } + + public override bool ButtonDown(InputButton button) + { + return XCI.GetButton(buttonMapping[button], controller); + } + + public override float Axis(InputAxis axis) + { + return XCI.GetAxis(axisMapping[axis], controller); + } + } +} diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta new file mode 100644 index 0000000..9f6859f --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ec7d070ee2898544aa46811e0e3da197 +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins.meta b/FallUnity/Assets/Plugins.meta new file mode 100644 index 0000000..b7025e8 --- /dev/null +++ b/FallUnity/Assets/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: dca2b803c244eb540bbf437959ae5f51 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll b/FallUnity/Assets/Plugins/XInputDotNetPure.dll new file mode 100644 index 0000000..d345520 --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta new file mode 100644 index 0000000..c87585b --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: a05c5d8086133f648a3dd3229d764a63 +timeCreated: 1572134134 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs new file mode 100644 index 0000000..69ee3a8 --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs @@ -0,0 +1,1969 @@ +using UnityEngine; +using UnityEngine.SceneManagement; + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN +using XInputDotNetPure; +#endif + +namespace XboxCtrlrInput +{ + + // ================= Enumerations ==================== // + + /// + /// List of enumerated identifiers for Xbox controllers. + /// + /// + /// Do NOT change enum values + /// + public enum XboxController + { + /// + /// "All" Controllers is deprecated! Use "Any" instead. + /// + [System.Obsolete("Instead use XboxController.Any")] + All = 0, + + Any = 0, + + First = 1, + Second = 2, + Third = 3, + Fourth = 4 + } + + /// + /// List of enumerated identifiers for Xbox buttons. + /// + public enum XboxButton + { + A, + B, + X, + Y, + Start, + Back, + LeftStick, + RightStick, + LeftBumper, + RightBumper, + DPadUp, + DPadDown, + DPadLeft, + DPadRight + } + + /// + /// List of enumerated identifiers for Xbox D-Pad directions. + /// + public enum XboxDPad + { + Up, + Down, + Left, + Right + } + + /// + /// List of enumerated identifiers for Xbox axis. + /// + public enum XboxAxis + { + LeftStickX, + LeftStickY, + RightStickX, + RightStickY, + LeftTrigger, + RightTrigger + } + + // ================ Classes =================== // + + public static class XCI + { + // ------------ Public Methods --------------- // + + public static bool SetVibration(XboxController controller, float left, float right) + { + + int controllerNumber = (int)controller; + + if (OnWindowsNative()) + { + GamePad.SetVibration((PlayerIndex)(controllerNumber - 1), left, right); + } + else + { + + } + + return false; + } + + // >>> For Buttons <<< // + + /// + /// Returns true if the specified button is held down by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButton(XboxButton button) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true if the specified button is held down by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButton(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButton(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonDown(XboxButton button) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonDown(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonDown(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonUp(XboxButton button) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonUp(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonUp(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + // >>> For D-Pad <<< // + + /// + /// Returns true if the specified D-Pad direction is pressed down by any controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + public static bool GetDPad(XboxDPad padDirection) + { + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, 0); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + /// + /// Returns true if the specified D-Pad direction is pressed down by a specified controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + /// + /// An identifier for the specific controller on which to test the D-Pad. + /// + public static bool GetDPad(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPad(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, controllerNumber); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadUp(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadUp(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadUp(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadDown(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadDown(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadDown(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // >>> For Axis <<< // + + /// + /// Returns the analog number of the specified axis from any controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxis(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxis(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxis(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from any controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxisRaw(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxisRaw(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxisRaw(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + // >>> Other important functions <<< // + + /// + /// Returns the number of Xbox controllers plugged to the computer. + /// + public static int GetNumPluggedCtrlrs() + { + int r = 0; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!xiNumOfCtrlrsQueried || !XInputStillInCurrFrame()) + { + xiNumOfCtrlrsQueried = true; + XInputUpdateAllStates(); + } + + for(int i = 0; i < 4; i++) + { + if(xInputCtrlrs[i].IsConnected) + { + r++; + } + } + #endif + } + + else + { + string[] ctrlrNames = Input.GetJoystickNames(); + for(int i = 0; i < ctrlrNames.Length; i++) + { + if(ctrlrNames[i].Contains("Xbox") || ctrlrNames[i].Contains("XBOX") || ctrlrNames[i].Contains("Microsoft")) + { + r++; + } + } + } + + return r; + } + + /// + /// DEBUG function. Log all controller names to Unity's console. + /// + public static void DEBUG_LogControllerNames() + { + string[] cNames = Input.GetJoystickNames(); + + for(int i = 0; i < cNames.Length; i++) + { + Debug.Log("Ctrlr " + i.ToString() + ": " + cNames[i]); + } + } + + + + + + // From @xoorath + /// + /// DEPRECATED: + /// Determines if the controller is plugged in the specified controllerNumber. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. An int between 1 and 4. + /// + [System.Obsolete("Instead use IsPluggedIn(XboxController)")] + public static bool IsPluggedIn(int controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + return ctrlrState.IsConnected; + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + // Based off @xoorath 's implementation + /// + /// Determines if the controller is plugged in the specified controllerNumber. + /// Passing Any will evaluate if any controller is connected. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// Passing Any will evaluate if any controller is connected. + /// + public static bool IsPluggedIn(XboxController controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + { + if (OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState; + + + // If inquiring about any controller + + // TODO: Remove condition for XboxController.All when the time comes + // Users of XCI: Feel free to remove XboxController.All if you like having no warnings + if(controllerNumber == XboxController.Any || controllerNumber == XboxController.All) + { + // Examine all controllers it see if any are connected + for(int i = 1; i <= 4; i++) + { + ctrlrState = XInputGetPaticularState(i); + if(ctrlrState.IsConnected) + { + return true; + } + } + } + + + // If specifying a specific controller + + // Note: Casting only works if XboxController enums are values 1 to 4 (First, Second, Third, Fourth) + ctrlrState = XInputGetPaticularState((int)controllerNumber); + + return ctrlrState.IsConnected; + } + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + + + //// + // ------------- Private -------------- // + //// + + // ------------ Methods --------------- // + + private static bool OnMac() + { + // All Mac mappings are based off TattieBogle Xbox Controller drivers + // http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver + // http://wiki.unity3d.com/index.php?title=Xbox360Controller + return (Application.platform == RuntimePlatform.OSXEditor || + Application.platform == RuntimePlatform.OSXPlayer ); + } + + private static bool OnWindows() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnWindowsNative() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnLinux() + { + // Linux mapping based on observation of mapping from default drivers on Ubuntu 13.04 + return Application.platform == RuntimePlatform.LinuxPlayer; + } + + private static bool IsControllerWireless() + { + // 0 means for any controller + return IsControllerWireless(0); + } + + private static bool IsControllerWireless(int ctrlNum) + { + if (ctrlNum < 0 || ctrlNum > 4) return false; + + // If 0 is passed in, that assumes that only 1 controller is plugged in. + if(ctrlNum == 0) + { + return ( (string) Input.GetJoystickNames()[0]).Contains("Wireless"); + } + + return ( (string) Input.GetJoystickNames()[ctrlNum-1]).Contains("Wireless"); + } + + private static bool IsControllerNumberValid(int ctrlrNum) + { + if(ctrlrNum > 0 && ctrlrNum <= 4) + { + return true; + } + else + { + Debug.LogError("XCI.IsControllerNumberValid(): " + + "Invalid contoller number! Should be between 1 and 4."); + } + return false; + } + + private static float RefactorRange(float oldRangeValue, int ctrlrNum, XboxAxis axis) + { + // HACK: On OS X, Left and right trigger under OSX return 0.5 until touched + // Issue #16 on Github: https://github.com/JISyed/Unity-XboxCtrlrInput/issues/16 + if(XCI.OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + else if(axis == XboxAxis.RightTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + } + + // Assumes you want to take a number from -1 to 1 range + // And turn it into a number from a 0 to 1 range + return ((oldRangeValue + 1.0f) / 2.0f ); + } + + private static string DetermineButtonCode(XboxButton btn, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sKeyCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + if(OnMac()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "16"; break; + case XboxButton.B: sKeyCode = "17"; break; + case XboxButton.X: sKeyCode = "18"; break; + case XboxButton.Y: sKeyCode = "19"; break; + case XboxButton.Start: sKeyCode = "9"; break; + case XboxButton.Back: sKeyCode = "10"; break; + case XboxButton.LeftStick: sKeyCode = "11"; break; + case XboxButton.RightStick: sKeyCode = "12"; break; + case XboxButton.LeftBumper: sKeyCode = "13"; break; + case XboxButton.RightBumper: sKeyCode = "14"; break; + + default: invalidCode = true; break; + } + } + else if (OnLinux()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "9"; break; + case XboxButton.RightStick: sKeyCode = "10"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "8"; break; + case XboxButton.RightStick: sKeyCode = "9"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + + r = "joystick" + sJoyCode + " button " + sKeyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineAxisCode(XboxAxis axs, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sAxisCode = ""; + bool invalidCode = false; + + + if(OnMac()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "3"; break; + case XboxAxis.RightStickY: sAxisCode = "4"; break; + case XboxAxis.LeftTrigger: sAxisCode = "5"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else if(OnLinux()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "3"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "9"; break; + case XboxAxis.RightTrigger: sAxisCode = "10"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sAxisCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static float AdjustAxisValues(float axisValue, XboxAxis axis, int ctrlrNum) + { + float newAxisValue = axisValue; + + if(OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = -newAxisValue; + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightStickY) + { + newAxisValue = -newAxisValue; + } + } + else if(OnLinux()) + { + if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + } + + return newAxisValue; + } + + private static string DetermineDPad(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sPadCode = ""; + bool invalidCode = false; + + if(OnLinux()) + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "8"; break; + case XboxDPad.Down: sPadCode = "8"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "7"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "7"; break; + case XboxDPad.Down: sPadCode = "7"; break; + case XboxDPad.Left: sPadCode = "6"; break; + case XboxDPad.Right: sPadCode = "6"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sPadCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadMac(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "5"; break; + case XboxDPad.Down: sPadCode = "6"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "8"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadWirelessLinux(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "13"; break; + case XboxDPad.Down: sPadCode = "14"; break; + case XboxDPad.Left: sPadCode = "11"; break; + case XboxDPad.Right: sPadCode = "12"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + + // ------------- Private XInput Wrappers (for Windows Native player and editor only) -------------- // + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + + // ------------ Inner Class ------------// + + // Used to setup XInput for Windows + class XciXInputInitializer + { + // Ctor + public XciXInputInitializer() + { + // Only runs once. + // Setup XInput here... + + + // Call input states twice in order to make sure that + // the previous states and current states are the same. + // This is needed to prevent errors where GetButtonUp will trigger unexpectledly + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + } + + public void Dummy() + { + // Intentionally does nothing to prevent warnings + } + } + + + + // ------------ Members --------------- // + + // Windows variables + private static GamePadState[] xInputCtrlrs = new GamePadState[4]; + private static GamePadState[] xInputCtrlrsPrev = new GamePadState[4]; + private static int xiPrevFrameCount = -1; + private static bool xiUpdateAlreadyCalled = false; + private static bool xiNumOfCtrlrsQueried = false; + private static XciXInputInitializer xinputInitalizer = new XCI.XciXInputInitializer(); + + + + // This can be set to something different if you want + private const GamePadDeadZone WindowsDeadzoneMethod = GamePadDeadZone.Circular; + + + + // ------------ Methods --------------- // + + //>> For updating states << + + private static void XInputUpdateAllStates() + { + if(xiUpdateAlreadyCalled) return; + + for(int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex) i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + xiUpdateAlreadyCalled = true; + } + + + //>> For getting states << + private static GamePadState XInputGetSingleState() + { + return xInputCtrlrs[0]; + } + + private static GamePadState XInputGetPaticularState(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrs[0]; + + return xInputCtrlrs[ctrlNum-1]; + } + + private static GamePadState XInputGetSingleStatePrev() + { + return xInputCtrlrsPrev[0]; + } + + private static GamePadState XInputGetPaticularStatePrev(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrsPrev[0]; + + return xInputCtrlrsPrev[ctrlNum-1]; + } + + //>> For getting input << + private static ButtonState XInputGetButtonState(GamePadButtons xiButtons, XboxButton xciBtn) + { + ButtonState stateToReturn = ButtonState.Pressed; + + switch(xciBtn) + { + case XboxButton.A: stateToReturn = xiButtons.A; break; + case XboxButton.B: stateToReturn = xiButtons.B; break; + case XboxButton.X: stateToReturn = xiButtons.X; break; + case XboxButton.Y: stateToReturn = xiButtons.Y; break; + case XboxButton.Start: stateToReturn = xiButtons.Start; break; + case XboxButton.Back: stateToReturn = xiButtons.Back; break; + case XboxButton.LeftBumper: stateToReturn = xiButtons.LeftShoulder; break; + case XboxButton.RightBumper: stateToReturn = xiButtons.RightShoulder; break; + case XboxButton.LeftStick: stateToReturn = xiButtons.LeftStick; break; + case XboxButton.RightStick: stateToReturn = xiButtons.RightStick; break; + } + + return stateToReturn; + } + + private static ButtonState XInputGetDPadState(GamePadDPad xiDPad, XboxDPad xciDPad) + { + ButtonState stateToReturn = ButtonState.Released; + + switch(xciDPad) + { + case XboxDPad.Up: stateToReturn = xiDPad.Up; break; + case XboxDPad.Down: stateToReturn = xiDPad.Down; break; + case XboxDPad.Left: stateToReturn = xiDPad.Left; break; + case XboxDPad.Right: stateToReturn = xiDPad.Right; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadTriggers xiTriggers, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftTrigger: stateToReturn = xiTriggers.Left; break; + case XboxAxis.RightTrigger: stateToReturn = xiTriggers.Right; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadThumbSticks xiThumbSticks, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftStickX: stateToReturn = xiThumbSticks.Left.X; break; + case XboxAxis.LeftStickY: stateToReturn = xiThumbSticks.Left.Y; break; + case XboxAxis.RightStickX: stateToReturn = xiThumbSticks.Right.X; break; + case XboxAxis.RightStickY: stateToReturn = xiThumbSticks.Right.Y; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static bool XInputStillInCurrFrame() + { + bool r = false; + xinputInitalizer.Dummy(); // Stop warnings about not using the initilaizer + + // Get the current frame + int currFrame = Time.frameCount; + + // Are we still in the current frame? + if(xiPrevFrameCount == currFrame) + { + r = true; + } + else + { + r = false; + xiUpdateAlreadyCalled = false; + } + + // Assign the previous frame count regardless of whether it's the same or not. + xiPrevFrameCount = currFrame; + + return r; + } + + + #endif + + // END of Windows only subsystem ========================================== + + + + // -------------------------- Handler Script ------------------- + + // Secret Private Script that does some maintainace work for XCI states. User should not use this script at all. + private class XciHandler : MonoBehaviour + { + private static XciHandler instance = null; + + public bool u3dTrigger0LeftIsTouched = false; + public bool u3dTrigger0RightIsTouched = false; + public bool u3dTrigger1LeftIsTouched = false; + public bool u3dTrigger1RightIsTouched = false; + public bool u3dTrigger2LeftIsTouched = false; + public bool u3dTrigger2RightIsTouched = false; + public bool u3dTrigger3LeftIsTouched = false; + public bool u3dTrigger3RightIsTouched = false; + public bool u3dTrigger4LeftIsTouched = false; + public bool u3dTrigger4RightIsTouched = false; + + void Awake() + { + if(XciHandler.instance != null) + { + GameObject.Destroy(this.gameObject); + } + + XciHandler.instance = this; + + // Lives for the life of the game + DontDestroyOnLoad(this.gameObject); + } + + void OnEnable() + { + SceneManager.sceneLoaded += OnSceneFinishedLoading; + } + + void OnDisable() + { + SceneManager.sceneLoaded -= OnSceneFinishedLoading; + } + + // Callback made to replace obsolete method OnLevelWasLoaded(int) + void OnSceneFinishedLoading(Scene currentScene, LoadSceneMode mode) + { + this.ResetTriggerTouches(); + } + + void OnApplicationFocus(bool isWindowInFocusNow) + { + if(!isWindowInFocusNow) + { + this.ResetTriggerTouches(); + } + } + + private void ResetTriggerTouches() + { + this.u3dTrigger0LeftIsTouched = false; + this.u3dTrigger0RightIsTouched = false; + this.u3dTrigger1LeftIsTouched = false; + this.u3dTrigger1RightIsTouched = false; + this.u3dTrigger2LeftIsTouched = false; + this.u3dTrigger2RightIsTouched = false; + this.u3dTrigger3LeftIsTouched = false; + this.u3dTrigger3RightIsTouched = false; + this.u3dTrigger4LeftIsTouched = false; + this.u3dTrigger4RightIsTouched = false; + } + + public static XciHandler Instance + { + get + { + if(XciHandler.instance == null) + { + GameObject xciHandleObj = new GameObject("XboxCtrlrInput Handler Object"); + xciHandleObj.AddComponent(); + } + + return XciHandler.instance; + } + } + } // end of XciHandler + } // end of XCI + + public static class XboxButtonExtensions + { + public static bool IsDPad(this XboxButton button) + { + return (button == XboxButton.DPadUp || + button == XboxButton.DPadDown || + button == XboxButton.DPadLeft || + button == XboxButton.DPadRight); + } + + public static XboxDPad ToDPad(this XboxButton button) + { + if (button == XboxButton.DPadUp) + return XboxDPad.Up; + if (button == XboxButton.DPadDown) + return XboxDPad.Down; + if (button == XboxButton.DPadLeft) + return XboxDPad.Left; + if (button == XboxButton.DPadRight) + return XboxDPad.Right; + return default(XboxDPad); + } + + + } + + +} diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta new file mode 100644 index 0000000..25d63aa --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 928025f6ea24748418044e4479b4c446 +timeCreated: 1572134135 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64.meta b/FallUnity/Assets/Plugins/x86_64.meta new file mode 100644 index 0000000..fb502ad --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9cd457a246db3a2458768c6d00ed39e6 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll new file mode 100644 index 0000000..8a2d764 --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta new file mode 100644 index 0000000..88fa34e --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta @@ -0,0 +1,95 @@ +fileFormatVersion: 2 +guid: ea895df4f09804d47ac0a43ce22418cb +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: ARMv7 + Any: + enabled: 1 + settings: + Exclude Android: 0 + Exclude Editor: 0 + Exclude Linux: 0 + Exclude Linux64: 0 + Exclude LinuxUniversal: 0 + Exclude OSXIntel: 0 + Exclude OSXIntel64: 0 + Exclude OSXUniversal: 0 + Exclude SamsungTV: 0 + Exclude Tizen: 0 + Exclude WebGL: 0 + Exclude Win: 1 + Exclude Win64: 0 + Exclude WindowsStoreApps: 0 + Exclude iOS: 0 + Editor: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 1 + settings: + CPU: None + Linux64: + enabled: 1 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel: + enabled: 1 + settings: + CPU: None + OSXIntel64: + enabled: 1 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 1 + settings: + CPU: AnyCPU + SamsungTV: + enabled: 1 + settings: + STV_MODEL: STANDARD_15 + Tizen: + enabled: 1 + settings: {} + WebGL: + enabled: 1 + settings: {} + Win: + enabled: 0 + settings: + CPU: None + Win64: + enabled: 1 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + iOS: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta new file mode 100644 index 0000000..2d0e145 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ada75d1768d6fad4eb285bd538323380 +timeCreated: 1472582191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs new file mode 100644 index 0000000..1106813 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using XboxCtrlrInput; + +namespace PlayerInput +{ + public class XboxControllerInputSource : InputSource where TTarget : MonoBehaviour + { + private static List allControllers; + public static IEnumerable AllControllers { get { return allControllers; } } + static XboxControllerInputSource() + { + allControllers = new List() + { + XboxController.First, + XboxController.Second, + XboxController.Third, + XboxController.Fourth, + }; + } + + private Dictionary buttonMapping; + private Dictionary axisMapping; + + private XboxController controller; + public XboxController Controller { get { return controller; } } + + public XboxControllerInputSource(XboxController controller) + { + this.controller = controller; + + buttonMapping = new Dictionary() + { + { InputButton.MenuSelect, XboxButton.A }, + { InputButton.MenuCancel, XboxButton.B }, + + //{ InputButton.UseItem, XboxButton.A }, + //{ InputButton.PickA, XboxButton.LeftBumper }, + //{ InputButton.PickB, XboxButton.RightBumper }, + + //{ InputButton.AnimalSelector, XboxButton.LeftBumper }, + }; + + axisMapping = new Dictionary() + { + { InputAxis.MenuX, XboxAxis.LeftStickX }, + { InputAxis.MenuY, XboxAxis.LeftStickY }, + + { InputAxis.RakeX, XboxAxis.RightStickX }, + { InputAxis.RakeY, XboxAxis.RightStickY }, + + { InputAxis.MoveX, XboxAxis.LeftStickX }, + { InputAxis.MoveY, XboxAxis.LeftStickY }, + + //{ InputAxis.Throttle, XboxAxis.RightTrigger }, + //{ InputAxis.RevThrottle, XboxAxis.LeftTrigger }, + }; + } + + protected override void VibrateInternal(float left, float right) + { + XCI.SetVibration(controller, left, right); + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + return XCI.GetButtonDown(buttonMapping[button], controller); + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + return XCI.GetButtonUp(buttonMapping[button], controller); + } + + public override bool ButtonDown(InputButton button) + { + return XCI.GetButton(buttonMapping[button], controller); + } + + public override float Axis(InputAxis axis) + { + return XCI.GetAxis(axisMapping[axis], controller); + } + } +} diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta new file mode 100644 index 0000000..9f6859f --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ec7d070ee2898544aa46811e0e3da197 +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins.meta b/FallUnity/Assets/Plugins.meta new file mode 100644 index 0000000..b7025e8 --- /dev/null +++ b/FallUnity/Assets/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: dca2b803c244eb540bbf437959ae5f51 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll b/FallUnity/Assets/Plugins/XInputDotNetPure.dll new file mode 100644 index 0000000..d345520 --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta new file mode 100644 index 0000000..c87585b --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: a05c5d8086133f648a3dd3229d764a63 +timeCreated: 1572134134 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs new file mode 100644 index 0000000..69ee3a8 --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs @@ -0,0 +1,1969 @@ +using UnityEngine; +using UnityEngine.SceneManagement; + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN +using XInputDotNetPure; +#endif + +namespace XboxCtrlrInput +{ + + // ================= Enumerations ==================== // + + /// + /// List of enumerated identifiers for Xbox controllers. + /// + /// + /// Do NOT change enum values + /// + public enum XboxController + { + /// + /// "All" Controllers is deprecated! Use "Any" instead. + /// + [System.Obsolete("Instead use XboxController.Any")] + All = 0, + + Any = 0, + + First = 1, + Second = 2, + Third = 3, + Fourth = 4 + } + + /// + /// List of enumerated identifiers for Xbox buttons. + /// + public enum XboxButton + { + A, + B, + X, + Y, + Start, + Back, + LeftStick, + RightStick, + LeftBumper, + RightBumper, + DPadUp, + DPadDown, + DPadLeft, + DPadRight + } + + /// + /// List of enumerated identifiers for Xbox D-Pad directions. + /// + public enum XboxDPad + { + Up, + Down, + Left, + Right + } + + /// + /// List of enumerated identifiers for Xbox axis. + /// + public enum XboxAxis + { + LeftStickX, + LeftStickY, + RightStickX, + RightStickY, + LeftTrigger, + RightTrigger + } + + // ================ Classes =================== // + + public static class XCI + { + // ------------ Public Methods --------------- // + + public static bool SetVibration(XboxController controller, float left, float right) + { + + int controllerNumber = (int)controller; + + if (OnWindowsNative()) + { + GamePad.SetVibration((PlayerIndex)(controllerNumber - 1), left, right); + } + else + { + + } + + return false; + } + + // >>> For Buttons <<< // + + /// + /// Returns true if the specified button is held down by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButton(XboxButton button) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true if the specified button is held down by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButton(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButton(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonDown(XboxButton button) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonDown(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonDown(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonUp(XboxButton button) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonUp(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonUp(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + // >>> For D-Pad <<< // + + /// + /// Returns true if the specified D-Pad direction is pressed down by any controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + public static bool GetDPad(XboxDPad padDirection) + { + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, 0); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + /// + /// Returns true if the specified D-Pad direction is pressed down by a specified controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + /// + /// An identifier for the specific controller on which to test the D-Pad. + /// + public static bool GetDPad(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPad(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, controllerNumber); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadUp(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadUp(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadUp(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadDown(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadDown(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadDown(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // >>> For Axis <<< // + + /// + /// Returns the analog number of the specified axis from any controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxis(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxis(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxis(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from any controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxisRaw(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxisRaw(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxisRaw(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + // >>> Other important functions <<< // + + /// + /// Returns the number of Xbox controllers plugged to the computer. + /// + public static int GetNumPluggedCtrlrs() + { + int r = 0; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!xiNumOfCtrlrsQueried || !XInputStillInCurrFrame()) + { + xiNumOfCtrlrsQueried = true; + XInputUpdateAllStates(); + } + + for(int i = 0; i < 4; i++) + { + if(xInputCtrlrs[i].IsConnected) + { + r++; + } + } + #endif + } + + else + { + string[] ctrlrNames = Input.GetJoystickNames(); + for(int i = 0; i < ctrlrNames.Length; i++) + { + if(ctrlrNames[i].Contains("Xbox") || ctrlrNames[i].Contains("XBOX") || ctrlrNames[i].Contains("Microsoft")) + { + r++; + } + } + } + + return r; + } + + /// + /// DEBUG function. Log all controller names to Unity's console. + /// + public static void DEBUG_LogControllerNames() + { + string[] cNames = Input.GetJoystickNames(); + + for(int i = 0; i < cNames.Length; i++) + { + Debug.Log("Ctrlr " + i.ToString() + ": " + cNames[i]); + } + } + + + + + + // From @xoorath + /// + /// DEPRECATED: + /// Determines if the controller is plugged in the specified controllerNumber. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. An int between 1 and 4. + /// + [System.Obsolete("Instead use IsPluggedIn(XboxController)")] + public static bool IsPluggedIn(int controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + return ctrlrState.IsConnected; + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + // Based off @xoorath 's implementation + /// + /// Determines if the controller is plugged in the specified controllerNumber. + /// Passing Any will evaluate if any controller is connected. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// Passing Any will evaluate if any controller is connected. + /// + public static bool IsPluggedIn(XboxController controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + { + if (OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState; + + + // If inquiring about any controller + + // TODO: Remove condition for XboxController.All when the time comes + // Users of XCI: Feel free to remove XboxController.All if you like having no warnings + if(controllerNumber == XboxController.Any || controllerNumber == XboxController.All) + { + // Examine all controllers it see if any are connected + for(int i = 1; i <= 4; i++) + { + ctrlrState = XInputGetPaticularState(i); + if(ctrlrState.IsConnected) + { + return true; + } + } + } + + + // If specifying a specific controller + + // Note: Casting only works if XboxController enums are values 1 to 4 (First, Second, Third, Fourth) + ctrlrState = XInputGetPaticularState((int)controllerNumber); + + return ctrlrState.IsConnected; + } + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + + + //// + // ------------- Private -------------- // + //// + + // ------------ Methods --------------- // + + private static bool OnMac() + { + // All Mac mappings are based off TattieBogle Xbox Controller drivers + // http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver + // http://wiki.unity3d.com/index.php?title=Xbox360Controller + return (Application.platform == RuntimePlatform.OSXEditor || + Application.platform == RuntimePlatform.OSXPlayer ); + } + + private static bool OnWindows() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnWindowsNative() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnLinux() + { + // Linux mapping based on observation of mapping from default drivers on Ubuntu 13.04 + return Application.platform == RuntimePlatform.LinuxPlayer; + } + + private static bool IsControllerWireless() + { + // 0 means for any controller + return IsControllerWireless(0); + } + + private static bool IsControllerWireless(int ctrlNum) + { + if (ctrlNum < 0 || ctrlNum > 4) return false; + + // If 0 is passed in, that assumes that only 1 controller is plugged in. + if(ctrlNum == 0) + { + return ( (string) Input.GetJoystickNames()[0]).Contains("Wireless"); + } + + return ( (string) Input.GetJoystickNames()[ctrlNum-1]).Contains("Wireless"); + } + + private static bool IsControllerNumberValid(int ctrlrNum) + { + if(ctrlrNum > 0 && ctrlrNum <= 4) + { + return true; + } + else + { + Debug.LogError("XCI.IsControllerNumberValid(): " + + "Invalid contoller number! Should be between 1 and 4."); + } + return false; + } + + private static float RefactorRange(float oldRangeValue, int ctrlrNum, XboxAxis axis) + { + // HACK: On OS X, Left and right trigger under OSX return 0.5 until touched + // Issue #16 on Github: https://github.com/JISyed/Unity-XboxCtrlrInput/issues/16 + if(XCI.OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + else if(axis == XboxAxis.RightTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + } + + // Assumes you want to take a number from -1 to 1 range + // And turn it into a number from a 0 to 1 range + return ((oldRangeValue + 1.0f) / 2.0f ); + } + + private static string DetermineButtonCode(XboxButton btn, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sKeyCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + if(OnMac()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "16"; break; + case XboxButton.B: sKeyCode = "17"; break; + case XboxButton.X: sKeyCode = "18"; break; + case XboxButton.Y: sKeyCode = "19"; break; + case XboxButton.Start: sKeyCode = "9"; break; + case XboxButton.Back: sKeyCode = "10"; break; + case XboxButton.LeftStick: sKeyCode = "11"; break; + case XboxButton.RightStick: sKeyCode = "12"; break; + case XboxButton.LeftBumper: sKeyCode = "13"; break; + case XboxButton.RightBumper: sKeyCode = "14"; break; + + default: invalidCode = true; break; + } + } + else if (OnLinux()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "9"; break; + case XboxButton.RightStick: sKeyCode = "10"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "8"; break; + case XboxButton.RightStick: sKeyCode = "9"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + + r = "joystick" + sJoyCode + " button " + sKeyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineAxisCode(XboxAxis axs, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sAxisCode = ""; + bool invalidCode = false; + + + if(OnMac()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "3"; break; + case XboxAxis.RightStickY: sAxisCode = "4"; break; + case XboxAxis.LeftTrigger: sAxisCode = "5"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else if(OnLinux()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "3"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "9"; break; + case XboxAxis.RightTrigger: sAxisCode = "10"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sAxisCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static float AdjustAxisValues(float axisValue, XboxAxis axis, int ctrlrNum) + { + float newAxisValue = axisValue; + + if(OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = -newAxisValue; + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightStickY) + { + newAxisValue = -newAxisValue; + } + } + else if(OnLinux()) + { + if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + } + + return newAxisValue; + } + + private static string DetermineDPad(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sPadCode = ""; + bool invalidCode = false; + + if(OnLinux()) + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "8"; break; + case XboxDPad.Down: sPadCode = "8"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "7"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "7"; break; + case XboxDPad.Down: sPadCode = "7"; break; + case XboxDPad.Left: sPadCode = "6"; break; + case XboxDPad.Right: sPadCode = "6"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sPadCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadMac(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "5"; break; + case XboxDPad.Down: sPadCode = "6"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "8"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadWirelessLinux(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "13"; break; + case XboxDPad.Down: sPadCode = "14"; break; + case XboxDPad.Left: sPadCode = "11"; break; + case XboxDPad.Right: sPadCode = "12"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + + // ------------- Private XInput Wrappers (for Windows Native player and editor only) -------------- // + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + + // ------------ Inner Class ------------// + + // Used to setup XInput for Windows + class XciXInputInitializer + { + // Ctor + public XciXInputInitializer() + { + // Only runs once. + // Setup XInput here... + + + // Call input states twice in order to make sure that + // the previous states and current states are the same. + // This is needed to prevent errors where GetButtonUp will trigger unexpectledly + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + } + + public void Dummy() + { + // Intentionally does nothing to prevent warnings + } + } + + + + // ------------ Members --------------- // + + // Windows variables + private static GamePadState[] xInputCtrlrs = new GamePadState[4]; + private static GamePadState[] xInputCtrlrsPrev = new GamePadState[4]; + private static int xiPrevFrameCount = -1; + private static bool xiUpdateAlreadyCalled = false; + private static bool xiNumOfCtrlrsQueried = false; + private static XciXInputInitializer xinputInitalizer = new XCI.XciXInputInitializer(); + + + + // This can be set to something different if you want + private const GamePadDeadZone WindowsDeadzoneMethod = GamePadDeadZone.Circular; + + + + // ------------ Methods --------------- // + + //>> For updating states << + + private static void XInputUpdateAllStates() + { + if(xiUpdateAlreadyCalled) return; + + for(int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex) i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + xiUpdateAlreadyCalled = true; + } + + + //>> For getting states << + private static GamePadState XInputGetSingleState() + { + return xInputCtrlrs[0]; + } + + private static GamePadState XInputGetPaticularState(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrs[0]; + + return xInputCtrlrs[ctrlNum-1]; + } + + private static GamePadState XInputGetSingleStatePrev() + { + return xInputCtrlrsPrev[0]; + } + + private static GamePadState XInputGetPaticularStatePrev(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrsPrev[0]; + + return xInputCtrlrsPrev[ctrlNum-1]; + } + + //>> For getting input << + private static ButtonState XInputGetButtonState(GamePadButtons xiButtons, XboxButton xciBtn) + { + ButtonState stateToReturn = ButtonState.Pressed; + + switch(xciBtn) + { + case XboxButton.A: stateToReturn = xiButtons.A; break; + case XboxButton.B: stateToReturn = xiButtons.B; break; + case XboxButton.X: stateToReturn = xiButtons.X; break; + case XboxButton.Y: stateToReturn = xiButtons.Y; break; + case XboxButton.Start: stateToReturn = xiButtons.Start; break; + case XboxButton.Back: stateToReturn = xiButtons.Back; break; + case XboxButton.LeftBumper: stateToReturn = xiButtons.LeftShoulder; break; + case XboxButton.RightBumper: stateToReturn = xiButtons.RightShoulder; break; + case XboxButton.LeftStick: stateToReturn = xiButtons.LeftStick; break; + case XboxButton.RightStick: stateToReturn = xiButtons.RightStick; break; + } + + return stateToReturn; + } + + private static ButtonState XInputGetDPadState(GamePadDPad xiDPad, XboxDPad xciDPad) + { + ButtonState stateToReturn = ButtonState.Released; + + switch(xciDPad) + { + case XboxDPad.Up: stateToReturn = xiDPad.Up; break; + case XboxDPad.Down: stateToReturn = xiDPad.Down; break; + case XboxDPad.Left: stateToReturn = xiDPad.Left; break; + case XboxDPad.Right: stateToReturn = xiDPad.Right; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadTriggers xiTriggers, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftTrigger: stateToReturn = xiTriggers.Left; break; + case XboxAxis.RightTrigger: stateToReturn = xiTriggers.Right; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadThumbSticks xiThumbSticks, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftStickX: stateToReturn = xiThumbSticks.Left.X; break; + case XboxAxis.LeftStickY: stateToReturn = xiThumbSticks.Left.Y; break; + case XboxAxis.RightStickX: stateToReturn = xiThumbSticks.Right.X; break; + case XboxAxis.RightStickY: stateToReturn = xiThumbSticks.Right.Y; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static bool XInputStillInCurrFrame() + { + bool r = false; + xinputInitalizer.Dummy(); // Stop warnings about not using the initilaizer + + // Get the current frame + int currFrame = Time.frameCount; + + // Are we still in the current frame? + if(xiPrevFrameCount == currFrame) + { + r = true; + } + else + { + r = false; + xiUpdateAlreadyCalled = false; + } + + // Assign the previous frame count regardless of whether it's the same or not. + xiPrevFrameCount = currFrame; + + return r; + } + + + #endif + + // END of Windows only subsystem ========================================== + + + + // -------------------------- Handler Script ------------------- + + // Secret Private Script that does some maintainace work for XCI states. User should not use this script at all. + private class XciHandler : MonoBehaviour + { + private static XciHandler instance = null; + + public bool u3dTrigger0LeftIsTouched = false; + public bool u3dTrigger0RightIsTouched = false; + public bool u3dTrigger1LeftIsTouched = false; + public bool u3dTrigger1RightIsTouched = false; + public bool u3dTrigger2LeftIsTouched = false; + public bool u3dTrigger2RightIsTouched = false; + public bool u3dTrigger3LeftIsTouched = false; + public bool u3dTrigger3RightIsTouched = false; + public bool u3dTrigger4LeftIsTouched = false; + public bool u3dTrigger4RightIsTouched = false; + + void Awake() + { + if(XciHandler.instance != null) + { + GameObject.Destroy(this.gameObject); + } + + XciHandler.instance = this; + + // Lives for the life of the game + DontDestroyOnLoad(this.gameObject); + } + + void OnEnable() + { + SceneManager.sceneLoaded += OnSceneFinishedLoading; + } + + void OnDisable() + { + SceneManager.sceneLoaded -= OnSceneFinishedLoading; + } + + // Callback made to replace obsolete method OnLevelWasLoaded(int) + void OnSceneFinishedLoading(Scene currentScene, LoadSceneMode mode) + { + this.ResetTriggerTouches(); + } + + void OnApplicationFocus(bool isWindowInFocusNow) + { + if(!isWindowInFocusNow) + { + this.ResetTriggerTouches(); + } + } + + private void ResetTriggerTouches() + { + this.u3dTrigger0LeftIsTouched = false; + this.u3dTrigger0RightIsTouched = false; + this.u3dTrigger1LeftIsTouched = false; + this.u3dTrigger1RightIsTouched = false; + this.u3dTrigger2LeftIsTouched = false; + this.u3dTrigger2RightIsTouched = false; + this.u3dTrigger3LeftIsTouched = false; + this.u3dTrigger3RightIsTouched = false; + this.u3dTrigger4LeftIsTouched = false; + this.u3dTrigger4RightIsTouched = false; + } + + public static XciHandler Instance + { + get + { + if(XciHandler.instance == null) + { + GameObject xciHandleObj = new GameObject("XboxCtrlrInput Handler Object"); + xciHandleObj.AddComponent(); + } + + return XciHandler.instance; + } + } + } // end of XciHandler + } // end of XCI + + public static class XboxButtonExtensions + { + public static bool IsDPad(this XboxButton button) + { + return (button == XboxButton.DPadUp || + button == XboxButton.DPadDown || + button == XboxButton.DPadLeft || + button == XboxButton.DPadRight); + } + + public static XboxDPad ToDPad(this XboxButton button) + { + if (button == XboxButton.DPadUp) + return XboxDPad.Up; + if (button == XboxButton.DPadDown) + return XboxDPad.Down; + if (button == XboxButton.DPadLeft) + return XboxDPad.Left; + if (button == XboxButton.DPadRight) + return XboxDPad.Right; + return default(XboxDPad); + } + + + } + + +} diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta new file mode 100644 index 0000000..25d63aa --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 928025f6ea24748418044e4479b4c446 +timeCreated: 1572134135 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64.meta b/FallUnity/Assets/Plugins/x86_64.meta new file mode 100644 index 0000000..fb502ad --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9cd457a246db3a2458768c6d00ed39e6 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll new file mode 100644 index 0000000..8a2d764 --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta new file mode 100644 index 0000000..88fa34e --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta @@ -0,0 +1,95 @@ +fileFormatVersion: 2 +guid: ea895df4f09804d47ac0a43ce22418cb +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: ARMv7 + Any: + enabled: 1 + settings: + Exclude Android: 0 + Exclude Editor: 0 + Exclude Linux: 0 + Exclude Linux64: 0 + Exclude LinuxUniversal: 0 + Exclude OSXIntel: 0 + Exclude OSXIntel64: 0 + Exclude OSXUniversal: 0 + Exclude SamsungTV: 0 + Exclude Tizen: 0 + Exclude WebGL: 0 + Exclude Win: 1 + Exclude Win64: 0 + Exclude WindowsStoreApps: 0 + Exclude iOS: 0 + Editor: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 1 + settings: + CPU: None + Linux64: + enabled: 1 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel: + enabled: 1 + settings: + CPU: None + OSXIntel64: + enabled: 1 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 1 + settings: + CPU: AnyCPU + SamsungTV: + enabled: 1 + settings: + STV_MODEL: STANDARD_15 + Tizen: + enabled: 1 + settings: {} + WebGL: + enabled: 1 + settings: {} + Win: + enabled: 0 + settings: + CPU: None + Win64: + enabled: 1 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + iOS: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/RedDebug.mat b/FallUnity/Assets/RedDebug.mat new file mode 100644 index 0000000..7786680 --- /dev/null +++ b/FallUnity/Assets/RedDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: RedDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 0, b: 0, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta new file mode 100644 index 0000000..2d0e145 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ada75d1768d6fad4eb285bd538323380 +timeCreated: 1472582191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs new file mode 100644 index 0000000..1106813 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using XboxCtrlrInput; + +namespace PlayerInput +{ + public class XboxControllerInputSource : InputSource where TTarget : MonoBehaviour + { + private static List allControllers; + public static IEnumerable AllControllers { get { return allControllers; } } + static XboxControllerInputSource() + { + allControllers = new List() + { + XboxController.First, + XboxController.Second, + XboxController.Third, + XboxController.Fourth, + }; + } + + private Dictionary buttonMapping; + private Dictionary axisMapping; + + private XboxController controller; + public XboxController Controller { get { return controller; } } + + public XboxControllerInputSource(XboxController controller) + { + this.controller = controller; + + buttonMapping = new Dictionary() + { + { InputButton.MenuSelect, XboxButton.A }, + { InputButton.MenuCancel, XboxButton.B }, + + //{ InputButton.UseItem, XboxButton.A }, + //{ InputButton.PickA, XboxButton.LeftBumper }, + //{ InputButton.PickB, XboxButton.RightBumper }, + + //{ InputButton.AnimalSelector, XboxButton.LeftBumper }, + }; + + axisMapping = new Dictionary() + { + { InputAxis.MenuX, XboxAxis.LeftStickX }, + { InputAxis.MenuY, XboxAxis.LeftStickY }, + + { InputAxis.RakeX, XboxAxis.RightStickX }, + { InputAxis.RakeY, XboxAxis.RightStickY }, + + { InputAxis.MoveX, XboxAxis.LeftStickX }, + { InputAxis.MoveY, XboxAxis.LeftStickY }, + + //{ InputAxis.Throttle, XboxAxis.RightTrigger }, + //{ InputAxis.RevThrottle, XboxAxis.LeftTrigger }, + }; + } + + protected override void VibrateInternal(float left, float right) + { + XCI.SetVibration(controller, left, right); + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + return XCI.GetButtonDown(buttonMapping[button], controller); + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + return XCI.GetButtonUp(buttonMapping[button], controller); + } + + public override bool ButtonDown(InputButton button) + { + return XCI.GetButton(buttonMapping[button], controller); + } + + public override float Axis(InputAxis axis) + { + return XCI.GetAxis(axisMapping[axis], controller); + } + } +} diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta new file mode 100644 index 0000000..9f6859f --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ec7d070ee2898544aa46811e0e3da197 +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins.meta b/FallUnity/Assets/Plugins.meta new file mode 100644 index 0000000..b7025e8 --- /dev/null +++ b/FallUnity/Assets/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: dca2b803c244eb540bbf437959ae5f51 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll b/FallUnity/Assets/Plugins/XInputDotNetPure.dll new file mode 100644 index 0000000..d345520 --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta new file mode 100644 index 0000000..c87585b --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: a05c5d8086133f648a3dd3229d764a63 +timeCreated: 1572134134 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs new file mode 100644 index 0000000..69ee3a8 --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs @@ -0,0 +1,1969 @@ +using UnityEngine; +using UnityEngine.SceneManagement; + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN +using XInputDotNetPure; +#endif + +namespace XboxCtrlrInput +{ + + // ================= Enumerations ==================== // + + /// + /// List of enumerated identifiers for Xbox controllers. + /// + /// + /// Do NOT change enum values + /// + public enum XboxController + { + /// + /// "All" Controllers is deprecated! Use "Any" instead. + /// + [System.Obsolete("Instead use XboxController.Any")] + All = 0, + + Any = 0, + + First = 1, + Second = 2, + Third = 3, + Fourth = 4 + } + + /// + /// List of enumerated identifiers for Xbox buttons. + /// + public enum XboxButton + { + A, + B, + X, + Y, + Start, + Back, + LeftStick, + RightStick, + LeftBumper, + RightBumper, + DPadUp, + DPadDown, + DPadLeft, + DPadRight + } + + /// + /// List of enumerated identifiers for Xbox D-Pad directions. + /// + public enum XboxDPad + { + Up, + Down, + Left, + Right + } + + /// + /// List of enumerated identifiers for Xbox axis. + /// + public enum XboxAxis + { + LeftStickX, + LeftStickY, + RightStickX, + RightStickY, + LeftTrigger, + RightTrigger + } + + // ================ Classes =================== // + + public static class XCI + { + // ------------ Public Methods --------------- // + + public static bool SetVibration(XboxController controller, float left, float right) + { + + int controllerNumber = (int)controller; + + if (OnWindowsNative()) + { + GamePad.SetVibration((PlayerIndex)(controllerNumber - 1), left, right); + } + else + { + + } + + return false; + } + + // >>> For Buttons <<< // + + /// + /// Returns true if the specified button is held down by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButton(XboxButton button) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true if the specified button is held down by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButton(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButton(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonDown(XboxButton button) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonDown(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonDown(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonUp(XboxButton button) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonUp(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonUp(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + // >>> For D-Pad <<< // + + /// + /// Returns true if the specified D-Pad direction is pressed down by any controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + public static bool GetDPad(XboxDPad padDirection) + { + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, 0); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + /// + /// Returns true if the specified D-Pad direction is pressed down by a specified controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + /// + /// An identifier for the specific controller on which to test the D-Pad. + /// + public static bool GetDPad(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPad(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, controllerNumber); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadUp(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadUp(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadUp(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadDown(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadDown(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadDown(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // >>> For Axis <<< // + + /// + /// Returns the analog number of the specified axis from any controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxis(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxis(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxis(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from any controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxisRaw(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxisRaw(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxisRaw(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + // >>> Other important functions <<< // + + /// + /// Returns the number of Xbox controllers plugged to the computer. + /// + public static int GetNumPluggedCtrlrs() + { + int r = 0; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!xiNumOfCtrlrsQueried || !XInputStillInCurrFrame()) + { + xiNumOfCtrlrsQueried = true; + XInputUpdateAllStates(); + } + + for(int i = 0; i < 4; i++) + { + if(xInputCtrlrs[i].IsConnected) + { + r++; + } + } + #endif + } + + else + { + string[] ctrlrNames = Input.GetJoystickNames(); + for(int i = 0; i < ctrlrNames.Length; i++) + { + if(ctrlrNames[i].Contains("Xbox") || ctrlrNames[i].Contains("XBOX") || ctrlrNames[i].Contains("Microsoft")) + { + r++; + } + } + } + + return r; + } + + /// + /// DEBUG function. Log all controller names to Unity's console. + /// + public static void DEBUG_LogControllerNames() + { + string[] cNames = Input.GetJoystickNames(); + + for(int i = 0; i < cNames.Length; i++) + { + Debug.Log("Ctrlr " + i.ToString() + ": " + cNames[i]); + } + } + + + + + + // From @xoorath + /// + /// DEPRECATED: + /// Determines if the controller is plugged in the specified controllerNumber. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. An int between 1 and 4. + /// + [System.Obsolete("Instead use IsPluggedIn(XboxController)")] + public static bool IsPluggedIn(int controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + return ctrlrState.IsConnected; + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + // Based off @xoorath 's implementation + /// + /// Determines if the controller is plugged in the specified controllerNumber. + /// Passing Any will evaluate if any controller is connected. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// Passing Any will evaluate if any controller is connected. + /// + public static bool IsPluggedIn(XboxController controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + { + if (OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState; + + + // If inquiring about any controller + + // TODO: Remove condition for XboxController.All when the time comes + // Users of XCI: Feel free to remove XboxController.All if you like having no warnings + if(controllerNumber == XboxController.Any || controllerNumber == XboxController.All) + { + // Examine all controllers it see if any are connected + for(int i = 1; i <= 4; i++) + { + ctrlrState = XInputGetPaticularState(i); + if(ctrlrState.IsConnected) + { + return true; + } + } + } + + + // If specifying a specific controller + + // Note: Casting only works if XboxController enums are values 1 to 4 (First, Second, Third, Fourth) + ctrlrState = XInputGetPaticularState((int)controllerNumber); + + return ctrlrState.IsConnected; + } + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + + + //// + // ------------- Private -------------- // + //// + + // ------------ Methods --------------- // + + private static bool OnMac() + { + // All Mac mappings are based off TattieBogle Xbox Controller drivers + // http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver + // http://wiki.unity3d.com/index.php?title=Xbox360Controller + return (Application.platform == RuntimePlatform.OSXEditor || + Application.platform == RuntimePlatform.OSXPlayer ); + } + + private static bool OnWindows() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnWindowsNative() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnLinux() + { + // Linux mapping based on observation of mapping from default drivers on Ubuntu 13.04 + return Application.platform == RuntimePlatform.LinuxPlayer; + } + + private static bool IsControllerWireless() + { + // 0 means for any controller + return IsControllerWireless(0); + } + + private static bool IsControllerWireless(int ctrlNum) + { + if (ctrlNum < 0 || ctrlNum > 4) return false; + + // If 0 is passed in, that assumes that only 1 controller is plugged in. + if(ctrlNum == 0) + { + return ( (string) Input.GetJoystickNames()[0]).Contains("Wireless"); + } + + return ( (string) Input.GetJoystickNames()[ctrlNum-1]).Contains("Wireless"); + } + + private static bool IsControllerNumberValid(int ctrlrNum) + { + if(ctrlrNum > 0 && ctrlrNum <= 4) + { + return true; + } + else + { + Debug.LogError("XCI.IsControllerNumberValid(): " + + "Invalid contoller number! Should be between 1 and 4."); + } + return false; + } + + private static float RefactorRange(float oldRangeValue, int ctrlrNum, XboxAxis axis) + { + // HACK: On OS X, Left and right trigger under OSX return 0.5 until touched + // Issue #16 on Github: https://github.com/JISyed/Unity-XboxCtrlrInput/issues/16 + if(XCI.OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + else if(axis == XboxAxis.RightTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + } + + // Assumes you want to take a number from -1 to 1 range + // And turn it into a number from a 0 to 1 range + return ((oldRangeValue + 1.0f) / 2.0f ); + } + + private static string DetermineButtonCode(XboxButton btn, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sKeyCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + if(OnMac()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "16"; break; + case XboxButton.B: sKeyCode = "17"; break; + case XboxButton.X: sKeyCode = "18"; break; + case XboxButton.Y: sKeyCode = "19"; break; + case XboxButton.Start: sKeyCode = "9"; break; + case XboxButton.Back: sKeyCode = "10"; break; + case XboxButton.LeftStick: sKeyCode = "11"; break; + case XboxButton.RightStick: sKeyCode = "12"; break; + case XboxButton.LeftBumper: sKeyCode = "13"; break; + case XboxButton.RightBumper: sKeyCode = "14"; break; + + default: invalidCode = true; break; + } + } + else if (OnLinux()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "9"; break; + case XboxButton.RightStick: sKeyCode = "10"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "8"; break; + case XboxButton.RightStick: sKeyCode = "9"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + + r = "joystick" + sJoyCode + " button " + sKeyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineAxisCode(XboxAxis axs, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sAxisCode = ""; + bool invalidCode = false; + + + if(OnMac()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "3"; break; + case XboxAxis.RightStickY: sAxisCode = "4"; break; + case XboxAxis.LeftTrigger: sAxisCode = "5"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else if(OnLinux()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "3"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "9"; break; + case XboxAxis.RightTrigger: sAxisCode = "10"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sAxisCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static float AdjustAxisValues(float axisValue, XboxAxis axis, int ctrlrNum) + { + float newAxisValue = axisValue; + + if(OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = -newAxisValue; + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightStickY) + { + newAxisValue = -newAxisValue; + } + } + else if(OnLinux()) + { + if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + } + + return newAxisValue; + } + + private static string DetermineDPad(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sPadCode = ""; + bool invalidCode = false; + + if(OnLinux()) + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "8"; break; + case XboxDPad.Down: sPadCode = "8"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "7"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "7"; break; + case XboxDPad.Down: sPadCode = "7"; break; + case XboxDPad.Left: sPadCode = "6"; break; + case XboxDPad.Right: sPadCode = "6"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sPadCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadMac(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "5"; break; + case XboxDPad.Down: sPadCode = "6"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "8"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadWirelessLinux(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "13"; break; + case XboxDPad.Down: sPadCode = "14"; break; + case XboxDPad.Left: sPadCode = "11"; break; + case XboxDPad.Right: sPadCode = "12"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + + // ------------- Private XInput Wrappers (for Windows Native player and editor only) -------------- // + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + + // ------------ Inner Class ------------// + + // Used to setup XInput for Windows + class XciXInputInitializer + { + // Ctor + public XciXInputInitializer() + { + // Only runs once. + // Setup XInput here... + + + // Call input states twice in order to make sure that + // the previous states and current states are the same. + // This is needed to prevent errors where GetButtonUp will trigger unexpectledly + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + } + + public void Dummy() + { + // Intentionally does nothing to prevent warnings + } + } + + + + // ------------ Members --------------- // + + // Windows variables + private static GamePadState[] xInputCtrlrs = new GamePadState[4]; + private static GamePadState[] xInputCtrlrsPrev = new GamePadState[4]; + private static int xiPrevFrameCount = -1; + private static bool xiUpdateAlreadyCalled = false; + private static bool xiNumOfCtrlrsQueried = false; + private static XciXInputInitializer xinputInitalizer = new XCI.XciXInputInitializer(); + + + + // This can be set to something different if you want + private const GamePadDeadZone WindowsDeadzoneMethod = GamePadDeadZone.Circular; + + + + // ------------ Methods --------------- // + + //>> For updating states << + + private static void XInputUpdateAllStates() + { + if(xiUpdateAlreadyCalled) return; + + for(int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex) i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + xiUpdateAlreadyCalled = true; + } + + + //>> For getting states << + private static GamePadState XInputGetSingleState() + { + return xInputCtrlrs[0]; + } + + private static GamePadState XInputGetPaticularState(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrs[0]; + + return xInputCtrlrs[ctrlNum-1]; + } + + private static GamePadState XInputGetSingleStatePrev() + { + return xInputCtrlrsPrev[0]; + } + + private static GamePadState XInputGetPaticularStatePrev(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrsPrev[0]; + + return xInputCtrlrsPrev[ctrlNum-1]; + } + + //>> For getting input << + private static ButtonState XInputGetButtonState(GamePadButtons xiButtons, XboxButton xciBtn) + { + ButtonState stateToReturn = ButtonState.Pressed; + + switch(xciBtn) + { + case XboxButton.A: stateToReturn = xiButtons.A; break; + case XboxButton.B: stateToReturn = xiButtons.B; break; + case XboxButton.X: stateToReturn = xiButtons.X; break; + case XboxButton.Y: stateToReturn = xiButtons.Y; break; + case XboxButton.Start: stateToReturn = xiButtons.Start; break; + case XboxButton.Back: stateToReturn = xiButtons.Back; break; + case XboxButton.LeftBumper: stateToReturn = xiButtons.LeftShoulder; break; + case XboxButton.RightBumper: stateToReturn = xiButtons.RightShoulder; break; + case XboxButton.LeftStick: stateToReturn = xiButtons.LeftStick; break; + case XboxButton.RightStick: stateToReturn = xiButtons.RightStick; break; + } + + return stateToReturn; + } + + private static ButtonState XInputGetDPadState(GamePadDPad xiDPad, XboxDPad xciDPad) + { + ButtonState stateToReturn = ButtonState.Released; + + switch(xciDPad) + { + case XboxDPad.Up: stateToReturn = xiDPad.Up; break; + case XboxDPad.Down: stateToReturn = xiDPad.Down; break; + case XboxDPad.Left: stateToReturn = xiDPad.Left; break; + case XboxDPad.Right: stateToReturn = xiDPad.Right; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadTriggers xiTriggers, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftTrigger: stateToReturn = xiTriggers.Left; break; + case XboxAxis.RightTrigger: stateToReturn = xiTriggers.Right; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadThumbSticks xiThumbSticks, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftStickX: stateToReturn = xiThumbSticks.Left.X; break; + case XboxAxis.LeftStickY: stateToReturn = xiThumbSticks.Left.Y; break; + case XboxAxis.RightStickX: stateToReturn = xiThumbSticks.Right.X; break; + case XboxAxis.RightStickY: stateToReturn = xiThumbSticks.Right.Y; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static bool XInputStillInCurrFrame() + { + bool r = false; + xinputInitalizer.Dummy(); // Stop warnings about not using the initilaizer + + // Get the current frame + int currFrame = Time.frameCount; + + // Are we still in the current frame? + if(xiPrevFrameCount == currFrame) + { + r = true; + } + else + { + r = false; + xiUpdateAlreadyCalled = false; + } + + // Assign the previous frame count regardless of whether it's the same or not. + xiPrevFrameCount = currFrame; + + return r; + } + + + #endif + + // END of Windows only subsystem ========================================== + + + + // -------------------------- Handler Script ------------------- + + // Secret Private Script that does some maintainace work for XCI states. User should not use this script at all. + private class XciHandler : MonoBehaviour + { + private static XciHandler instance = null; + + public bool u3dTrigger0LeftIsTouched = false; + public bool u3dTrigger0RightIsTouched = false; + public bool u3dTrigger1LeftIsTouched = false; + public bool u3dTrigger1RightIsTouched = false; + public bool u3dTrigger2LeftIsTouched = false; + public bool u3dTrigger2RightIsTouched = false; + public bool u3dTrigger3LeftIsTouched = false; + public bool u3dTrigger3RightIsTouched = false; + public bool u3dTrigger4LeftIsTouched = false; + public bool u3dTrigger4RightIsTouched = false; + + void Awake() + { + if(XciHandler.instance != null) + { + GameObject.Destroy(this.gameObject); + } + + XciHandler.instance = this; + + // Lives for the life of the game + DontDestroyOnLoad(this.gameObject); + } + + void OnEnable() + { + SceneManager.sceneLoaded += OnSceneFinishedLoading; + } + + void OnDisable() + { + SceneManager.sceneLoaded -= OnSceneFinishedLoading; + } + + // Callback made to replace obsolete method OnLevelWasLoaded(int) + void OnSceneFinishedLoading(Scene currentScene, LoadSceneMode mode) + { + this.ResetTriggerTouches(); + } + + void OnApplicationFocus(bool isWindowInFocusNow) + { + if(!isWindowInFocusNow) + { + this.ResetTriggerTouches(); + } + } + + private void ResetTriggerTouches() + { + this.u3dTrigger0LeftIsTouched = false; + this.u3dTrigger0RightIsTouched = false; + this.u3dTrigger1LeftIsTouched = false; + this.u3dTrigger1RightIsTouched = false; + this.u3dTrigger2LeftIsTouched = false; + this.u3dTrigger2RightIsTouched = false; + this.u3dTrigger3LeftIsTouched = false; + this.u3dTrigger3RightIsTouched = false; + this.u3dTrigger4LeftIsTouched = false; + this.u3dTrigger4RightIsTouched = false; + } + + public static XciHandler Instance + { + get + { + if(XciHandler.instance == null) + { + GameObject xciHandleObj = new GameObject("XboxCtrlrInput Handler Object"); + xciHandleObj.AddComponent(); + } + + return XciHandler.instance; + } + } + } // end of XciHandler + } // end of XCI + + public static class XboxButtonExtensions + { + public static bool IsDPad(this XboxButton button) + { + return (button == XboxButton.DPadUp || + button == XboxButton.DPadDown || + button == XboxButton.DPadLeft || + button == XboxButton.DPadRight); + } + + public static XboxDPad ToDPad(this XboxButton button) + { + if (button == XboxButton.DPadUp) + return XboxDPad.Up; + if (button == XboxButton.DPadDown) + return XboxDPad.Down; + if (button == XboxButton.DPadLeft) + return XboxDPad.Left; + if (button == XboxButton.DPadRight) + return XboxDPad.Right; + return default(XboxDPad); + } + + + } + + +} diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta new file mode 100644 index 0000000..25d63aa --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 928025f6ea24748418044e4479b4c446 +timeCreated: 1572134135 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64.meta b/FallUnity/Assets/Plugins/x86_64.meta new file mode 100644 index 0000000..fb502ad --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9cd457a246db3a2458768c6d00ed39e6 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll new file mode 100644 index 0000000..8a2d764 --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta new file mode 100644 index 0000000..88fa34e --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta @@ -0,0 +1,95 @@ +fileFormatVersion: 2 +guid: ea895df4f09804d47ac0a43ce22418cb +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: ARMv7 + Any: + enabled: 1 + settings: + Exclude Android: 0 + Exclude Editor: 0 + Exclude Linux: 0 + Exclude Linux64: 0 + Exclude LinuxUniversal: 0 + Exclude OSXIntel: 0 + Exclude OSXIntel64: 0 + Exclude OSXUniversal: 0 + Exclude SamsungTV: 0 + Exclude Tizen: 0 + Exclude WebGL: 0 + Exclude Win: 1 + Exclude Win64: 0 + Exclude WindowsStoreApps: 0 + Exclude iOS: 0 + Editor: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 1 + settings: + CPU: None + Linux64: + enabled: 1 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel: + enabled: 1 + settings: + CPU: None + OSXIntel64: + enabled: 1 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 1 + settings: + CPU: AnyCPU + SamsungTV: + enabled: 1 + settings: + STV_MODEL: STANDARD_15 + Tizen: + enabled: 1 + settings: {} + WebGL: + enabled: 1 + settings: {} + Win: + enabled: 0 + settings: + CPU: None + Win64: + enabled: 1 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + iOS: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/RedDebug.mat b/FallUnity/Assets/RedDebug.mat new file mode 100644 index 0000000..7786680 --- /dev/null +++ b/FallUnity/Assets/RedDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: RedDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 0, b: 0, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/RedDebug.mat.meta b/FallUnity/Assets/RedDebug.mat.meta new file mode 100644 index 0000000..c65627f --- /dev/null +++ b/FallUnity/Assets/RedDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 30ca106f1a02e19498baabb238d01d50 +timeCreated: 1572133462 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta new file mode 100644 index 0000000..2d0e145 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ada75d1768d6fad4eb285bd538323380 +timeCreated: 1472582191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs new file mode 100644 index 0000000..1106813 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using XboxCtrlrInput; + +namespace PlayerInput +{ + public class XboxControllerInputSource : InputSource where TTarget : MonoBehaviour + { + private static List allControllers; + public static IEnumerable AllControllers { get { return allControllers; } } + static XboxControllerInputSource() + { + allControllers = new List() + { + XboxController.First, + XboxController.Second, + XboxController.Third, + XboxController.Fourth, + }; + } + + private Dictionary buttonMapping; + private Dictionary axisMapping; + + private XboxController controller; + public XboxController Controller { get { return controller; } } + + public XboxControllerInputSource(XboxController controller) + { + this.controller = controller; + + buttonMapping = new Dictionary() + { + { InputButton.MenuSelect, XboxButton.A }, + { InputButton.MenuCancel, XboxButton.B }, + + //{ InputButton.UseItem, XboxButton.A }, + //{ InputButton.PickA, XboxButton.LeftBumper }, + //{ InputButton.PickB, XboxButton.RightBumper }, + + //{ InputButton.AnimalSelector, XboxButton.LeftBumper }, + }; + + axisMapping = new Dictionary() + { + { InputAxis.MenuX, XboxAxis.LeftStickX }, + { InputAxis.MenuY, XboxAxis.LeftStickY }, + + { InputAxis.RakeX, XboxAxis.RightStickX }, + { InputAxis.RakeY, XboxAxis.RightStickY }, + + { InputAxis.MoveX, XboxAxis.LeftStickX }, + { InputAxis.MoveY, XboxAxis.LeftStickY }, + + //{ InputAxis.Throttle, XboxAxis.RightTrigger }, + //{ InputAxis.RevThrottle, XboxAxis.LeftTrigger }, + }; + } + + protected override void VibrateInternal(float left, float right) + { + XCI.SetVibration(controller, left, right); + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + return XCI.GetButtonDown(buttonMapping[button], controller); + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + return XCI.GetButtonUp(buttonMapping[button], controller); + } + + public override bool ButtonDown(InputButton button) + { + return XCI.GetButton(buttonMapping[button], controller); + } + + public override float Axis(InputAxis axis) + { + return XCI.GetAxis(axisMapping[axis], controller); + } + } +} diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta new file mode 100644 index 0000000..9f6859f --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ec7d070ee2898544aa46811e0e3da197 +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins.meta b/FallUnity/Assets/Plugins.meta new file mode 100644 index 0000000..b7025e8 --- /dev/null +++ b/FallUnity/Assets/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: dca2b803c244eb540bbf437959ae5f51 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll b/FallUnity/Assets/Plugins/XInputDotNetPure.dll new file mode 100644 index 0000000..d345520 --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta new file mode 100644 index 0000000..c87585b --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: a05c5d8086133f648a3dd3229d764a63 +timeCreated: 1572134134 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs new file mode 100644 index 0000000..69ee3a8 --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs @@ -0,0 +1,1969 @@ +using UnityEngine; +using UnityEngine.SceneManagement; + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN +using XInputDotNetPure; +#endif + +namespace XboxCtrlrInput +{ + + // ================= Enumerations ==================== // + + /// + /// List of enumerated identifiers for Xbox controllers. + /// + /// + /// Do NOT change enum values + /// + public enum XboxController + { + /// + /// "All" Controllers is deprecated! Use "Any" instead. + /// + [System.Obsolete("Instead use XboxController.Any")] + All = 0, + + Any = 0, + + First = 1, + Second = 2, + Third = 3, + Fourth = 4 + } + + /// + /// List of enumerated identifiers for Xbox buttons. + /// + public enum XboxButton + { + A, + B, + X, + Y, + Start, + Back, + LeftStick, + RightStick, + LeftBumper, + RightBumper, + DPadUp, + DPadDown, + DPadLeft, + DPadRight + } + + /// + /// List of enumerated identifiers for Xbox D-Pad directions. + /// + public enum XboxDPad + { + Up, + Down, + Left, + Right + } + + /// + /// List of enumerated identifiers for Xbox axis. + /// + public enum XboxAxis + { + LeftStickX, + LeftStickY, + RightStickX, + RightStickY, + LeftTrigger, + RightTrigger + } + + // ================ Classes =================== // + + public static class XCI + { + // ------------ Public Methods --------------- // + + public static bool SetVibration(XboxController controller, float left, float right) + { + + int controllerNumber = (int)controller; + + if (OnWindowsNative()) + { + GamePad.SetVibration((PlayerIndex)(controllerNumber - 1), left, right); + } + else + { + + } + + return false; + } + + // >>> For Buttons <<< // + + /// + /// Returns true if the specified button is held down by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButton(XboxButton button) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true if the specified button is held down by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButton(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButton(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonDown(XboxButton button) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonDown(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonDown(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonUp(XboxButton button) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonUp(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonUp(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + // >>> For D-Pad <<< // + + /// + /// Returns true if the specified D-Pad direction is pressed down by any controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + public static bool GetDPad(XboxDPad padDirection) + { + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, 0); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + /// + /// Returns true if the specified D-Pad direction is pressed down by a specified controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + /// + /// An identifier for the specific controller on which to test the D-Pad. + /// + public static bool GetDPad(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPad(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, controllerNumber); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadUp(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadUp(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadUp(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadDown(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadDown(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadDown(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // >>> For Axis <<< // + + /// + /// Returns the analog number of the specified axis from any controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxis(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxis(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxis(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from any controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxisRaw(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxisRaw(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxisRaw(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + // >>> Other important functions <<< // + + /// + /// Returns the number of Xbox controllers plugged to the computer. + /// + public static int GetNumPluggedCtrlrs() + { + int r = 0; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!xiNumOfCtrlrsQueried || !XInputStillInCurrFrame()) + { + xiNumOfCtrlrsQueried = true; + XInputUpdateAllStates(); + } + + for(int i = 0; i < 4; i++) + { + if(xInputCtrlrs[i].IsConnected) + { + r++; + } + } + #endif + } + + else + { + string[] ctrlrNames = Input.GetJoystickNames(); + for(int i = 0; i < ctrlrNames.Length; i++) + { + if(ctrlrNames[i].Contains("Xbox") || ctrlrNames[i].Contains("XBOX") || ctrlrNames[i].Contains("Microsoft")) + { + r++; + } + } + } + + return r; + } + + /// + /// DEBUG function. Log all controller names to Unity's console. + /// + public static void DEBUG_LogControllerNames() + { + string[] cNames = Input.GetJoystickNames(); + + for(int i = 0; i < cNames.Length; i++) + { + Debug.Log("Ctrlr " + i.ToString() + ": " + cNames[i]); + } + } + + + + + + // From @xoorath + /// + /// DEPRECATED: + /// Determines if the controller is plugged in the specified controllerNumber. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. An int between 1 and 4. + /// + [System.Obsolete("Instead use IsPluggedIn(XboxController)")] + public static bool IsPluggedIn(int controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + return ctrlrState.IsConnected; + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + // Based off @xoorath 's implementation + /// + /// Determines if the controller is plugged in the specified controllerNumber. + /// Passing Any will evaluate if any controller is connected. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// Passing Any will evaluate if any controller is connected. + /// + public static bool IsPluggedIn(XboxController controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + { + if (OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState; + + + // If inquiring about any controller + + // TODO: Remove condition for XboxController.All when the time comes + // Users of XCI: Feel free to remove XboxController.All if you like having no warnings + if(controllerNumber == XboxController.Any || controllerNumber == XboxController.All) + { + // Examine all controllers it see if any are connected + for(int i = 1; i <= 4; i++) + { + ctrlrState = XInputGetPaticularState(i); + if(ctrlrState.IsConnected) + { + return true; + } + } + } + + + // If specifying a specific controller + + // Note: Casting only works if XboxController enums are values 1 to 4 (First, Second, Third, Fourth) + ctrlrState = XInputGetPaticularState((int)controllerNumber); + + return ctrlrState.IsConnected; + } + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + + + //// + // ------------- Private -------------- // + //// + + // ------------ Methods --------------- // + + private static bool OnMac() + { + // All Mac mappings are based off TattieBogle Xbox Controller drivers + // http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver + // http://wiki.unity3d.com/index.php?title=Xbox360Controller + return (Application.platform == RuntimePlatform.OSXEditor || + Application.platform == RuntimePlatform.OSXPlayer ); + } + + private static bool OnWindows() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnWindowsNative() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnLinux() + { + // Linux mapping based on observation of mapping from default drivers on Ubuntu 13.04 + return Application.platform == RuntimePlatform.LinuxPlayer; + } + + private static bool IsControllerWireless() + { + // 0 means for any controller + return IsControllerWireless(0); + } + + private static bool IsControllerWireless(int ctrlNum) + { + if (ctrlNum < 0 || ctrlNum > 4) return false; + + // If 0 is passed in, that assumes that only 1 controller is plugged in. + if(ctrlNum == 0) + { + return ( (string) Input.GetJoystickNames()[0]).Contains("Wireless"); + } + + return ( (string) Input.GetJoystickNames()[ctrlNum-1]).Contains("Wireless"); + } + + private static bool IsControllerNumberValid(int ctrlrNum) + { + if(ctrlrNum > 0 && ctrlrNum <= 4) + { + return true; + } + else + { + Debug.LogError("XCI.IsControllerNumberValid(): " + + "Invalid contoller number! Should be between 1 and 4."); + } + return false; + } + + private static float RefactorRange(float oldRangeValue, int ctrlrNum, XboxAxis axis) + { + // HACK: On OS X, Left and right trigger under OSX return 0.5 until touched + // Issue #16 on Github: https://github.com/JISyed/Unity-XboxCtrlrInput/issues/16 + if(XCI.OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + else if(axis == XboxAxis.RightTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + } + + // Assumes you want to take a number from -1 to 1 range + // And turn it into a number from a 0 to 1 range + return ((oldRangeValue + 1.0f) / 2.0f ); + } + + private static string DetermineButtonCode(XboxButton btn, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sKeyCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + if(OnMac()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "16"; break; + case XboxButton.B: sKeyCode = "17"; break; + case XboxButton.X: sKeyCode = "18"; break; + case XboxButton.Y: sKeyCode = "19"; break; + case XboxButton.Start: sKeyCode = "9"; break; + case XboxButton.Back: sKeyCode = "10"; break; + case XboxButton.LeftStick: sKeyCode = "11"; break; + case XboxButton.RightStick: sKeyCode = "12"; break; + case XboxButton.LeftBumper: sKeyCode = "13"; break; + case XboxButton.RightBumper: sKeyCode = "14"; break; + + default: invalidCode = true; break; + } + } + else if (OnLinux()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "9"; break; + case XboxButton.RightStick: sKeyCode = "10"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "8"; break; + case XboxButton.RightStick: sKeyCode = "9"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + + r = "joystick" + sJoyCode + " button " + sKeyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineAxisCode(XboxAxis axs, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sAxisCode = ""; + bool invalidCode = false; + + + if(OnMac()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "3"; break; + case XboxAxis.RightStickY: sAxisCode = "4"; break; + case XboxAxis.LeftTrigger: sAxisCode = "5"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else if(OnLinux()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "3"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "9"; break; + case XboxAxis.RightTrigger: sAxisCode = "10"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sAxisCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static float AdjustAxisValues(float axisValue, XboxAxis axis, int ctrlrNum) + { + float newAxisValue = axisValue; + + if(OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = -newAxisValue; + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightStickY) + { + newAxisValue = -newAxisValue; + } + } + else if(OnLinux()) + { + if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + } + + return newAxisValue; + } + + private static string DetermineDPad(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sPadCode = ""; + bool invalidCode = false; + + if(OnLinux()) + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "8"; break; + case XboxDPad.Down: sPadCode = "8"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "7"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "7"; break; + case XboxDPad.Down: sPadCode = "7"; break; + case XboxDPad.Left: sPadCode = "6"; break; + case XboxDPad.Right: sPadCode = "6"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sPadCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadMac(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "5"; break; + case XboxDPad.Down: sPadCode = "6"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "8"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadWirelessLinux(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "13"; break; + case XboxDPad.Down: sPadCode = "14"; break; + case XboxDPad.Left: sPadCode = "11"; break; + case XboxDPad.Right: sPadCode = "12"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + + // ------------- Private XInput Wrappers (for Windows Native player and editor only) -------------- // + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + + // ------------ Inner Class ------------// + + // Used to setup XInput for Windows + class XciXInputInitializer + { + // Ctor + public XciXInputInitializer() + { + // Only runs once. + // Setup XInput here... + + + // Call input states twice in order to make sure that + // the previous states and current states are the same. + // This is needed to prevent errors where GetButtonUp will trigger unexpectledly + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + } + + public void Dummy() + { + // Intentionally does nothing to prevent warnings + } + } + + + + // ------------ Members --------------- // + + // Windows variables + private static GamePadState[] xInputCtrlrs = new GamePadState[4]; + private static GamePadState[] xInputCtrlrsPrev = new GamePadState[4]; + private static int xiPrevFrameCount = -1; + private static bool xiUpdateAlreadyCalled = false; + private static bool xiNumOfCtrlrsQueried = false; + private static XciXInputInitializer xinputInitalizer = new XCI.XciXInputInitializer(); + + + + // This can be set to something different if you want + private const GamePadDeadZone WindowsDeadzoneMethod = GamePadDeadZone.Circular; + + + + // ------------ Methods --------------- // + + //>> For updating states << + + private static void XInputUpdateAllStates() + { + if(xiUpdateAlreadyCalled) return; + + for(int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex) i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + xiUpdateAlreadyCalled = true; + } + + + //>> For getting states << + private static GamePadState XInputGetSingleState() + { + return xInputCtrlrs[0]; + } + + private static GamePadState XInputGetPaticularState(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrs[0]; + + return xInputCtrlrs[ctrlNum-1]; + } + + private static GamePadState XInputGetSingleStatePrev() + { + return xInputCtrlrsPrev[0]; + } + + private static GamePadState XInputGetPaticularStatePrev(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrsPrev[0]; + + return xInputCtrlrsPrev[ctrlNum-1]; + } + + //>> For getting input << + private static ButtonState XInputGetButtonState(GamePadButtons xiButtons, XboxButton xciBtn) + { + ButtonState stateToReturn = ButtonState.Pressed; + + switch(xciBtn) + { + case XboxButton.A: stateToReturn = xiButtons.A; break; + case XboxButton.B: stateToReturn = xiButtons.B; break; + case XboxButton.X: stateToReturn = xiButtons.X; break; + case XboxButton.Y: stateToReturn = xiButtons.Y; break; + case XboxButton.Start: stateToReturn = xiButtons.Start; break; + case XboxButton.Back: stateToReturn = xiButtons.Back; break; + case XboxButton.LeftBumper: stateToReturn = xiButtons.LeftShoulder; break; + case XboxButton.RightBumper: stateToReturn = xiButtons.RightShoulder; break; + case XboxButton.LeftStick: stateToReturn = xiButtons.LeftStick; break; + case XboxButton.RightStick: stateToReturn = xiButtons.RightStick; break; + } + + return stateToReturn; + } + + private static ButtonState XInputGetDPadState(GamePadDPad xiDPad, XboxDPad xciDPad) + { + ButtonState stateToReturn = ButtonState.Released; + + switch(xciDPad) + { + case XboxDPad.Up: stateToReturn = xiDPad.Up; break; + case XboxDPad.Down: stateToReturn = xiDPad.Down; break; + case XboxDPad.Left: stateToReturn = xiDPad.Left; break; + case XboxDPad.Right: stateToReturn = xiDPad.Right; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadTriggers xiTriggers, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftTrigger: stateToReturn = xiTriggers.Left; break; + case XboxAxis.RightTrigger: stateToReturn = xiTriggers.Right; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadThumbSticks xiThumbSticks, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftStickX: stateToReturn = xiThumbSticks.Left.X; break; + case XboxAxis.LeftStickY: stateToReturn = xiThumbSticks.Left.Y; break; + case XboxAxis.RightStickX: stateToReturn = xiThumbSticks.Right.X; break; + case XboxAxis.RightStickY: stateToReturn = xiThumbSticks.Right.Y; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static bool XInputStillInCurrFrame() + { + bool r = false; + xinputInitalizer.Dummy(); // Stop warnings about not using the initilaizer + + // Get the current frame + int currFrame = Time.frameCount; + + // Are we still in the current frame? + if(xiPrevFrameCount == currFrame) + { + r = true; + } + else + { + r = false; + xiUpdateAlreadyCalled = false; + } + + // Assign the previous frame count regardless of whether it's the same or not. + xiPrevFrameCount = currFrame; + + return r; + } + + + #endif + + // END of Windows only subsystem ========================================== + + + + // -------------------------- Handler Script ------------------- + + // Secret Private Script that does some maintainace work for XCI states. User should not use this script at all. + private class XciHandler : MonoBehaviour + { + private static XciHandler instance = null; + + public bool u3dTrigger0LeftIsTouched = false; + public bool u3dTrigger0RightIsTouched = false; + public bool u3dTrigger1LeftIsTouched = false; + public bool u3dTrigger1RightIsTouched = false; + public bool u3dTrigger2LeftIsTouched = false; + public bool u3dTrigger2RightIsTouched = false; + public bool u3dTrigger3LeftIsTouched = false; + public bool u3dTrigger3RightIsTouched = false; + public bool u3dTrigger4LeftIsTouched = false; + public bool u3dTrigger4RightIsTouched = false; + + void Awake() + { + if(XciHandler.instance != null) + { + GameObject.Destroy(this.gameObject); + } + + XciHandler.instance = this; + + // Lives for the life of the game + DontDestroyOnLoad(this.gameObject); + } + + void OnEnable() + { + SceneManager.sceneLoaded += OnSceneFinishedLoading; + } + + void OnDisable() + { + SceneManager.sceneLoaded -= OnSceneFinishedLoading; + } + + // Callback made to replace obsolete method OnLevelWasLoaded(int) + void OnSceneFinishedLoading(Scene currentScene, LoadSceneMode mode) + { + this.ResetTriggerTouches(); + } + + void OnApplicationFocus(bool isWindowInFocusNow) + { + if(!isWindowInFocusNow) + { + this.ResetTriggerTouches(); + } + } + + private void ResetTriggerTouches() + { + this.u3dTrigger0LeftIsTouched = false; + this.u3dTrigger0RightIsTouched = false; + this.u3dTrigger1LeftIsTouched = false; + this.u3dTrigger1RightIsTouched = false; + this.u3dTrigger2LeftIsTouched = false; + this.u3dTrigger2RightIsTouched = false; + this.u3dTrigger3LeftIsTouched = false; + this.u3dTrigger3RightIsTouched = false; + this.u3dTrigger4LeftIsTouched = false; + this.u3dTrigger4RightIsTouched = false; + } + + public static XciHandler Instance + { + get + { + if(XciHandler.instance == null) + { + GameObject xciHandleObj = new GameObject("XboxCtrlrInput Handler Object"); + xciHandleObj.AddComponent(); + } + + return XciHandler.instance; + } + } + } // end of XciHandler + } // end of XCI + + public static class XboxButtonExtensions + { + public static bool IsDPad(this XboxButton button) + { + return (button == XboxButton.DPadUp || + button == XboxButton.DPadDown || + button == XboxButton.DPadLeft || + button == XboxButton.DPadRight); + } + + public static XboxDPad ToDPad(this XboxButton button) + { + if (button == XboxButton.DPadUp) + return XboxDPad.Up; + if (button == XboxButton.DPadDown) + return XboxDPad.Down; + if (button == XboxButton.DPadLeft) + return XboxDPad.Left; + if (button == XboxButton.DPadRight) + return XboxDPad.Right; + return default(XboxDPad); + } + + + } + + +} diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta new file mode 100644 index 0000000..25d63aa --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 928025f6ea24748418044e4479b4c446 +timeCreated: 1572134135 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64.meta b/FallUnity/Assets/Plugins/x86_64.meta new file mode 100644 index 0000000..fb502ad --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9cd457a246db3a2458768c6d00ed39e6 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll new file mode 100644 index 0000000..8a2d764 --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta new file mode 100644 index 0000000..88fa34e --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta @@ -0,0 +1,95 @@ +fileFormatVersion: 2 +guid: ea895df4f09804d47ac0a43ce22418cb +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: ARMv7 + Any: + enabled: 1 + settings: + Exclude Android: 0 + Exclude Editor: 0 + Exclude Linux: 0 + Exclude Linux64: 0 + Exclude LinuxUniversal: 0 + Exclude OSXIntel: 0 + Exclude OSXIntel64: 0 + Exclude OSXUniversal: 0 + Exclude SamsungTV: 0 + Exclude Tizen: 0 + Exclude WebGL: 0 + Exclude Win: 1 + Exclude Win64: 0 + Exclude WindowsStoreApps: 0 + Exclude iOS: 0 + Editor: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 1 + settings: + CPU: None + Linux64: + enabled: 1 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel: + enabled: 1 + settings: + CPU: None + OSXIntel64: + enabled: 1 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 1 + settings: + CPU: AnyCPU + SamsungTV: + enabled: 1 + settings: + STV_MODEL: STANDARD_15 + Tizen: + enabled: 1 + settings: {} + WebGL: + enabled: 1 + settings: {} + Win: + enabled: 0 + settings: + CPU: None + Win64: + enabled: 1 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + iOS: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/RedDebug.mat b/FallUnity/Assets/RedDebug.mat new file mode 100644 index 0000000..7786680 --- /dev/null +++ b/FallUnity/Assets/RedDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: RedDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 0, b: 0, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/RedDebug.mat.meta b/FallUnity/Assets/RedDebug.mat.meta new file mode 100644 index 0000000..c65627f --- /dev/null +++ b/FallUnity/Assets/RedDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 30ca106f1a02e19498baabb238d01d50 +timeCreated: 1572133462 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/XboxCtrlrInput.meta b/FallUnity/Assets/XboxCtrlrInput.meta new file mode 100644 index 0000000..7b92c68 --- /dev/null +++ b/FallUnity/Assets/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 03c20217de43a304b9db30d8f9cf01af +folderAsset: yes +timeCreated: 1572134146 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta new file mode 100644 index 0000000..2d0e145 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ada75d1768d6fad4eb285bd538323380 +timeCreated: 1472582191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs new file mode 100644 index 0000000..1106813 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using XboxCtrlrInput; + +namespace PlayerInput +{ + public class XboxControllerInputSource : InputSource where TTarget : MonoBehaviour + { + private static List allControllers; + public static IEnumerable AllControllers { get { return allControllers; } } + static XboxControllerInputSource() + { + allControllers = new List() + { + XboxController.First, + XboxController.Second, + XboxController.Third, + XboxController.Fourth, + }; + } + + private Dictionary buttonMapping; + private Dictionary axisMapping; + + private XboxController controller; + public XboxController Controller { get { return controller; } } + + public XboxControllerInputSource(XboxController controller) + { + this.controller = controller; + + buttonMapping = new Dictionary() + { + { InputButton.MenuSelect, XboxButton.A }, + { InputButton.MenuCancel, XboxButton.B }, + + //{ InputButton.UseItem, XboxButton.A }, + //{ InputButton.PickA, XboxButton.LeftBumper }, + //{ InputButton.PickB, XboxButton.RightBumper }, + + //{ InputButton.AnimalSelector, XboxButton.LeftBumper }, + }; + + axisMapping = new Dictionary() + { + { InputAxis.MenuX, XboxAxis.LeftStickX }, + { InputAxis.MenuY, XboxAxis.LeftStickY }, + + { InputAxis.RakeX, XboxAxis.RightStickX }, + { InputAxis.RakeY, XboxAxis.RightStickY }, + + { InputAxis.MoveX, XboxAxis.LeftStickX }, + { InputAxis.MoveY, XboxAxis.LeftStickY }, + + //{ InputAxis.Throttle, XboxAxis.RightTrigger }, + //{ InputAxis.RevThrottle, XboxAxis.LeftTrigger }, + }; + } + + protected override void VibrateInternal(float left, float right) + { + XCI.SetVibration(controller, left, right); + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + return XCI.GetButtonDown(buttonMapping[button], controller); + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + return XCI.GetButtonUp(buttonMapping[button], controller); + } + + public override bool ButtonDown(InputButton button) + { + return XCI.GetButton(buttonMapping[button], controller); + } + + public override float Axis(InputAxis axis) + { + return XCI.GetAxis(axisMapping[axis], controller); + } + } +} diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta new file mode 100644 index 0000000..9f6859f --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ec7d070ee2898544aa46811e0e3da197 +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins.meta b/FallUnity/Assets/Plugins.meta new file mode 100644 index 0000000..b7025e8 --- /dev/null +++ b/FallUnity/Assets/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: dca2b803c244eb540bbf437959ae5f51 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll b/FallUnity/Assets/Plugins/XInputDotNetPure.dll new file mode 100644 index 0000000..d345520 --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta new file mode 100644 index 0000000..c87585b --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: a05c5d8086133f648a3dd3229d764a63 +timeCreated: 1572134134 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs new file mode 100644 index 0000000..69ee3a8 --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs @@ -0,0 +1,1969 @@ +using UnityEngine; +using UnityEngine.SceneManagement; + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN +using XInputDotNetPure; +#endif + +namespace XboxCtrlrInput +{ + + // ================= Enumerations ==================== // + + /// + /// List of enumerated identifiers for Xbox controllers. + /// + /// + /// Do NOT change enum values + /// + public enum XboxController + { + /// + /// "All" Controllers is deprecated! Use "Any" instead. + /// + [System.Obsolete("Instead use XboxController.Any")] + All = 0, + + Any = 0, + + First = 1, + Second = 2, + Third = 3, + Fourth = 4 + } + + /// + /// List of enumerated identifiers for Xbox buttons. + /// + public enum XboxButton + { + A, + B, + X, + Y, + Start, + Back, + LeftStick, + RightStick, + LeftBumper, + RightBumper, + DPadUp, + DPadDown, + DPadLeft, + DPadRight + } + + /// + /// List of enumerated identifiers for Xbox D-Pad directions. + /// + public enum XboxDPad + { + Up, + Down, + Left, + Right + } + + /// + /// List of enumerated identifiers for Xbox axis. + /// + public enum XboxAxis + { + LeftStickX, + LeftStickY, + RightStickX, + RightStickY, + LeftTrigger, + RightTrigger + } + + // ================ Classes =================== // + + public static class XCI + { + // ------------ Public Methods --------------- // + + public static bool SetVibration(XboxController controller, float left, float right) + { + + int controllerNumber = (int)controller; + + if (OnWindowsNative()) + { + GamePad.SetVibration((PlayerIndex)(controllerNumber - 1), left, right); + } + else + { + + } + + return false; + } + + // >>> For Buttons <<< // + + /// + /// Returns true if the specified button is held down by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButton(XboxButton button) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true if the specified button is held down by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButton(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButton(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonDown(XboxButton button) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonDown(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonDown(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonUp(XboxButton button) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonUp(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonUp(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + // >>> For D-Pad <<< // + + /// + /// Returns true if the specified D-Pad direction is pressed down by any controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + public static bool GetDPad(XboxDPad padDirection) + { + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, 0); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + /// + /// Returns true if the specified D-Pad direction is pressed down by a specified controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + /// + /// An identifier for the specific controller on which to test the D-Pad. + /// + public static bool GetDPad(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPad(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, controllerNumber); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadUp(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadUp(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadUp(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadDown(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadDown(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadDown(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // >>> For Axis <<< // + + /// + /// Returns the analog number of the specified axis from any controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxis(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxis(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxis(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from any controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxisRaw(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxisRaw(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxisRaw(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + // >>> Other important functions <<< // + + /// + /// Returns the number of Xbox controllers plugged to the computer. + /// + public static int GetNumPluggedCtrlrs() + { + int r = 0; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!xiNumOfCtrlrsQueried || !XInputStillInCurrFrame()) + { + xiNumOfCtrlrsQueried = true; + XInputUpdateAllStates(); + } + + for(int i = 0; i < 4; i++) + { + if(xInputCtrlrs[i].IsConnected) + { + r++; + } + } + #endif + } + + else + { + string[] ctrlrNames = Input.GetJoystickNames(); + for(int i = 0; i < ctrlrNames.Length; i++) + { + if(ctrlrNames[i].Contains("Xbox") || ctrlrNames[i].Contains("XBOX") || ctrlrNames[i].Contains("Microsoft")) + { + r++; + } + } + } + + return r; + } + + /// + /// DEBUG function. Log all controller names to Unity's console. + /// + public static void DEBUG_LogControllerNames() + { + string[] cNames = Input.GetJoystickNames(); + + for(int i = 0; i < cNames.Length; i++) + { + Debug.Log("Ctrlr " + i.ToString() + ": " + cNames[i]); + } + } + + + + + + // From @xoorath + /// + /// DEPRECATED: + /// Determines if the controller is plugged in the specified controllerNumber. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. An int between 1 and 4. + /// + [System.Obsolete("Instead use IsPluggedIn(XboxController)")] + public static bool IsPluggedIn(int controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + return ctrlrState.IsConnected; + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + // Based off @xoorath 's implementation + /// + /// Determines if the controller is plugged in the specified controllerNumber. + /// Passing Any will evaluate if any controller is connected. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// Passing Any will evaluate if any controller is connected. + /// + public static bool IsPluggedIn(XboxController controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + { + if (OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState; + + + // If inquiring about any controller + + // TODO: Remove condition for XboxController.All when the time comes + // Users of XCI: Feel free to remove XboxController.All if you like having no warnings + if(controllerNumber == XboxController.Any || controllerNumber == XboxController.All) + { + // Examine all controllers it see if any are connected + for(int i = 1; i <= 4; i++) + { + ctrlrState = XInputGetPaticularState(i); + if(ctrlrState.IsConnected) + { + return true; + } + } + } + + + // If specifying a specific controller + + // Note: Casting only works if XboxController enums are values 1 to 4 (First, Second, Third, Fourth) + ctrlrState = XInputGetPaticularState((int)controllerNumber); + + return ctrlrState.IsConnected; + } + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + + + //// + // ------------- Private -------------- // + //// + + // ------------ Methods --------------- // + + private static bool OnMac() + { + // All Mac mappings are based off TattieBogle Xbox Controller drivers + // http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver + // http://wiki.unity3d.com/index.php?title=Xbox360Controller + return (Application.platform == RuntimePlatform.OSXEditor || + Application.platform == RuntimePlatform.OSXPlayer ); + } + + private static bool OnWindows() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnWindowsNative() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnLinux() + { + // Linux mapping based on observation of mapping from default drivers on Ubuntu 13.04 + return Application.platform == RuntimePlatform.LinuxPlayer; + } + + private static bool IsControllerWireless() + { + // 0 means for any controller + return IsControllerWireless(0); + } + + private static bool IsControllerWireless(int ctrlNum) + { + if (ctrlNum < 0 || ctrlNum > 4) return false; + + // If 0 is passed in, that assumes that only 1 controller is plugged in. + if(ctrlNum == 0) + { + return ( (string) Input.GetJoystickNames()[0]).Contains("Wireless"); + } + + return ( (string) Input.GetJoystickNames()[ctrlNum-1]).Contains("Wireless"); + } + + private static bool IsControllerNumberValid(int ctrlrNum) + { + if(ctrlrNum > 0 && ctrlrNum <= 4) + { + return true; + } + else + { + Debug.LogError("XCI.IsControllerNumberValid(): " + + "Invalid contoller number! Should be between 1 and 4."); + } + return false; + } + + private static float RefactorRange(float oldRangeValue, int ctrlrNum, XboxAxis axis) + { + // HACK: On OS X, Left and right trigger under OSX return 0.5 until touched + // Issue #16 on Github: https://github.com/JISyed/Unity-XboxCtrlrInput/issues/16 + if(XCI.OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + else if(axis == XboxAxis.RightTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + } + + // Assumes you want to take a number from -1 to 1 range + // And turn it into a number from a 0 to 1 range + return ((oldRangeValue + 1.0f) / 2.0f ); + } + + private static string DetermineButtonCode(XboxButton btn, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sKeyCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + if(OnMac()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "16"; break; + case XboxButton.B: sKeyCode = "17"; break; + case XboxButton.X: sKeyCode = "18"; break; + case XboxButton.Y: sKeyCode = "19"; break; + case XboxButton.Start: sKeyCode = "9"; break; + case XboxButton.Back: sKeyCode = "10"; break; + case XboxButton.LeftStick: sKeyCode = "11"; break; + case XboxButton.RightStick: sKeyCode = "12"; break; + case XboxButton.LeftBumper: sKeyCode = "13"; break; + case XboxButton.RightBumper: sKeyCode = "14"; break; + + default: invalidCode = true; break; + } + } + else if (OnLinux()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "9"; break; + case XboxButton.RightStick: sKeyCode = "10"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "8"; break; + case XboxButton.RightStick: sKeyCode = "9"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + + r = "joystick" + sJoyCode + " button " + sKeyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineAxisCode(XboxAxis axs, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sAxisCode = ""; + bool invalidCode = false; + + + if(OnMac()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "3"; break; + case XboxAxis.RightStickY: sAxisCode = "4"; break; + case XboxAxis.LeftTrigger: sAxisCode = "5"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else if(OnLinux()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "3"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "9"; break; + case XboxAxis.RightTrigger: sAxisCode = "10"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sAxisCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static float AdjustAxisValues(float axisValue, XboxAxis axis, int ctrlrNum) + { + float newAxisValue = axisValue; + + if(OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = -newAxisValue; + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightStickY) + { + newAxisValue = -newAxisValue; + } + } + else if(OnLinux()) + { + if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + } + + return newAxisValue; + } + + private static string DetermineDPad(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sPadCode = ""; + bool invalidCode = false; + + if(OnLinux()) + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "8"; break; + case XboxDPad.Down: sPadCode = "8"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "7"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "7"; break; + case XboxDPad.Down: sPadCode = "7"; break; + case XboxDPad.Left: sPadCode = "6"; break; + case XboxDPad.Right: sPadCode = "6"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sPadCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadMac(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "5"; break; + case XboxDPad.Down: sPadCode = "6"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "8"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadWirelessLinux(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "13"; break; + case XboxDPad.Down: sPadCode = "14"; break; + case XboxDPad.Left: sPadCode = "11"; break; + case XboxDPad.Right: sPadCode = "12"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + + // ------------- Private XInput Wrappers (for Windows Native player and editor only) -------------- // + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + + // ------------ Inner Class ------------// + + // Used to setup XInput for Windows + class XciXInputInitializer + { + // Ctor + public XciXInputInitializer() + { + // Only runs once. + // Setup XInput here... + + + // Call input states twice in order to make sure that + // the previous states and current states are the same. + // This is needed to prevent errors where GetButtonUp will trigger unexpectledly + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + } + + public void Dummy() + { + // Intentionally does nothing to prevent warnings + } + } + + + + // ------------ Members --------------- // + + // Windows variables + private static GamePadState[] xInputCtrlrs = new GamePadState[4]; + private static GamePadState[] xInputCtrlrsPrev = new GamePadState[4]; + private static int xiPrevFrameCount = -1; + private static bool xiUpdateAlreadyCalled = false; + private static bool xiNumOfCtrlrsQueried = false; + private static XciXInputInitializer xinputInitalizer = new XCI.XciXInputInitializer(); + + + + // This can be set to something different if you want + private const GamePadDeadZone WindowsDeadzoneMethod = GamePadDeadZone.Circular; + + + + // ------------ Methods --------------- // + + //>> For updating states << + + private static void XInputUpdateAllStates() + { + if(xiUpdateAlreadyCalled) return; + + for(int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex) i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + xiUpdateAlreadyCalled = true; + } + + + //>> For getting states << + private static GamePadState XInputGetSingleState() + { + return xInputCtrlrs[0]; + } + + private static GamePadState XInputGetPaticularState(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrs[0]; + + return xInputCtrlrs[ctrlNum-1]; + } + + private static GamePadState XInputGetSingleStatePrev() + { + return xInputCtrlrsPrev[0]; + } + + private static GamePadState XInputGetPaticularStatePrev(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrsPrev[0]; + + return xInputCtrlrsPrev[ctrlNum-1]; + } + + //>> For getting input << + private static ButtonState XInputGetButtonState(GamePadButtons xiButtons, XboxButton xciBtn) + { + ButtonState stateToReturn = ButtonState.Pressed; + + switch(xciBtn) + { + case XboxButton.A: stateToReturn = xiButtons.A; break; + case XboxButton.B: stateToReturn = xiButtons.B; break; + case XboxButton.X: stateToReturn = xiButtons.X; break; + case XboxButton.Y: stateToReturn = xiButtons.Y; break; + case XboxButton.Start: stateToReturn = xiButtons.Start; break; + case XboxButton.Back: stateToReturn = xiButtons.Back; break; + case XboxButton.LeftBumper: stateToReturn = xiButtons.LeftShoulder; break; + case XboxButton.RightBumper: stateToReturn = xiButtons.RightShoulder; break; + case XboxButton.LeftStick: stateToReturn = xiButtons.LeftStick; break; + case XboxButton.RightStick: stateToReturn = xiButtons.RightStick; break; + } + + return stateToReturn; + } + + private static ButtonState XInputGetDPadState(GamePadDPad xiDPad, XboxDPad xciDPad) + { + ButtonState stateToReturn = ButtonState.Released; + + switch(xciDPad) + { + case XboxDPad.Up: stateToReturn = xiDPad.Up; break; + case XboxDPad.Down: stateToReturn = xiDPad.Down; break; + case XboxDPad.Left: stateToReturn = xiDPad.Left; break; + case XboxDPad.Right: stateToReturn = xiDPad.Right; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadTriggers xiTriggers, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftTrigger: stateToReturn = xiTriggers.Left; break; + case XboxAxis.RightTrigger: stateToReturn = xiTriggers.Right; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadThumbSticks xiThumbSticks, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftStickX: stateToReturn = xiThumbSticks.Left.X; break; + case XboxAxis.LeftStickY: stateToReturn = xiThumbSticks.Left.Y; break; + case XboxAxis.RightStickX: stateToReturn = xiThumbSticks.Right.X; break; + case XboxAxis.RightStickY: stateToReturn = xiThumbSticks.Right.Y; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static bool XInputStillInCurrFrame() + { + bool r = false; + xinputInitalizer.Dummy(); // Stop warnings about not using the initilaizer + + // Get the current frame + int currFrame = Time.frameCount; + + // Are we still in the current frame? + if(xiPrevFrameCount == currFrame) + { + r = true; + } + else + { + r = false; + xiUpdateAlreadyCalled = false; + } + + // Assign the previous frame count regardless of whether it's the same or not. + xiPrevFrameCount = currFrame; + + return r; + } + + + #endif + + // END of Windows only subsystem ========================================== + + + + // -------------------------- Handler Script ------------------- + + // Secret Private Script that does some maintainace work for XCI states. User should not use this script at all. + private class XciHandler : MonoBehaviour + { + private static XciHandler instance = null; + + public bool u3dTrigger0LeftIsTouched = false; + public bool u3dTrigger0RightIsTouched = false; + public bool u3dTrigger1LeftIsTouched = false; + public bool u3dTrigger1RightIsTouched = false; + public bool u3dTrigger2LeftIsTouched = false; + public bool u3dTrigger2RightIsTouched = false; + public bool u3dTrigger3LeftIsTouched = false; + public bool u3dTrigger3RightIsTouched = false; + public bool u3dTrigger4LeftIsTouched = false; + public bool u3dTrigger4RightIsTouched = false; + + void Awake() + { + if(XciHandler.instance != null) + { + GameObject.Destroy(this.gameObject); + } + + XciHandler.instance = this; + + // Lives for the life of the game + DontDestroyOnLoad(this.gameObject); + } + + void OnEnable() + { + SceneManager.sceneLoaded += OnSceneFinishedLoading; + } + + void OnDisable() + { + SceneManager.sceneLoaded -= OnSceneFinishedLoading; + } + + // Callback made to replace obsolete method OnLevelWasLoaded(int) + void OnSceneFinishedLoading(Scene currentScene, LoadSceneMode mode) + { + this.ResetTriggerTouches(); + } + + void OnApplicationFocus(bool isWindowInFocusNow) + { + if(!isWindowInFocusNow) + { + this.ResetTriggerTouches(); + } + } + + private void ResetTriggerTouches() + { + this.u3dTrigger0LeftIsTouched = false; + this.u3dTrigger0RightIsTouched = false; + this.u3dTrigger1LeftIsTouched = false; + this.u3dTrigger1RightIsTouched = false; + this.u3dTrigger2LeftIsTouched = false; + this.u3dTrigger2RightIsTouched = false; + this.u3dTrigger3LeftIsTouched = false; + this.u3dTrigger3RightIsTouched = false; + this.u3dTrigger4LeftIsTouched = false; + this.u3dTrigger4RightIsTouched = false; + } + + public static XciHandler Instance + { + get + { + if(XciHandler.instance == null) + { + GameObject xciHandleObj = new GameObject("XboxCtrlrInput Handler Object"); + xciHandleObj.AddComponent(); + } + + return XciHandler.instance; + } + } + } // end of XciHandler + } // end of XCI + + public static class XboxButtonExtensions + { + public static bool IsDPad(this XboxButton button) + { + return (button == XboxButton.DPadUp || + button == XboxButton.DPadDown || + button == XboxButton.DPadLeft || + button == XboxButton.DPadRight); + } + + public static XboxDPad ToDPad(this XboxButton button) + { + if (button == XboxButton.DPadUp) + return XboxDPad.Up; + if (button == XboxButton.DPadDown) + return XboxDPad.Down; + if (button == XboxButton.DPadLeft) + return XboxDPad.Left; + if (button == XboxButton.DPadRight) + return XboxDPad.Right; + return default(XboxDPad); + } + + + } + + +} diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta new file mode 100644 index 0000000..25d63aa --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 928025f6ea24748418044e4479b4c446 +timeCreated: 1572134135 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64.meta b/FallUnity/Assets/Plugins/x86_64.meta new file mode 100644 index 0000000..fb502ad --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9cd457a246db3a2458768c6d00ed39e6 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll new file mode 100644 index 0000000..8a2d764 --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta new file mode 100644 index 0000000..88fa34e --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta @@ -0,0 +1,95 @@ +fileFormatVersion: 2 +guid: ea895df4f09804d47ac0a43ce22418cb +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: ARMv7 + Any: + enabled: 1 + settings: + Exclude Android: 0 + Exclude Editor: 0 + Exclude Linux: 0 + Exclude Linux64: 0 + Exclude LinuxUniversal: 0 + Exclude OSXIntel: 0 + Exclude OSXIntel64: 0 + Exclude OSXUniversal: 0 + Exclude SamsungTV: 0 + Exclude Tizen: 0 + Exclude WebGL: 0 + Exclude Win: 1 + Exclude Win64: 0 + Exclude WindowsStoreApps: 0 + Exclude iOS: 0 + Editor: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 1 + settings: + CPU: None + Linux64: + enabled: 1 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel: + enabled: 1 + settings: + CPU: None + OSXIntel64: + enabled: 1 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 1 + settings: + CPU: AnyCPU + SamsungTV: + enabled: 1 + settings: + STV_MODEL: STANDARD_15 + Tizen: + enabled: 1 + settings: {} + WebGL: + enabled: 1 + settings: {} + Win: + enabled: 0 + settings: + CPU: None + Win64: + enabled: 1 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + iOS: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/RedDebug.mat b/FallUnity/Assets/RedDebug.mat new file mode 100644 index 0000000..7786680 --- /dev/null +++ b/FallUnity/Assets/RedDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: RedDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 0, b: 0, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/RedDebug.mat.meta b/FallUnity/Assets/RedDebug.mat.meta new file mode 100644 index 0000000..c65627f --- /dev/null +++ b/FallUnity/Assets/RedDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 30ca106f1a02e19498baabb238d01d50 +timeCreated: 1572133462 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/XboxCtrlrInput.meta b/FallUnity/Assets/XboxCtrlrInput.meta new file mode 100644 index 0000000..7b92c68 --- /dev/null +++ b/FallUnity/Assets/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 03c20217de43a304b9db30d8f9cf01af +folderAsset: yes +timeCreated: 1572134146 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/level.unity b/FallUnity/Assets/level.unity index eee2288..6f0f3c1 100755 --- a/FallUnity/Assets/level.unity +++ b/FallUnity/Assets/level.unity @@ -223,6 +223,8 @@ m_Script: {fileID: 11500000, guid: e9e45b67a184f38439d0136610b1d1cb, type: 3} m_Name: m_EditorClassIdentifier: + ChunksX: 20 + ChunksY: 20 --- !u!1 &257733088 GameObject: m_ObjectHideFlags: 0 @@ -365,9 +367,12 @@ m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - ManualDepth: 1 - Depth: 995 + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 LinkedImage: {fileID: 1777425976} + IsoRadius: 0 + IsoPerspective: 0 + IsoType: 1 --- !u!1 &418505720 GameObject: m_ObjectHideFlags: 0 @@ -405,14 +410,14 @@ m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 418505720} - m_Enabled: 1 + m_Enabled: 0 --- !u!124 &418505723 Behaviour: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 418505720} - m_Enabled: 1 + m_Enabled: 0 --- !u!20 &418505724 Camera: m_ObjectHideFlags: 0 @@ -744,7 +749,7 @@ m_GameObject: {fileID: 1076119174} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0.08, y: -0.41, z: -3.74} - m_LocalScale: {x: 13.190122, y: 1.2632968, z: 0.18388264} + m_LocalScale: {x: 13.190122, y: 1.7437512, z: 0.18388264} m_Children: [] m_Father: {fileID: 468371543} m_RootOrder: 0 @@ -763,7 +768,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: d76887554d5b2e441b3ecb5e4e52b392, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -813,9 +818,12 @@ m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - ManualDepth: 0 - Depth: 0 + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 LinkedImage: {fileID: 1548969793} + IsoRadius: 0 + IsoPerspective: 0 + IsoType: 1 --- !u!1 &1206131915 GameObject: m_ObjectHideFlags: 0 @@ -857,7 +865,7 @@ m_Name: m_EditorClassIdentifier: Radius: 5 - Rate: 52.6 + Rate: 33.04 Leaf: {fileID: 114579094665962866, guid: 1701be1f15e160d4d904862548ae69de, type: 2} --- !u!1 &1272122407 GameObject: @@ -988,7 +996,7 @@ m_Depth: 0 m_CullingMask: serializedVersion: 2 - m_Bits: 4294964479 + m_Bits: 4294952191 m_RenderingPath: -1 m_TargetTexture: {fileID: 0} m_TargetDisplay: 0 @@ -1174,6 +1182,48 @@ m_Father: {fileID: 257733089} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1774596164 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1774596166} + - component: {fileID: 1774596165} + m_Layer: 0 + m_Name: InputManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1774596165 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1774596164} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 33ec797898b03244e94c917f9503fe39, type: 3} + m_Name: + m_EditorClassIdentifier: + PlayerPrefab: {fileID: 114770286734950254, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, + type: 2} +--- !u!4 &1774596166 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1774596164} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 24.684563, z: -35.583923} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1777425976 GameObject: m_ObjectHideFlags: 0 @@ -1242,15 +1292,15 @@ m_Modifications: - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} propertyPath: m_LocalPosition.x - value: 0.55 + value: -2.25 objectReference: {fileID: 0} - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} propertyPath: m_LocalPosition.y - value: -1 + value: -0.84 objectReference: {fileID: 0} - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} propertyPath: m_LocalPosition.z - value: 0.24 + value: -1.05 objectReference: {fileID: 0} - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} propertyPath: m_LocalRotation.x @@ -1272,19 +1322,6 @@ propertyPath: m_RootOrder value: 5 objectReference: {fileID: 0} - - target: {fileID: 114432391297954942, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, - type: 2} - propertyPath: PixelScale - value: 0.01 - objectReference: {fileID: 0} - - target: {fileID: 1217361112803688, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} - propertyPath: m_Layer - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1127561252628422, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} - propertyPath: m_IsActive - value: 0 - objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} m_IsPrefabParent: 0 diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta new file mode 100644 index 0000000..2d0e145 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ada75d1768d6fad4eb285bd538323380 +timeCreated: 1472582191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs new file mode 100644 index 0000000..1106813 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using XboxCtrlrInput; + +namespace PlayerInput +{ + public class XboxControllerInputSource : InputSource where TTarget : MonoBehaviour + { + private static List allControllers; + public static IEnumerable AllControllers { get { return allControllers; } } + static XboxControllerInputSource() + { + allControllers = new List() + { + XboxController.First, + XboxController.Second, + XboxController.Third, + XboxController.Fourth, + }; + } + + private Dictionary buttonMapping; + private Dictionary axisMapping; + + private XboxController controller; + public XboxController Controller { get { return controller; } } + + public XboxControllerInputSource(XboxController controller) + { + this.controller = controller; + + buttonMapping = new Dictionary() + { + { InputButton.MenuSelect, XboxButton.A }, + { InputButton.MenuCancel, XboxButton.B }, + + //{ InputButton.UseItem, XboxButton.A }, + //{ InputButton.PickA, XboxButton.LeftBumper }, + //{ InputButton.PickB, XboxButton.RightBumper }, + + //{ InputButton.AnimalSelector, XboxButton.LeftBumper }, + }; + + axisMapping = new Dictionary() + { + { InputAxis.MenuX, XboxAxis.LeftStickX }, + { InputAxis.MenuY, XboxAxis.LeftStickY }, + + { InputAxis.RakeX, XboxAxis.RightStickX }, + { InputAxis.RakeY, XboxAxis.RightStickY }, + + { InputAxis.MoveX, XboxAxis.LeftStickX }, + { InputAxis.MoveY, XboxAxis.LeftStickY }, + + //{ InputAxis.Throttle, XboxAxis.RightTrigger }, + //{ InputAxis.RevThrottle, XboxAxis.LeftTrigger }, + }; + } + + protected override void VibrateInternal(float left, float right) + { + XCI.SetVibration(controller, left, right); + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + return XCI.GetButtonDown(buttonMapping[button], controller); + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + return XCI.GetButtonUp(buttonMapping[button], controller); + } + + public override bool ButtonDown(InputButton button) + { + return XCI.GetButton(buttonMapping[button], controller); + } + + public override float Axis(InputAxis axis) + { + return XCI.GetAxis(axisMapping[axis], controller); + } + } +} diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta new file mode 100644 index 0000000..9f6859f --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ec7d070ee2898544aa46811e0e3da197 +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins.meta b/FallUnity/Assets/Plugins.meta new file mode 100644 index 0000000..b7025e8 --- /dev/null +++ b/FallUnity/Assets/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: dca2b803c244eb540bbf437959ae5f51 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll b/FallUnity/Assets/Plugins/XInputDotNetPure.dll new file mode 100644 index 0000000..d345520 --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta new file mode 100644 index 0000000..c87585b --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: a05c5d8086133f648a3dd3229d764a63 +timeCreated: 1572134134 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs new file mode 100644 index 0000000..69ee3a8 --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs @@ -0,0 +1,1969 @@ +using UnityEngine; +using UnityEngine.SceneManagement; + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN +using XInputDotNetPure; +#endif + +namespace XboxCtrlrInput +{ + + // ================= Enumerations ==================== // + + /// + /// List of enumerated identifiers for Xbox controllers. + /// + /// + /// Do NOT change enum values + /// + public enum XboxController + { + /// + /// "All" Controllers is deprecated! Use "Any" instead. + /// + [System.Obsolete("Instead use XboxController.Any")] + All = 0, + + Any = 0, + + First = 1, + Second = 2, + Third = 3, + Fourth = 4 + } + + /// + /// List of enumerated identifiers for Xbox buttons. + /// + public enum XboxButton + { + A, + B, + X, + Y, + Start, + Back, + LeftStick, + RightStick, + LeftBumper, + RightBumper, + DPadUp, + DPadDown, + DPadLeft, + DPadRight + } + + /// + /// List of enumerated identifiers for Xbox D-Pad directions. + /// + public enum XboxDPad + { + Up, + Down, + Left, + Right + } + + /// + /// List of enumerated identifiers for Xbox axis. + /// + public enum XboxAxis + { + LeftStickX, + LeftStickY, + RightStickX, + RightStickY, + LeftTrigger, + RightTrigger + } + + // ================ Classes =================== // + + public static class XCI + { + // ------------ Public Methods --------------- // + + public static bool SetVibration(XboxController controller, float left, float right) + { + + int controllerNumber = (int)controller; + + if (OnWindowsNative()) + { + GamePad.SetVibration((PlayerIndex)(controllerNumber - 1), left, right); + } + else + { + + } + + return false; + } + + // >>> For Buttons <<< // + + /// + /// Returns true if the specified button is held down by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButton(XboxButton button) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true if the specified button is held down by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButton(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButton(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonDown(XboxButton button) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonDown(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonDown(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonUp(XboxButton button) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonUp(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonUp(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + // >>> For D-Pad <<< // + + /// + /// Returns true if the specified D-Pad direction is pressed down by any controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + public static bool GetDPad(XboxDPad padDirection) + { + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, 0); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + /// + /// Returns true if the specified D-Pad direction is pressed down by a specified controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + /// + /// An identifier for the specific controller on which to test the D-Pad. + /// + public static bool GetDPad(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPad(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, controllerNumber); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadUp(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadUp(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadUp(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadDown(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadDown(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadDown(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // >>> For Axis <<< // + + /// + /// Returns the analog number of the specified axis from any controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxis(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxis(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxis(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from any controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxisRaw(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxisRaw(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxisRaw(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + // >>> Other important functions <<< // + + /// + /// Returns the number of Xbox controllers plugged to the computer. + /// + public static int GetNumPluggedCtrlrs() + { + int r = 0; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!xiNumOfCtrlrsQueried || !XInputStillInCurrFrame()) + { + xiNumOfCtrlrsQueried = true; + XInputUpdateAllStates(); + } + + for(int i = 0; i < 4; i++) + { + if(xInputCtrlrs[i].IsConnected) + { + r++; + } + } + #endif + } + + else + { + string[] ctrlrNames = Input.GetJoystickNames(); + for(int i = 0; i < ctrlrNames.Length; i++) + { + if(ctrlrNames[i].Contains("Xbox") || ctrlrNames[i].Contains("XBOX") || ctrlrNames[i].Contains("Microsoft")) + { + r++; + } + } + } + + return r; + } + + /// + /// DEBUG function. Log all controller names to Unity's console. + /// + public static void DEBUG_LogControllerNames() + { + string[] cNames = Input.GetJoystickNames(); + + for(int i = 0; i < cNames.Length; i++) + { + Debug.Log("Ctrlr " + i.ToString() + ": " + cNames[i]); + } + } + + + + + + // From @xoorath + /// + /// DEPRECATED: + /// Determines if the controller is plugged in the specified controllerNumber. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. An int between 1 and 4. + /// + [System.Obsolete("Instead use IsPluggedIn(XboxController)")] + public static bool IsPluggedIn(int controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + return ctrlrState.IsConnected; + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + // Based off @xoorath 's implementation + /// + /// Determines if the controller is plugged in the specified controllerNumber. + /// Passing Any will evaluate if any controller is connected. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// Passing Any will evaluate if any controller is connected. + /// + public static bool IsPluggedIn(XboxController controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + { + if (OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState; + + + // If inquiring about any controller + + // TODO: Remove condition for XboxController.All when the time comes + // Users of XCI: Feel free to remove XboxController.All if you like having no warnings + if(controllerNumber == XboxController.Any || controllerNumber == XboxController.All) + { + // Examine all controllers it see if any are connected + for(int i = 1; i <= 4; i++) + { + ctrlrState = XInputGetPaticularState(i); + if(ctrlrState.IsConnected) + { + return true; + } + } + } + + + // If specifying a specific controller + + // Note: Casting only works if XboxController enums are values 1 to 4 (First, Second, Third, Fourth) + ctrlrState = XInputGetPaticularState((int)controllerNumber); + + return ctrlrState.IsConnected; + } + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + + + //// + // ------------- Private -------------- // + //// + + // ------------ Methods --------------- // + + private static bool OnMac() + { + // All Mac mappings are based off TattieBogle Xbox Controller drivers + // http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver + // http://wiki.unity3d.com/index.php?title=Xbox360Controller + return (Application.platform == RuntimePlatform.OSXEditor || + Application.platform == RuntimePlatform.OSXPlayer ); + } + + private static bool OnWindows() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnWindowsNative() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnLinux() + { + // Linux mapping based on observation of mapping from default drivers on Ubuntu 13.04 + return Application.platform == RuntimePlatform.LinuxPlayer; + } + + private static bool IsControllerWireless() + { + // 0 means for any controller + return IsControllerWireless(0); + } + + private static bool IsControllerWireless(int ctrlNum) + { + if (ctrlNum < 0 || ctrlNum > 4) return false; + + // If 0 is passed in, that assumes that only 1 controller is plugged in. + if(ctrlNum == 0) + { + return ( (string) Input.GetJoystickNames()[0]).Contains("Wireless"); + } + + return ( (string) Input.GetJoystickNames()[ctrlNum-1]).Contains("Wireless"); + } + + private static bool IsControllerNumberValid(int ctrlrNum) + { + if(ctrlrNum > 0 && ctrlrNum <= 4) + { + return true; + } + else + { + Debug.LogError("XCI.IsControllerNumberValid(): " + + "Invalid contoller number! Should be between 1 and 4."); + } + return false; + } + + private static float RefactorRange(float oldRangeValue, int ctrlrNum, XboxAxis axis) + { + // HACK: On OS X, Left and right trigger under OSX return 0.5 until touched + // Issue #16 on Github: https://github.com/JISyed/Unity-XboxCtrlrInput/issues/16 + if(XCI.OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + else if(axis == XboxAxis.RightTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + } + + // Assumes you want to take a number from -1 to 1 range + // And turn it into a number from a 0 to 1 range + return ((oldRangeValue + 1.0f) / 2.0f ); + } + + private static string DetermineButtonCode(XboxButton btn, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sKeyCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + if(OnMac()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "16"; break; + case XboxButton.B: sKeyCode = "17"; break; + case XboxButton.X: sKeyCode = "18"; break; + case XboxButton.Y: sKeyCode = "19"; break; + case XboxButton.Start: sKeyCode = "9"; break; + case XboxButton.Back: sKeyCode = "10"; break; + case XboxButton.LeftStick: sKeyCode = "11"; break; + case XboxButton.RightStick: sKeyCode = "12"; break; + case XboxButton.LeftBumper: sKeyCode = "13"; break; + case XboxButton.RightBumper: sKeyCode = "14"; break; + + default: invalidCode = true; break; + } + } + else if (OnLinux()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "9"; break; + case XboxButton.RightStick: sKeyCode = "10"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "8"; break; + case XboxButton.RightStick: sKeyCode = "9"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + + r = "joystick" + sJoyCode + " button " + sKeyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineAxisCode(XboxAxis axs, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sAxisCode = ""; + bool invalidCode = false; + + + if(OnMac()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "3"; break; + case XboxAxis.RightStickY: sAxisCode = "4"; break; + case XboxAxis.LeftTrigger: sAxisCode = "5"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else if(OnLinux()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "3"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "9"; break; + case XboxAxis.RightTrigger: sAxisCode = "10"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sAxisCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static float AdjustAxisValues(float axisValue, XboxAxis axis, int ctrlrNum) + { + float newAxisValue = axisValue; + + if(OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = -newAxisValue; + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightStickY) + { + newAxisValue = -newAxisValue; + } + } + else if(OnLinux()) + { + if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + } + + return newAxisValue; + } + + private static string DetermineDPad(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sPadCode = ""; + bool invalidCode = false; + + if(OnLinux()) + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "8"; break; + case XboxDPad.Down: sPadCode = "8"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "7"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "7"; break; + case XboxDPad.Down: sPadCode = "7"; break; + case XboxDPad.Left: sPadCode = "6"; break; + case XboxDPad.Right: sPadCode = "6"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sPadCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadMac(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "5"; break; + case XboxDPad.Down: sPadCode = "6"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "8"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadWirelessLinux(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "13"; break; + case XboxDPad.Down: sPadCode = "14"; break; + case XboxDPad.Left: sPadCode = "11"; break; + case XboxDPad.Right: sPadCode = "12"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + + // ------------- Private XInput Wrappers (for Windows Native player and editor only) -------------- // + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + + // ------------ Inner Class ------------// + + // Used to setup XInput for Windows + class XciXInputInitializer + { + // Ctor + public XciXInputInitializer() + { + // Only runs once. + // Setup XInput here... + + + // Call input states twice in order to make sure that + // the previous states and current states are the same. + // This is needed to prevent errors where GetButtonUp will trigger unexpectledly + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + } + + public void Dummy() + { + // Intentionally does nothing to prevent warnings + } + } + + + + // ------------ Members --------------- // + + // Windows variables + private static GamePadState[] xInputCtrlrs = new GamePadState[4]; + private static GamePadState[] xInputCtrlrsPrev = new GamePadState[4]; + private static int xiPrevFrameCount = -1; + private static bool xiUpdateAlreadyCalled = false; + private static bool xiNumOfCtrlrsQueried = false; + private static XciXInputInitializer xinputInitalizer = new XCI.XciXInputInitializer(); + + + + // This can be set to something different if you want + private const GamePadDeadZone WindowsDeadzoneMethod = GamePadDeadZone.Circular; + + + + // ------------ Methods --------------- // + + //>> For updating states << + + private static void XInputUpdateAllStates() + { + if(xiUpdateAlreadyCalled) return; + + for(int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex) i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + xiUpdateAlreadyCalled = true; + } + + + //>> For getting states << + private static GamePadState XInputGetSingleState() + { + return xInputCtrlrs[0]; + } + + private static GamePadState XInputGetPaticularState(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrs[0]; + + return xInputCtrlrs[ctrlNum-1]; + } + + private static GamePadState XInputGetSingleStatePrev() + { + return xInputCtrlrsPrev[0]; + } + + private static GamePadState XInputGetPaticularStatePrev(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrsPrev[0]; + + return xInputCtrlrsPrev[ctrlNum-1]; + } + + //>> For getting input << + private static ButtonState XInputGetButtonState(GamePadButtons xiButtons, XboxButton xciBtn) + { + ButtonState stateToReturn = ButtonState.Pressed; + + switch(xciBtn) + { + case XboxButton.A: stateToReturn = xiButtons.A; break; + case XboxButton.B: stateToReturn = xiButtons.B; break; + case XboxButton.X: stateToReturn = xiButtons.X; break; + case XboxButton.Y: stateToReturn = xiButtons.Y; break; + case XboxButton.Start: stateToReturn = xiButtons.Start; break; + case XboxButton.Back: stateToReturn = xiButtons.Back; break; + case XboxButton.LeftBumper: stateToReturn = xiButtons.LeftShoulder; break; + case XboxButton.RightBumper: stateToReturn = xiButtons.RightShoulder; break; + case XboxButton.LeftStick: stateToReturn = xiButtons.LeftStick; break; + case XboxButton.RightStick: stateToReturn = xiButtons.RightStick; break; + } + + return stateToReturn; + } + + private static ButtonState XInputGetDPadState(GamePadDPad xiDPad, XboxDPad xciDPad) + { + ButtonState stateToReturn = ButtonState.Released; + + switch(xciDPad) + { + case XboxDPad.Up: stateToReturn = xiDPad.Up; break; + case XboxDPad.Down: stateToReturn = xiDPad.Down; break; + case XboxDPad.Left: stateToReturn = xiDPad.Left; break; + case XboxDPad.Right: stateToReturn = xiDPad.Right; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadTriggers xiTriggers, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftTrigger: stateToReturn = xiTriggers.Left; break; + case XboxAxis.RightTrigger: stateToReturn = xiTriggers.Right; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadThumbSticks xiThumbSticks, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftStickX: stateToReturn = xiThumbSticks.Left.X; break; + case XboxAxis.LeftStickY: stateToReturn = xiThumbSticks.Left.Y; break; + case XboxAxis.RightStickX: stateToReturn = xiThumbSticks.Right.X; break; + case XboxAxis.RightStickY: stateToReturn = xiThumbSticks.Right.Y; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static bool XInputStillInCurrFrame() + { + bool r = false; + xinputInitalizer.Dummy(); // Stop warnings about not using the initilaizer + + // Get the current frame + int currFrame = Time.frameCount; + + // Are we still in the current frame? + if(xiPrevFrameCount == currFrame) + { + r = true; + } + else + { + r = false; + xiUpdateAlreadyCalled = false; + } + + // Assign the previous frame count regardless of whether it's the same or not. + xiPrevFrameCount = currFrame; + + return r; + } + + + #endif + + // END of Windows only subsystem ========================================== + + + + // -------------------------- Handler Script ------------------- + + // Secret Private Script that does some maintainace work for XCI states. User should not use this script at all. + private class XciHandler : MonoBehaviour + { + private static XciHandler instance = null; + + public bool u3dTrigger0LeftIsTouched = false; + public bool u3dTrigger0RightIsTouched = false; + public bool u3dTrigger1LeftIsTouched = false; + public bool u3dTrigger1RightIsTouched = false; + public bool u3dTrigger2LeftIsTouched = false; + public bool u3dTrigger2RightIsTouched = false; + public bool u3dTrigger3LeftIsTouched = false; + public bool u3dTrigger3RightIsTouched = false; + public bool u3dTrigger4LeftIsTouched = false; + public bool u3dTrigger4RightIsTouched = false; + + void Awake() + { + if(XciHandler.instance != null) + { + GameObject.Destroy(this.gameObject); + } + + XciHandler.instance = this; + + // Lives for the life of the game + DontDestroyOnLoad(this.gameObject); + } + + void OnEnable() + { + SceneManager.sceneLoaded += OnSceneFinishedLoading; + } + + void OnDisable() + { + SceneManager.sceneLoaded -= OnSceneFinishedLoading; + } + + // Callback made to replace obsolete method OnLevelWasLoaded(int) + void OnSceneFinishedLoading(Scene currentScene, LoadSceneMode mode) + { + this.ResetTriggerTouches(); + } + + void OnApplicationFocus(bool isWindowInFocusNow) + { + if(!isWindowInFocusNow) + { + this.ResetTriggerTouches(); + } + } + + private void ResetTriggerTouches() + { + this.u3dTrigger0LeftIsTouched = false; + this.u3dTrigger0RightIsTouched = false; + this.u3dTrigger1LeftIsTouched = false; + this.u3dTrigger1RightIsTouched = false; + this.u3dTrigger2LeftIsTouched = false; + this.u3dTrigger2RightIsTouched = false; + this.u3dTrigger3LeftIsTouched = false; + this.u3dTrigger3RightIsTouched = false; + this.u3dTrigger4LeftIsTouched = false; + this.u3dTrigger4RightIsTouched = false; + } + + public static XciHandler Instance + { + get + { + if(XciHandler.instance == null) + { + GameObject xciHandleObj = new GameObject("XboxCtrlrInput Handler Object"); + xciHandleObj.AddComponent(); + } + + return XciHandler.instance; + } + } + } // end of XciHandler + } // end of XCI + + public static class XboxButtonExtensions + { + public static bool IsDPad(this XboxButton button) + { + return (button == XboxButton.DPadUp || + button == XboxButton.DPadDown || + button == XboxButton.DPadLeft || + button == XboxButton.DPadRight); + } + + public static XboxDPad ToDPad(this XboxButton button) + { + if (button == XboxButton.DPadUp) + return XboxDPad.Up; + if (button == XboxButton.DPadDown) + return XboxDPad.Down; + if (button == XboxButton.DPadLeft) + return XboxDPad.Left; + if (button == XboxButton.DPadRight) + return XboxDPad.Right; + return default(XboxDPad); + } + + + } + + +} diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta new file mode 100644 index 0000000..25d63aa --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 928025f6ea24748418044e4479b4c446 +timeCreated: 1572134135 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64.meta b/FallUnity/Assets/Plugins/x86_64.meta new file mode 100644 index 0000000..fb502ad --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9cd457a246db3a2458768c6d00ed39e6 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll new file mode 100644 index 0000000..8a2d764 --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta new file mode 100644 index 0000000..88fa34e --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta @@ -0,0 +1,95 @@ +fileFormatVersion: 2 +guid: ea895df4f09804d47ac0a43ce22418cb +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: ARMv7 + Any: + enabled: 1 + settings: + Exclude Android: 0 + Exclude Editor: 0 + Exclude Linux: 0 + Exclude Linux64: 0 + Exclude LinuxUniversal: 0 + Exclude OSXIntel: 0 + Exclude OSXIntel64: 0 + Exclude OSXUniversal: 0 + Exclude SamsungTV: 0 + Exclude Tizen: 0 + Exclude WebGL: 0 + Exclude Win: 1 + Exclude Win64: 0 + Exclude WindowsStoreApps: 0 + Exclude iOS: 0 + Editor: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 1 + settings: + CPU: None + Linux64: + enabled: 1 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel: + enabled: 1 + settings: + CPU: None + OSXIntel64: + enabled: 1 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 1 + settings: + CPU: AnyCPU + SamsungTV: + enabled: 1 + settings: + STV_MODEL: STANDARD_15 + Tizen: + enabled: 1 + settings: {} + WebGL: + enabled: 1 + settings: {} + Win: + enabled: 0 + settings: + CPU: None + Win64: + enabled: 1 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + iOS: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/RedDebug.mat b/FallUnity/Assets/RedDebug.mat new file mode 100644 index 0000000..7786680 --- /dev/null +++ b/FallUnity/Assets/RedDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: RedDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 0, b: 0, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/RedDebug.mat.meta b/FallUnity/Assets/RedDebug.mat.meta new file mode 100644 index 0000000..c65627f --- /dev/null +++ b/FallUnity/Assets/RedDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 30ca106f1a02e19498baabb238d01d50 +timeCreated: 1572133462 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/XboxCtrlrInput.meta b/FallUnity/Assets/XboxCtrlrInput.meta new file mode 100644 index 0000000..7b92c68 --- /dev/null +++ b/FallUnity/Assets/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 03c20217de43a304b9db30d8f9cf01af +folderAsset: yes +timeCreated: 1572134146 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/level.unity b/FallUnity/Assets/level.unity index eee2288..6f0f3c1 100755 --- a/FallUnity/Assets/level.unity +++ b/FallUnity/Assets/level.unity @@ -223,6 +223,8 @@ m_Script: {fileID: 11500000, guid: e9e45b67a184f38439d0136610b1d1cb, type: 3} m_Name: m_EditorClassIdentifier: + ChunksX: 20 + ChunksY: 20 --- !u!1 &257733088 GameObject: m_ObjectHideFlags: 0 @@ -365,9 +367,12 @@ m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - ManualDepth: 1 - Depth: 995 + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 LinkedImage: {fileID: 1777425976} + IsoRadius: 0 + IsoPerspective: 0 + IsoType: 1 --- !u!1 &418505720 GameObject: m_ObjectHideFlags: 0 @@ -405,14 +410,14 @@ m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 418505720} - m_Enabled: 1 + m_Enabled: 0 --- !u!124 &418505723 Behaviour: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 418505720} - m_Enabled: 1 + m_Enabled: 0 --- !u!20 &418505724 Camera: m_ObjectHideFlags: 0 @@ -744,7 +749,7 @@ m_GameObject: {fileID: 1076119174} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0.08, y: -0.41, z: -3.74} - m_LocalScale: {x: 13.190122, y: 1.2632968, z: 0.18388264} + m_LocalScale: {x: 13.190122, y: 1.7437512, z: 0.18388264} m_Children: [] m_Father: {fileID: 468371543} m_RootOrder: 0 @@ -763,7 +768,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: d76887554d5b2e441b3ecb5e4e52b392, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -813,9 +818,12 @@ m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - ManualDepth: 0 - Depth: 0 + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 LinkedImage: {fileID: 1548969793} + IsoRadius: 0 + IsoPerspective: 0 + IsoType: 1 --- !u!1 &1206131915 GameObject: m_ObjectHideFlags: 0 @@ -857,7 +865,7 @@ m_Name: m_EditorClassIdentifier: Radius: 5 - Rate: 52.6 + Rate: 33.04 Leaf: {fileID: 114579094665962866, guid: 1701be1f15e160d4d904862548ae69de, type: 2} --- !u!1 &1272122407 GameObject: @@ -988,7 +996,7 @@ m_Depth: 0 m_CullingMask: serializedVersion: 2 - m_Bits: 4294964479 + m_Bits: 4294952191 m_RenderingPath: -1 m_TargetTexture: {fileID: 0} m_TargetDisplay: 0 @@ -1174,6 +1182,48 @@ m_Father: {fileID: 257733089} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1774596164 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1774596166} + - component: {fileID: 1774596165} + m_Layer: 0 + m_Name: InputManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1774596165 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1774596164} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 33ec797898b03244e94c917f9503fe39, type: 3} + m_Name: + m_EditorClassIdentifier: + PlayerPrefab: {fileID: 114770286734950254, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, + type: 2} +--- !u!4 &1774596166 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1774596164} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 24.684563, z: -35.583923} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1777425976 GameObject: m_ObjectHideFlags: 0 @@ -1242,15 +1292,15 @@ m_Modifications: - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} propertyPath: m_LocalPosition.x - value: 0.55 + value: -2.25 objectReference: {fileID: 0} - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} propertyPath: m_LocalPosition.y - value: -1 + value: -0.84 objectReference: {fileID: 0} - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} propertyPath: m_LocalPosition.z - value: 0.24 + value: -1.05 objectReference: {fileID: 0} - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} propertyPath: m_LocalRotation.x @@ -1272,19 +1322,6 @@ propertyPath: m_RootOrder value: 5 objectReference: {fileID: 0} - - target: {fileID: 114432391297954942, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, - type: 2} - propertyPath: PixelScale - value: 0.01 - objectReference: {fileID: 0} - - target: {fileID: 1217361112803688, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} - propertyPath: m_Layer - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1127561252628422, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} - propertyPath: m_IsActive - value: 0 - objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} m_IsPrefabParent: 0 diff --git a/FallUnity/ProjectSettings/DynamicsManager.asset b/FallUnity/ProjectSettings/DynamicsManager.asset index 4095a05..aec42ed 100755 --- a/FallUnity/ProjectSettings/DynamicsManager.asset +++ b/FallUnity/ProjectSettings/DynamicsManager.asset @@ -5,7 +5,7 @@ m_ObjectHideFlags: 0 serializedVersion: 3 m_Gravity: {x: 0, y: -2.55, z: 0} - m_DefaultMaterial: {fileID: 0} + m_DefaultMaterial: {fileID: 13400000, guid: b7da08e26ab67394da4bd04c31cbe10a, type: 2} m_BounceThreshold: 2 m_SleepThreshold: 0.005 m_DefaultContactOffset: 0.01 @@ -15,6 +15,6 @@ m_QueriesHitTriggers: 1 m_EnableAdaptiveForce: 0 m_EnablePCM: 1 - m_LayerCollisionMatrix: fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdbfffffffffffffffffffffffbffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff m_AutoSimulation: 1 m_AutoSyncTransforms: 1 diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta new file mode 100644 index 0000000..2d0e145 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ada75d1768d6fad4eb285bd538323380 +timeCreated: 1472582191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs new file mode 100644 index 0000000..1106813 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using XboxCtrlrInput; + +namespace PlayerInput +{ + public class XboxControllerInputSource : InputSource where TTarget : MonoBehaviour + { + private static List allControllers; + public static IEnumerable AllControllers { get { return allControllers; } } + static XboxControllerInputSource() + { + allControllers = new List() + { + XboxController.First, + XboxController.Second, + XboxController.Third, + XboxController.Fourth, + }; + } + + private Dictionary buttonMapping; + private Dictionary axisMapping; + + private XboxController controller; + public XboxController Controller { get { return controller; } } + + public XboxControllerInputSource(XboxController controller) + { + this.controller = controller; + + buttonMapping = new Dictionary() + { + { InputButton.MenuSelect, XboxButton.A }, + { InputButton.MenuCancel, XboxButton.B }, + + //{ InputButton.UseItem, XboxButton.A }, + //{ InputButton.PickA, XboxButton.LeftBumper }, + //{ InputButton.PickB, XboxButton.RightBumper }, + + //{ InputButton.AnimalSelector, XboxButton.LeftBumper }, + }; + + axisMapping = new Dictionary() + { + { InputAxis.MenuX, XboxAxis.LeftStickX }, + { InputAxis.MenuY, XboxAxis.LeftStickY }, + + { InputAxis.RakeX, XboxAxis.RightStickX }, + { InputAxis.RakeY, XboxAxis.RightStickY }, + + { InputAxis.MoveX, XboxAxis.LeftStickX }, + { InputAxis.MoveY, XboxAxis.LeftStickY }, + + //{ InputAxis.Throttle, XboxAxis.RightTrigger }, + //{ InputAxis.RevThrottle, XboxAxis.LeftTrigger }, + }; + } + + protected override void VibrateInternal(float left, float right) + { + XCI.SetVibration(controller, left, right); + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + return XCI.GetButtonDown(buttonMapping[button], controller); + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + return XCI.GetButtonUp(buttonMapping[button], controller); + } + + public override bool ButtonDown(InputButton button) + { + return XCI.GetButton(buttonMapping[button], controller); + } + + public override float Axis(InputAxis axis) + { + return XCI.GetAxis(axisMapping[axis], controller); + } + } +} diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta new file mode 100644 index 0000000..9f6859f --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ec7d070ee2898544aa46811e0e3da197 +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins.meta b/FallUnity/Assets/Plugins.meta new file mode 100644 index 0000000..b7025e8 --- /dev/null +++ b/FallUnity/Assets/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: dca2b803c244eb540bbf437959ae5f51 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll b/FallUnity/Assets/Plugins/XInputDotNetPure.dll new file mode 100644 index 0000000..d345520 --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta new file mode 100644 index 0000000..c87585b --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: a05c5d8086133f648a3dd3229d764a63 +timeCreated: 1572134134 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs new file mode 100644 index 0000000..69ee3a8 --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs @@ -0,0 +1,1969 @@ +using UnityEngine; +using UnityEngine.SceneManagement; + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN +using XInputDotNetPure; +#endif + +namespace XboxCtrlrInput +{ + + // ================= Enumerations ==================== // + + /// + /// List of enumerated identifiers for Xbox controllers. + /// + /// + /// Do NOT change enum values + /// + public enum XboxController + { + /// + /// "All" Controllers is deprecated! Use "Any" instead. + /// + [System.Obsolete("Instead use XboxController.Any")] + All = 0, + + Any = 0, + + First = 1, + Second = 2, + Third = 3, + Fourth = 4 + } + + /// + /// List of enumerated identifiers for Xbox buttons. + /// + public enum XboxButton + { + A, + B, + X, + Y, + Start, + Back, + LeftStick, + RightStick, + LeftBumper, + RightBumper, + DPadUp, + DPadDown, + DPadLeft, + DPadRight + } + + /// + /// List of enumerated identifiers for Xbox D-Pad directions. + /// + public enum XboxDPad + { + Up, + Down, + Left, + Right + } + + /// + /// List of enumerated identifiers for Xbox axis. + /// + public enum XboxAxis + { + LeftStickX, + LeftStickY, + RightStickX, + RightStickY, + LeftTrigger, + RightTrigger + } + + // ================ Classes =================== // + + public static class XCI + { + // ------------ Public Methods --------------- // + + public static bool SetVibration(XboxController controller, float left, float right) + { + + int controllerNumber = (int)controller; + + if (OnWindowsNative()) + { + GamePad.SetVibration((PlayerIndex)(controllerNumber - 1), left, right); + } + else + { + + } + + return false; + } + + // >>> For Buttons <<< // + + /// + /// Returns true if the specified button is held down by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButton(XboxButton button) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true if the specified button is held down by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButton(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButton(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonDown(XboxButton button) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonDown(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonDown(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonUp(XboxButton button) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonUp(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonUp(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + // >>> For D-Pad <<< // + + /// + /// Returns true if the specified D-Pad direction is pressed down by any controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + public static bool GetDPad(XboxDPad padDirection) + { + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, 0); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + /// + /// Returns true if the specified D-Pad direction is pressed down by a specified controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + /// + /// An identifier for the specific controller on which to test the D-Pad. + /// + public static bool GetDPad(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPad(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, controllerNumber); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadUp(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadUp(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadUp(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadDown(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadDown(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadDown(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // >>> For Axis <<< // + + /// + /// Returns the analog number of the specified axis from any controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxis(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxis(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxis(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from any controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxisRaw(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxisRaw(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxisRaw(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + // >>> Other important functions <<< // + + /// + /// Returns the number of Xbox controllers plugged to the computer. + /// + public static int GetNumPluggedCtrlrs() + { + int r = 0; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!xiNumOfCtrlrsQueried || !XInputStillInCurrFrame()) + { + xiNumOfCtrlrsQueried = true; + XInputUpdateAllStates(); + } + + for(int i = 0; i < 4; i++) + { + if(xInputCtrlrs[i].IsConnected) + { + r++; + } + } + #endif + } + + else + { + string[] ctrlrNames = Input.GetJoystickNames(); + for(int i = 0; i < ctrlrNames.Length; i++) + { + if(ctrlrNames[i].Contains("Xbox") || ctrlrNames[i].Contains("XBOX") || ctrlrNames[i].Contains("Microsoft")) + { + r++; + } + } + } + + return r; + } + + /// + /// DEBUG function. Log all controller names to Unity's console. + /// + public static void DEBUG_LogControllerNames() + { + string[] cNames = Input.GetJoystickNames(); + + for(int i = 0; i < cNames.Length; i++) + { + Debug.Log("Ctrlr " + i.ToString() + ": " + cNames[i]); + } + } + + + + + + // From @xoorath + /// + /// DEPRECATED: + /// Determines if the controller is plugged in the specified controllerNumber. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. An int between 1 and 4. + /// + [System.Obsolete("Instead use IsPluggedIn(XboxController)")] + public static bool IsPluggedIn(int controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + return ctrlrState.IsConnected; + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + // Based off @xoorath 's implementation + /// + /// Determines if the controller is plugged in the specified controllerNumber. + /// Passing Any will evaluate if any controller is connected. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// Passing Any will evaluate if any controller is connected. + /// + public static bool IsPluggedIn(XboxController controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + { + if (OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState; + + + // If inquiring about any controller + + // TODO: Remove condition for XboxController.All when the time comes + // Users of XCI: Feel free to remove XboxController.All if you like having no warnings + if(controllerNumber == XboxController.Any || controllerNumber == XboxController.All) + { + // Examine all controllers it see if any are connected + for(int i = 1; i <= 4; i++) + { + ctrlrState = XInputGetPaticularState(i); + if(ctrlrState.IsConnected) + { + return true; + } + } + } + + + // If specifying a specific controller + + // Note: Casting only works if XboxController enums are values 1 to 4 (First, Second, Third, Fourth) + ctrlrState = XInputGetPaticularState((int)controllerNumber); + + return ctrlrState.IsConnected; + } + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + + + //// + // ------------- Private -------------- // + //// + + // ------------ Methods --------------- // + + private static bool OnMac() + { + // All Mac mappings are based off TattieBogle Xbox Controller drivers + // http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver + // http://wiki.unity3d.com/index.php?title=Xbox360Controller + return (Application.platform == RuntimePlatform.OSXEditor || + Application.platform == RuntimePlatform.OSXPlayer ); + } + + private static bool OnWindows() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnWindowsNative() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnLinux() + { + // Linux mapping based on observation of mapping from default drivers on Ubuntu 13.04 + return Application.platform == RuntimePlatform.LinuxPlayer; + } + + private static bool IsControllerWireless() + { + // 0 means for any controller + return IsControllerWireless(0); + } + + private static bool IsControllerWireless(int ctrlNum) + { + if (ctrlNum < 0 || ctrlNum > 4) return false; + + // If 0 is passed in, that assumes that only 1 controller is plugged in. + if(ctrlNum == 0) + { + return ( (string) Input.GetJoystickNames()[0]).Contains("Wireless"); + } + + return ( (string) Input.GetJoystickNames()[ctrlNum-1]).Contains("Wireless"); + } + + private static bool IsControllerNumberValid(int ctrlrNum) + { + if(ctrlrNum > 0 && ctrlrNum <= 4) + { + return true; + } + else + { + Debug.LogError("XCI.IsControllerNumberValid(): " + + "Invalid contoller number! Should be between 1 and 4."); + } + return false; + } + + private static float RefactorRange(float oldRangeValue, int ctrlrNum, XboxAxis axis) + { + // HACK: On OS X, Left and right trigger under OSX return 0.5 until touched + // Issue #16 on Github: https://github.com/JISyed/Unity-XboxCtrlrInput/issues/16 + if(XCI.OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + else if(axis == XboxAxis.RightTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + } + + // Assumes you want to take a number from -1 to 1 range + // And turn it into a number from a 0 to 1 range + return ((oldRangeValue + 1.0f) / 2.0f ); + } + + private static string DetermineButtonCode(XboxButton btn, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sKeyCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + if(OnMac()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "16"; break; + case XboxButton.B: sKeyCode = "17"; break; + case XboxButton.X: sKeyCode = "18"; break; + case XboxButton.Y: sKeyCode = "19"; break; + case XboxButton.Start: sKeyCode = "9"; break; + case XboxButton.Back: sKeyCode = "10"; break; + case XboxButton.LeftStick: sKeyCode = "11"; break; + case XboxButton.RightStick: sKeyCode = "12"; break; + case XboxButton.LeftBumper: sKeyCode = "13"; break; + case XboxButton.RightBumper: sKeyCode = "14"; break; + + default: invalidCode = true; break; + } + } + else if (OnLinux()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "9"; break; + case XboxButton.RightStick: sKeyCode = "10"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "8"; break; + case XboxButton.RightStick: sKeyCode = "9"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + + r = "joystick" + sJoyCode + " button " + sKeyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineAxisCode(XboxAxis axs, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sAxisCode = ""; + bool invalidCode = false; + + + if(OnMac()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "3"; break; + case XboxAxis.RightStickY: sAxisCode = "4"; break; + case XboxAxis.LeftTrigger: sAxisCode = "5"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else if(OnLinux()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "3"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "9"; break; + case XboxAxis.RightTrigger: sAxisCode = "10"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sAxisCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static float AdjustAxisValues(float axisValue, XboxAxis axis, int ctrlrNum) + { + float newAxisValue = axisValue; + + if(OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = -newAxisValue; + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightStickY) + { + newAxisValue = -newAxisValue; + } + } + else if(OnLinux()) + { + if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + } + + return newAxisValue; + } + + private static string DetermineDPad(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sPadCode = ""; + bool invalidCode = false; + + if(OnLinux()) + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "8"; break; + case XboxDPad.Down: sPadCode = "8"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "7"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "7"; break; + case XboxDPad.Down: sPadCode = "7"; break; + case XboxDPad.Left: sPadCode = "6"; break; + case XboxDPad.Right: sPadCode = "6"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sPadCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadMac(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "5"; break; + case XboxDPad.Down: sPadCode = "6"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "8"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadWirelessLinux(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "13"; break; + case XboxDPad.Down: sPadCode = "14"; break; + case XboxDPad.Left: sPadCode = "11"; break; + case XboxDPad.Right: sPadCode = "12"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + + // ------------- Private XInput Wrappers (for Windows Native player and editor only) -------------- // + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + + // ------------ Inner Class ------------// + + // Used to setup XInput for Windows + class XciXInputInitializer + { + // Ctor + public XciXInputInitializer() + { + // Only runs once. + // Setup XInput here... + + + // Call input states twice in order to make sure that + // the previous states and current states are the same. + // This is needed to prevent errors where GetButtonUp will trigger unexpectledly + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + } + + public void Dummy() + { + // Intentionally does nothing to prevent warnings + } + } + + + + // ------------ Members --------------- // + + // Windows variables + private static GamePadState[] xInputCtrlrs = new GamePadState[4]; + private static GamePadState[] xInputCtrlrsPrev = new GamePadState[4]; + private static int xiPrevFrameCount = -1; + private static bool xiUpdateAlreadyCalled = false; + private static bool xiNumOfCtrlrsQueried = false; + private static XciXInputInitializer xinputInitalizer = new XCI.XciXInputInitializer(); + + + + // This can be set to something different if you want + private const GamePadDeadZone WindowsDeadzoneMethod = GamePadDeadZone.Circular; + + + + // ------------ Methods --------------- // + + //>> For updating states << + + private static void XInputUpdateAllStates() + { + if(xiUpdateAlreadyCalled) return; + + for(int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex) i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + xiUpdateAlreadyCalled = true; + } + + + //>> For getting states << + private static GamePadState XInputGetSingleState() + { + return xInputCtrlrs[0]; + } + + private static GamePadState XInputGetPaticularState(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrs[0]; + + return xInputCtrlrs[ctrlNum-1]; + } + + private static GamePadState XInputGetSingleStatePrev() + { + return xInputCtrlrsPrev[0]; + } + + private static GamePadState XInputGetPaticularStatePrev(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrsPrev[0]; + + return xInputCtrlrsPrev[ctrlNum-1]; + } + + //>> For getting input << + private static ButtonState XInputGetButtonState(GamePadButtons xiButtons, XboxButton xciBtn) + { + ButtonState stateToReturn = ButtonState.Pressed; + + switch(xciBtn) + { + case XboxButton.A: stateToReturn = xiButtons.A; break; + case XboxButton.B: stateToReturn = xiButtons.B; break; + case XboxButton.X: stateToReturn = xiButtons.X; break; + case XboxButton.Y: stateToReturn = xiButtons.Y; break; + case XboxButton.Start: stateToReturn = xiButtons.Start; break; + case XboxButton.Back: stateToReturn = xiButtons.Back; break; + case XboxButton.LeftBumper: stateToReturn = xiButtons.LeftShoulder; break; + case XboxButton.RightBumper: stateToReturn = xiButtons.RightShoulder; break; + case XboxButton.LeftStick: stateToReturn = xiButtons.LeftStick; break; + case XboxButton.RightStick: stateToReturn = xiButtons.RightStick; break; + } + + return stateToReturn; + } + + private static ButtonState XInputGetDPadState(GamePadDPad xiDPad, XboxDPad xciDPad) + { + ButtonState stateToReturn = ButtonState.Released; + + switch(xciDPad) + { + case XboxDPad.Up: stateToReturn = xiDPad.Up; break; + case XboxDPad.Down: stateToReturn = xiDPad.Down; break; + case XboxDPad.Left: stateToReturn = xiDPad.Left; break; + case XboxDPad.Right: stateToReturn = xiDPad.Right; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadTriggers xiTriggers, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftTrigger: stateToReturn = xiTriggers.Left; break; + case XboxAxis.RightTrigger: stateToReturn = xiTriggers.Right; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadThumbSticks xiThumbSticks, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftStickX: stateToReturn = xiThumbSticks.Left.X; break; + case XboxAxis.LeftStickY: stateToReturn = xiThumbSticks.Left.Y; break; + case XboxAxis.RightStickX: stateToReturn = xiThumbSticks.Right.X; break; + case XboxAxis.RightStickY: stateToReturn = xiThumbSticks.Right.Y; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static bool XInputStillInCurrFrame() + { + bool r = false; + xinputInitalizer.Dummy(); // Stop warnings about not using the initilaizer + + // Get the current frame + int currFrame = Time.frameCount; + + // Are we still in the current frame? + if(xiPrevFrameCount == currFrame) + { + r = true; + } + else + { + r = false; + xiUpdateAlreadyCalled = false; + } + + // Assign the previous frame count regardless of whether it's the same or not. + xiPrevFrameCount = currFrame; + + return r; + } + + + #endif + + // END of Windows only subsystem ========================================== + + + + // -------------------------- Handler Script ------------------- + + // Secret Private Script that does some maintainace work for XCI states. User should not use this script at all. + private class XciHandler : MonoBehaviour + { + private static XciHandler instance = null; + + public bool u3dTrigger0LeftIsTouched = false; + public bool u3dTrigger0RightIsTouched = false; + public bool u3dTrigger1LeftIsTouched = false; + public bool u3dTrigger1RightIsTouched = false; + public bool u3dTrigger2LeftIsTouched = false; + public bool u3dTrigger2RightIsTouched = false; + public bool u3dTrigger3LeftIsTouched = false; + public bool u3dTrigger3RightIsTouched = false; + public bool u3dTrigger4LeftIsTouched = false; + public bool u3dTrigger4RightIsTouched = false; + + void Awake() + { + if(XciHandler.instance != null) + { + GameObject.Destroy(this.gameObject); + } + + XciHandler.instance = this; + + // Lives for the life of the game + DontDestroyOnLoad(this.gameObject); + } + + void OnEnable() + { + SceneManager.sceneLoaded += OnSceneFinishedLoading; + } + + void OnDisable() + { + SceneManager.sceneLoaded -= OnSceneFinishedLoading; + } + + // Callback made to replace obsolete method OnLevelWasLoaded(int) + void OnSceneFinishedLoading(Scene currentScene, LoadSceneMode mode) + { + this.ResetTriggerTouches(); + } + + void OnApplicationFocus(bool isWindowInFocusNow) + { + if(!isWindowInFocusNow) + { + this.ResetTriggerTouches(); + } + } + + private void ResetTriggerTouches() + { + this.u3dTrigger0LeftIsTouched = false; + this.u3dTrigger0RightIsTouched = false; + this.u3dTrigger1LeftIsTouched = false; + this.u3dTrigger1RightIsTouched = false; + this.u3dTrigger2LeftIsTouched = false; + this.u3dTrigger2RightIsTouched = false; + this.u3dTrigger3LeftIsTouched = false; + this.u3dTrigger3RightIsTouched = false; + this.u3dTrigger4LeftIsTouched = false; + this.u3dTrigger4RightIsTouched = false; + } + + public static XciHandler Instance + { + get + { + if(XciHandler.instance == null) + { + GameObject xciHandleObj = new GameObject("XboxCtrlrInput Handler Object"); + xciHandleObj.AddComponent(); + } + + return XciHandler.instance; + } + } + } // end of XciHandler + } // end of XCI + + public static class XboxButtonExtensions + { + public static bool IsDPad(this XboxButton button) + { + return (button == XboxButton.DPadUp || + button == XboxButton.DPadDown || + button == XboxButton.DPadLeft || + button == XboxButton.DPadRight); + } + + public static XboxDPad ToDPad(this XboxButton button) + { + if (button == XboxButton.DPadUp) + return XboxDPad.Up; + if (button == XboxButton.DPadDown) + return XboxDPad.Down; + if (button == XboxButton.DPadLeft) + return XboxDPad.Left; + if (button == XboxButton.DPadRight) + return XboxDPad.Right; + return default(XboxDPad); + } + + + } + + +} diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta new file mode 100644 index 0000000..25d63aa --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 928025f6ea24748418044e4479b4c446 +timeCreated: 1572134135 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64.meta b/FallUnity/Assets/Plugins/x86_64.meta new file mode 100644 index 0000000..fb502ad --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9cd457a246db3a2458768c6d00ed39e6 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll new file mode 100644 index 0000000..8a2d764 --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta new file mode 100644 index 0000000..88fa34e --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta @@ -0,0 +1,95 @@ +fileFormatVersion: 2 +guid: ea895df4f09804d47ac0a43ce22418cb +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: ARMv7 + Any: + enabled: 1 + settings: + Exclude Android: 0 + Exclude Editor: 0 + Exclude Linux: 0 + Exclude Linux64: 0 + Exclude LinuxUniversal: 0 + Exclude OSXIntel: 0 + Exclude OSXIntel64: 0 + Exclude OSXUniversal: 0 + Exclude SamsungTV: 0 + Exclude Tizen: 0 + Exclude WebGL: 0 + Exclude Win: 1 + Exclude Win64: 0 + Exclude WindowsStoreApps: 0 + Exclude iOS: 0 + Editor: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 1 + settings: + CPU: None + Linux64: + enabled: 1 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel: + enabled: 1 + settings: + CPU: None + OSXIntel64: + enabled: 1 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 1 + settings: + CPU: AnyCPU + SamsungTV: + enabled: 1 + settings: + STV_MODEL: STANDARD_15 + Tizen: + enabled: 1 + settings: {} + WebGL: + enabled: 1 + settings: {} + Win: + enabled: 0 + settings: + CPU: None + Win64: + enabled: 1 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + iOS: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/RedDebug.mat b/FallUnity/Assets/RedDebug.mat new file mode 100644 index 0000000..7786680 --- /dev/null +++ b/FallUnity/Assets/RedDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: RedDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 0, b: 0, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/RedDebug.mat.meta b/FallUnity/Assets/RedDebug.mat.meta new file mode 100644 index 0000000..c65627f --- /dev/null +++ b/FallUnity/Assets/RedDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 30ca106f1a02e19498baabb238d01d50 +timeCreated: 1572133462 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/XboxCtrlrInput.meta b/FallUnity/Assets/XboxCtrlrInput.meta new file mode 100644 index 0000000..7b92c68 --- /dev/null +++ b/FallUnity/Assets/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 03c20217de43a304b9db30d8f9cf01af +folderAsset: yes +timeCreated: 1572134146 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/level.unity b/FallUnity/Assets/level.unity index eee2288..6f0f3c1 100755 --- a/FallUnity/Assets/level.unity +++ b/FallUnity/Assets/level.unity @@ -223,6 +223,8 @@ m_Script: {fileID: 11500000, guid: e9e45b67a184f38439d0136610b1d1cb, type: 3} m_Name: m_EditorClassIdentifier: + ChunksX: 20 + ChunksY: 20 --- !u!1 &257733088 GameObject: m_ObjectHideFlags: 0 @@ -365,9 +367,12 @@ m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - ManualDepth: 1 - Depth: 995 + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 LinkedImage: {fileID: 1777425976} + IsoRadius: 0 + IsoPerspective: 0 + IsoType: 1 --- !u!1 &418505720 GameObject: m_ObjectHideFlags: 0 @@ -405,14 +410,14 @@ m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 418505720} - m_Enabled: 1 + m_Enabled: 0 --- !u!124 &418505723 Behaviour: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 418505720} - m_Enabled: 1 + m_Enabled: 0 --- !u!20 &418505724 Camera: m_ObjectHideFlags: 0 @@ -744,7 +749,7 @@ m_GameObject: {fileID: 1076119174} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0.08, y: -0.41, z: -3.74} - m_LocalScale: {x: 13.190122, y: 1.2632968, z: 0.18388264} + m_LocalScale: {x: 13.190122, y: 1.7437512, z: 0.18388264} m_Children: [] m_Father: {fileID: 468371543} m_RootOrder: 0 @@ -763,7 +768,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: d76887554d5b2e441b3ecb5e4e52b392, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -813,9 +818,12 @@ m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - ManualDepth: 0 - Depth: 0 + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 LinkedImage: {fileID: 1548969793} + IsoRadius: 0 + IsoPerspective: 0 + IsoType: 1 --- !u!1 &1206131915 GameObject: m_ObjectHideFlags: 0 @@ -857,7 +865,7 @@ m_Name: m_EditorClassIdentifier: Radius: 5 - Rate: 52.6 + Rate: 33.04 Leaf: {fileID: 114579094665962866, guid: 1701be1f15e160d4d904862548ae69de, type: 2} --- !u!1 &1272122407 GameObject: @@ -988,7 +996,7 @@ m_Depth: 0 m_CullingMask: serializedVersion: 2 - m_Bits: 4294964479 + m_Bits: 4294952191 m_RenderingPath: -1 m_TargetTexture: {fileID: 0} m_TargetDisplay: 0 @@ -1174,6 +1182,48 @@ m_Father: {fileID: 257733089} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1774596164 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1774596166} + - component: {fileID: 1774596165} + m_Layer: 0 + m_Name: InputManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1774596165 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1774596164} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 33ec797898b03244e94c917f9503fe39, type: 3} + m_Name: + m_EditorClassIdentifier: + PlayerPrefab: {fileID: 114770286734950254, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, + type: 2} +--- !u!4 &1774596166 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1774596164} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 24.684563, z: -35.583923} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1777425976 GameObject: m_ObjectHideFlags: 0 @@ -1242,15 +1292,15 @@ m_Modifications: - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} propertyPath: m_LocalPosition.x - value: 0.55 + value: -2.25 objectReference: {fileID: 0} - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} propertyPath: m_LocalPosition.y - value: -1 + value: -0.84 objectReference: {fileID: 0} - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} propertyPath: m_LocalPosition.z - value: 0.24 + value: -1.05 objectReference: {fileID: 0} - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} propertyPath: m_LocalRotation.x @@ -1272,19 +1322,6 @@ propertyPath: m_RootOrder value: 5 objectReference: {fileID: 0} - - target: {fileID: 114432391297954942, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, - type: 2} - propertyPath: PixelScale - value: 0.01 - objectReference: {fileID: 0} - - target: {fileID: 1217361112803688, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} - propertyPath: m_Layer - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1127561252628422, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} - propertyPath: m_IsActive - value: 0 - objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} m_IsPrefabParent: 0 diff --git a/FallUnity/ProjectSettings/DynamicsManager.asset b/FallUnity/ProjectSettings/DynamicsManager.asset index 4095a05..aec42ed 100755 --- a/FallUnity/ProjectSettings/DynamicsManager.asset +++ b/FallUnity/ProjectSettings/DynamicsManager.asset @@ -5,7 +5,7 @@ m_ObjectHideFlags: 0 serializedVersion: 3 m_Gravity: {x: 0, y: -2.55, z: 0} - m_DefaultMaterial: {fileID: 0} + m_DefaultMaterial: {fileID: 13400000, guid: b7da08e26ab67394da4bd04c31cbe10a, type: 2} m_BounceThreshold: 2 m_SleepThreshold: 0.005 m_DefaultContactOffset: 0.01 @@ -15,6 +15,6 @@ m_QueriesHitTriggers: 1 m_EnableAdaptiveForce: 0 m_EnablePCM: 1 - m_LayerCollisionMatrix: fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdbfffffffffffffffffffffffbffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff m_AutoSimulation: 1 m_AutoSyncTransforms: 1 diff --git a/FallUnity/ProjectSettings/TagManager.asset b/FallUnity/ProjectSettings/TagManager.asset index 74fe74e..64c03e1 100644 --- a/FallUnity/ProjectSettings/TagManager.asset +++ b/FallUnity/ProjectSettings/TagManager.asset @@ -17,8 +17,8 @@ - hide - leaf - iso_piece - - - - + - player_controller + - player_controller_no_collide - - - diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs index 9df9e44..870efd2 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -139,6 +139,24 @@ } } + public void SetDir(Direction dir) + { + if (this.Dir != dir) + { + this.Dir = dir; + UpdateMesh(); + } + } + + public void SetFrame(int frame) + { + if (this.Frame != frame) + { + this.Frame = frame; + UpdateMesh(); + } + } + public Direction Dir = Direction.DownRight; public int Frame = 0; diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta index 6b030a0..055da09 100644 --- a/FallUnity/Assets/Animations/AnimationHandler.cs.meta +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -1,12 +1,12 @@ fileFormatVersion: 2 guid: 7bcddcb25d3f2f0418f47d778e3320c6 -timeCreated: 1572129689 +timeCreated: 1572140054 licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/FallUnity/Assets/Editor.meta b/FallUnity/Assets/Editor.meta new file mode 100644 index 0000000..cafeb5c --- /dev/null +++ b/FallUnity/Assets/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 52c1ea61d0196934b935913ac07b4746 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput.meta b/FallUnity/Assets/Editor/XboxCtrlrInput.meta new file mode 100644 index 0000000..2b1e79b --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae71df67efe53234ca69dbf5d3900cbe +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta new file mode 100644 index 0000000..681eb1c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5517ba1dd28984b4f8c1d47cc84572a1 +folderAsset: yes +timeCreated: 1440560499 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary new file mode 100644 index 0000000..e133e65 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary Binary files differ diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta new file mode 100644 index 0000000..ee3d214 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerBinary.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72f411ea18b6d4edb8d898da50f52bdd +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText new file mode 100644 index 0000000..c050f6c --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText @@ -0,0 +1,1078 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Window Shake Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 3 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisYJoy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis3Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis4Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis5Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis6Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis7Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxisXJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisYJoy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis3Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis4Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis5Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis6Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis7Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxisXJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisYJoy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis3Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis4Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis5Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis6Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis7Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxisXJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisYJoy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis3Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis4Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis5Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis6Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis7Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxisXJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxisYJoy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis3Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 2 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis4Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 3 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis5Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 4 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis6Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 5 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis7Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 6 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis9Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis10Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis9Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis10Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis9Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis10Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis9Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis10Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis9Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 8 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis10Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 9 + joyNum: 4 + - serializedVersion: 3 + m_Name: XboxAxis8Joy0 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 0 + - serializedVersion: 3 + m_Name: XboxAxis8Joy1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 1 + - serializedVersion: 3 + m_Name: XboxAxis8Joy2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 2 + - serializedVersion: 3 + m_Name: XboxAxis8Joy3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 3 + - serializedVersion: 3 + m_Name: XboxAxis8Joy4 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 7 + joyNum: 4 diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta new file mode 100644 index 0000000..658f93d --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManager Copies/InputManagerText.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5db22628e3e8342bcabb10bdb5e56547 +timeCreated: 1440560539 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs new file mode 100644 index 0000000..1da2e0a --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs @@ -0,0 +1,48 @@ +using UnityEngine; +using UnityEditor; +using UnityEditorInternal; + +using System; +using System.IO; +using System.Collections; + +namespace XboxCtrlrInput.Editor { + static class InputManagerReplacer { + [MenuItem("Window/XboxCtrlrInput/Replace InputManager.asset...")] + static void ReplaceInputManagerAsset() { + + if (!EditorUtility.DisplayDialog("XboxCtrlrInput", + "This will replace ProjectSettings/InputManager.asset (a backup file will be created)", "Continue", "Cancel")) { + return; + } + + DirectoryInfo assetsDirectory = new DirectoryInfo("Assets"); + if (!assetsDirectory.Exists) { + Debug.LogError("Can't resolve 'Assets' directory"); + return; + } + + string projectSettingsPath = Path.Combine(assetsDirectory.Parent.FullName, "ProjectSettings"); + if (!Directory.Exists(projectSettingsPath)) { + Debug.LogError("Can't resolve 'ProjectSettings' directory"); + return; + } + + string settingsFilename = EditorSettings.serializationMode == SerializationMode.ForceText ? + "InputManagerText": "InputManagerBinary"; + string settingsFile = Path.Combine("Assets/Editor/XboxCtrlrInput/InputManager Copies", settingsFilename); + + if (!File.Exists(settingsFile)) { + Debug.LogError("Can't resolve '" + settingsFile + "' file"); + return; + } + + string originalSettingsFile = Path.Combine(projectSettingsPath, "InputManager.asset"); + string backupSettingsFile = originalSettingsFile + ".bak"; + File.Copy(originalSettingsFile, backupSettingsFile); + + File.Copy(settingsFile, originalSettingsFile, true); + Debug.Log("Backup file: " + backupSettingsFile); + } + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta new file mode 100644 index 0000000..6602121 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/InputManagerReplacer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43a927faec8464f51aed0b9ff796eb22 +timeCreated: 1440560595 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs new file mode 100644 index 0000000..48ba301 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs @@ -0,0 +1,81 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.IO; +using System.Collections.Generic; + +namespace XboxCtrlrInput.Editor { + + static class PackageExporter { + + static readonly string DefaultUnityPackageName = "XboxCtrlrInput"; // TODO: add auto incremental version + + static readonly string[] PackageIgnoredFiles = { + "Assets/Editor/XboxCtrlrInput/PackageExporter.cs" // don't include package exporter script + }; + + [MenuItem("Window/XboxCtrlrInput/Export Unity Package...")] + static void ExportUnityPackage() { + + string fileName = EditorUtility.SaveFilePanel("Save Unity Package", "Assets", DefaultUnityPackageName, "unitypackage"); + if (string.IsNullOrEmpty(fileName)) { + return; + } + + string[] assetPathNames = ListPackageFiles("Assets", PackageIgnoredFiles); + Debug.Log("Total package assets: " + assetPathNames.Length); + + AssetDatabase.ExportPackage(assetPathNames, fileName); + Debug.Log("Package written to '" + fileName + "'"); + } + + static string[] ListPackageFiles(string rootDir, params string[] ignoredFiles) { + return ListFiles(rootDir, delegate(string path) { + + // should we ignore path? + if (Array.IndexOf(ignoredFiles, path) != -1) { + return false; + } + + // skip meta files + if (path.EndsWith(".meta")) { + return false; + } + + // the rest is OK + return true; + }); + } + + #region File Helpers + + private delegate bool FilenameFilter(string path); + + private static string[] ListFiles(string directory, FilenameFilter filter) { + List list = new List(); + ListFiles(list, directory, filter); + return list.ToArray(); + } + + private static void ListFiles(List list, string directory, FilenameFilter filter) { + if (filter(directory)) { + list.Add(directory); + + string[] directories = Directory.GetDirectories(directory); + foreach (string child in directories) { + ListFiles(list, child, filter); + } + + string[] files = Directory.GetFiles(directory); + foreach (string file in files) { + if (filter(file)) { + list.Add(file); + } + } + } + } + + #endregion + } +} diff --git a/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta new file mode 100644 index 0000000..7af7243 --- /dev/null +++ b/FallUnity/Assets/Editor/XboxCtrlrInput/PackageExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4e18cff18eab4281b2f5dcb47c86b4a +timeCreated: 1440557553 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/GreenDebug.mat b/FallUnity/Assets/GreenDebug.mat new file mode 100644 index 0000000..0693894 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 1, b: 0.048275948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/GreenDebug.mat.meta b/FallUnity/Assets/GreenDebug.mat.meta new file mode 100644 index 0000000..9a06227 --- /dev/null +++ b/FallUnity/Assets/GreenDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d76887554d5b2e441b3ecb5e4e52b392 +timeCreated: 1572133489 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial deleted file mode 100644 index 29b2033..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial +++ /dev/null @@ -1,13 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!134 &13400000 -PhysicMaterial: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: GroundPhysics - dynamicFriction: 0.6 - staticFriction: 0.6 - bounciness: 0 - frictionCombine: 0 - bounceCombine: 0 diff --git a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta deleted file mode 100644 index c9dc77e..0000000 --- a/FallUnity/Assets/Ground/GroundPhysics.physicMaterial.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b7da08e26ab67394da4bd04c31cbe10a -timeCreated: 1572070851 -licenseType: Free -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 13400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial b/FallUnity/Assets/GroundPhysics.physicMaterial new file mode 100644 index 0000000..29b2033 --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial @@ -0,0 +1,13 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GroundPhysics + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/FallUnity/Assets/GroundPhysics.physicMaterial.meta b/FallUnity/Assets/GroundPhysics.physicMaterial.meta new file mode 100644 index 0000000..c9dc77e --- /dev/null +++ b/FallUnity/Assets/GroundPhysics.physicMaterial.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b7da08e26ab67394da4bd04c31cbe10a +timeCreated: 1572070851 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index 640f193..25c952e 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -1,45 +1,66 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; +[SelectionBase] public class IsoHandler : MonoBehaviour { - private HashSet sprites = new HashSet(); - private List spriteList = new List(); + private HashSet items = new HashSet(); + private List spriteList = new List(); + private List objectList = new List(); private Camera mainCamera; - public void AddIsoSprite(IsoSprite sprite) - { - if (sprites.Add(sprite)) - { - spriteList.Add(sprite); - } - } - public void RemoveIsoSprite(IsoSprite sprite) - { - if (sprites.Remove(sprite)) - { - spriteList.Remove(sprite); - } - } - private List pieceList = new List(); - public void AddIsoPiece(IsoPiece piece) - { - if (!pieceList.Contains(piece)) - { - pieceList.Add(piece); - } - } - public void RemoveIsoPiece(IsoPiece piece) - { - pieceList.Remove(piece); - } + public int ChunksX = 40; + public int ChunksY = 40; + private int numChunks; + + private List> chunks; + // Use this for initialization - void Start () { + void Start() + { + numChunks = ChunksX * ChunksY; mainCamera = GameObject.Find("Main Camera").GetComponent(); mainCamera.transparencySortMode = TransparencySortMode.Orthographic; - } - int SpriteSort(IsoSprite a, IsoSprite b) + chunks = new List>(); + for (int i = 0; i < numChunks; i++) + { + chunks.Add(new HashSet()); + } + } + + public void AddIsoItem(IsoItem item) + { + if (items.Add(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Add(item); + } + else + { + objectList.Add(item); + } + } + } + public void RemoveIsoItem(IsoItem item) + { + if (items.Remove(item)) + { + if (item.IsoType == IsoItem.IsoTypes.Sprite) + { + spriteList.Remove(item); + } + else + { + objectList.Remove(item); + } + } + } + + int ItemSort(IsoItem a, IsoItem b) { float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; @@ -47,20 +68,14 @@ return 0; } - int PieceSort(IsoPiece a, IsoPiece b) - { - float diff = b.CameraSpace.z - a.CameraSpace.z; - if (diff > 0) return 1; - if (diff < 0) return -1; - return 0; - } - - private List frontSort = new List(); private float nextDepth = 0; private Vector3 camForward; private Vector3 camRight; private Vector3 camUp; private Vector3 camPos; + private HashSet remaining = new HashSet(); + private List ordered = new List(); + private List tmpSort = new List(); void LateUpdate() { camForward = mainCamera.transform.forward; @@ -68,60 +83,147 @@ camUp = mainCamera.transform.up; camPos = mainCamera.transform.position; - frontSort.Clear(); - for (int i = 0; i < pieceList.Count; i++) + float worldSizeH = mainCamera.orthographicSize * 2; + float worldSizeW = worldSizeH * mainCamera.aspect; + + Vector3 worldBottomLeft = mainCamera.ViewportToWorldPoint(new Vector3()); + + remaining.Clear(); + ordered.Clear(); + + nextDepth = 10; + + for (int i = 0; i < spriteList.Count; i++) { - pieceList[i].Behind.Clear(); - pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); + spriteList[i].Behind.Clear(); + spriteList[i].MarkTemp = false; + spriteList[i].MarkPerm = false; + remaining.Add(spriteList[i]); + } + + for (int i = 0; i < objectList.Count; i++) + { + objectList[i].Behind.Clear(); + objectList[i].MarkTemp = false; + objectList[i].MarkPerm = false; + remaining.Add(objectList[i]); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); - } - spriteList.Sort(SpriteSort); + IsoItem item = spriteList[i]; + Vector3 screenSpace = mainCamera.WorldToViewportPoint(item.transform.position); + //item.CameraSpace.x = worldBottomLeft.x + screenSpace.x * worldSizeW; + //item.CameraSpace.y = worldBottomLeft.y + screenSpace.y * worldSizeH; + //item.CameraSpace.z = screenSpace.z; + item.CameraSpace = screenSpace; + if (item.IsoRadius > 0) + { + float scale = Mathf.Max(item.LinkedImage.transform.lossyScale.x, Mathf.Max(item.LinkedImage.transform.lossyScale.y, item.LinkedImage.transform.lossyScale.z)); + float radiusCamX = item.IsoRadius / worldSizeW * scale; + float radiusCamY = item.IsoRadius / worldSizeH * scale; + int leftBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Floor((screenSpace.x - radiusCamX) * ChunksX))); + int rightBucket = Mathf.Max(0, Mathf.Min(ChunksX - 1, (int)Mathf.Ceil((screenSpace.x + radiusCamX) * ChunksX))); - int layer = LayerMask.GetMask("iso_piece"); - RaycastHit hitInfo = new RaycastHit(); - for (int i = 0; i < spriteList.Count; i++) - { - IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) - { - IsoPiece piece = hitInfo.collider.GetComponentInParent(); - piece.Behind.Add(sprite); + int bottomBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Floor((screenSpace.y - radiusCamY) * ChunksY))); + int topBucket = Mathf.Max(0, Mathf.Min(ChunksY - 1, (int)Mathf.Ceil((screenSpace.y + radiusCamY) * ChunksY))); + + for (int x = leftBucket; x <= rightBucket; x++) + { + for (int y = bottomBucket; y <= topBucket; y++) + { + HashSet chunk = chunks[y * ChunksX + x]; ; + chunk.Add(item); + } + } } - else + + int layer = LayerMask.GetMask("iso_piece"); + RaycastHit hitInfo = new RaycastHit(); + if (Physics.Raycast(new Ray(item.transform.position, -camForward), out hitInfo, item.CameraSpace.z, layer)) { - frontSort.Add(sprite); + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + item.Behind.Add(otherItem); + } + } + if (Physics.Raycast(new Ray(item.transform.position, camForward), out hitInfo, 50, layer)) + { + IsoItem otherItem = hitInfo.collider.GetComponentInParent(); + if (otherItem != null) + { + otherItem.Behind.Add(item); + } + } + + } + + for (int i = 0; i < numChunks; i++) + { + if (chunks[i].Count > 0) + { + tmpSort.Clear(); + tmpSort.AddRange(chunks[i]); + chunks[i].Clear(); + tmpSort.Sort(ItemSort); + + for (int j = 0; j < tmpSort.Count - 1; j++) + { + tmpSort[j].Behind.Add(tmpSort[j + 1]); + if (tmpSort[j].CameraSpace.z < tmpSort[j + 1].CameraSpace.z) + { + bool bp = true; + } + } } } - pieceList.Sort(PieceSort); - - nextDepth = 50; - for (int i = 0; i < pieceList.Count; i++) + for (int i = 0; i < objectList.Count; i++) { - IsoPiece piece = pieceList[i]; - for (int j = 0; j < piece.Behind.Count; j++) - { - SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); - } - SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); + IsoItem item = objectList[i]; + item.CameraSpace = mainCamera.WorldToViewportPoint(item.LinkedImage.transform.position); } - for (int i = 0; i < frontSort.Count; i++) + objectList.Sort(ItemSort); + for (int i = 0; i < objectList.Count - 1; i++) { - SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); + objectList[i].Behind.Add(objectList[i + 1]); + } + + while (remaining.Count > 0) + { + IsoItem item = remaining.First(); + Visit(item); } } - private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) + private void Visit(IsoItem item) { - camPoint.z = nextDepth; + if (item.MarkPerm) return; + if (item.MarkTemp) + { + Debug.LogError("CYCLICAL RENDER GRAPH"); + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); + return; + } + item.MarkTemp = true; + foreach (IsoItem newItem in item.Behind) + { + Visit(newItem); + } + item.MarkTemp = false; + item.MarkPerm = true; + remaining.Remove(item); - setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); + item.SetDepth = nextDepth; - nextDepth -= 0.001f; + Vector3 camPos = item.CameraSpace; + camPos.z = nextDepth; + item.LinkedImage.transform.position = mainCamera.ViewportToWorldPoint(camPos); + + nextDepth += 0.01f; } } diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs b/FallUnity/Assets/IsoSorting/IsoItem.cs new file mode 100644 index 0000000..275a33c --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class IsoItem : MonoBehaviour +{ + public Vector3 CameraSpace; + public float SetDepth; + internal List Behind = new List(); + + public GameObject LinkedImage; + + public float IsoRadius = 0; + + public bool IsoPerspective = false; + + internal bool MarkTemp = false; + internal bool MarkPerm = false; + + public enum IsoTypes + { + Sprite, + Object + } + public IsoTypes IsoType; + + + void Start() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.AddIsoItem(this); + + if (IsoPerspective) + { + GameObject world = GameObject.Find("IsoWorld"); + LinkedImage.transform.parent = world.transform; + LinkedImage.transform.localRotation = Quaternion.identity; + } + + if (IsoType == IsoTypes.Sprite && IsoRadius == 0) + { + MeshFilter mf = LinkedImage.GetComponent(); + if (mf != null) + { + mf.sharedMesh.RecalculateBounds(); + float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); + float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); + float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); + IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); + } + } + } + + void Destroy() + { + IsoHandler iso = GameObject.FindObjectOfType(); + iso.RemoveIsoItem(this); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoItem.cs.meta b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta new file mode 100644 index 0000000..7a6c247 --- /dev/null +++ b/FallUnity/Assets/IsoSorting/IsoItem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b34189096d561ef48859c46a7d8eac3b +timeCreated: 1572118069 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs deleted file mode 100644 index 187e42c..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class IsoPiece : MonoBehaviour { - public bool ManualDepth = false; - public float Depth = 0; - - public GameObject LinkedImage; - - internal List Behind = new List(); - - internal Vector3 CameraSpace; - - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoPiece(this); - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoPiece(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta b/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta deleted file mode 100644 index 7a6c247..0000000 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: b34189096d561ef48859c46a7d8eac3b -timeCreated: 1572118069 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs deleted file mode 100644 index 1873476..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[SelectionBase] -public class IsoSprite : MonoBehaviour { - internal Vector3 CameraSpace; - public GameObject Mesh; - public bool IsoPerspective = false; - void Start() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.AddIsoSprite(this); - if (IsoPerspective) - { - GameObject world = GameObject.Find("IsoWorld"); - Mesh.transform.parent = world.transform; - Mesh.transform.localRotation = Quaternion.identity; - } - } - - void Destroy() - { - IsoHandler iso = GameObject.FindObjectOfType(); - iso.RemoveIsoSprite(this); - } - - // Update is called once per frame - void Update () { - - } -} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta b/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta deleted file mode 100644 index 6ed3fbf..0000000 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e9a79ce64cf72154b9b18d7d4cb18499 -timeCreated: 1572118210 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/FallUnity/Assets/Leaves/Leaf.prefab b/FallUnity/Assets/Leaves/Leaf.prefab index c2feeaf..804d87d 100755 --- a/FallUnity/Assets/Leaves/Leaf.prefab +++ b/FallUnity/Assets/Leaves/Leaf.prefab @@ -37,7 +37,7 @@ - component: {fileID: 4112338132911916} - component: {fileID: 54734295098261424} - component: {fileID: 114579094665962866} - - component: {fileID: 114772710203120024} + - component: {fileID: 114930901842287872} m_Layer: 10 m_Name: Leaf m_TagString: Untagged @@ -364,7 +364,7 @@ Debug: 0 BaseWindForce: 0.4 AnglePow: 2 ---- !u!114 &114772710203120024 +--- !u!114 &114930901842287872 MonoBehaviour: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} @@ -372,7 +372,12 @@ m_GameObject: {fileID: 1179573681969856} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - Mesh: {fileID: 1906529563300476} + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1906529563300476} + IsoRadius: 0.4 + IsoPerspective: 0 + IsoType: 0 diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab index 11e8bf5..f316914 100644 --- a/FallUnity/Assets/Player/Player.prefab +++ b/FallUnity/Assets/Player/Player.prefab @@ -20,7 +20,9 @@ m_Component: - component: {fileID: 4968172230546488} - component: {fileID: 114432391297954942} - - component: {fileID: 114045144791326304} + - component: {fileID: 114770286734950254} + - component: {fileID: 143677422544443006} + - component: {fileID: 114917061756029764} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -39,7 +41,7 @@ - component: {fileID: 33712194424262930} - component: {fileID: 136032829821990682} - component: {fileID: 23824139775216508} - m_Layer: 0 + m_Layer: 12 m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} @@ -96,7 +98,7 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1127561252628422} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.55, y: -1, z: 0.24} + m_LocalPosition: {x: 0.55, y: 2.34, z: 0.24} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4644232291033494} @@ -152,7 +154,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 30ca106f1a02e19498baabb238d01d50, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -186,19 +188,6 @@ m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1217361112803688} m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &114045144791326304 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1127561252628422} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e9a79ce64cf72154b9b18d7d4cb18499, type: 3} - m_Name: - m_EditorClassIdentifier: - Mesh: {fileID: 1369658487247200} - IsoPerspective: 1 --- !u!114 &114432391297954942 MonoBehaviour: m_ObjectHideFlags: 1 @@ -210,7 +199,7 @@ m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} m_Name: m_EditorClassIdentifier: - PixelScale: 0.1 + PixelScale: 0.01 Animations: - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} Frames: 1 @@ -219,6 +208,36 @@ Target: {fileID: 1369658487247200} Dir: 0 Frame: 0 +--- !u!114 &114770286734950254 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea63365dedf6a964a84060ee654bd095, type: 3} + m_Name: + m_EditorClassIdentifier: + Speed: 5 + Gravity: 6 +--- !u!114 &114917061756029764 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} + m_Name: + m_EditorClassIdentifier: + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 + LinkedImage: {fileID: 1369658487247200} + IsoRadius: 0 + IsoPerspective: 1 + IsoType: 0 --- !u!136 &136032829821990682 CapsuleCollider: m_ObjectHideFlags: 1 @@ -232,3 +251,20 @@ m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &143677422544443006 +CharacterController: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2.03 + m_Radius: 0.28 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.9, z: 0} diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs new file mode 100644 index 0000000..320138b --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using PlayerInput; +using UnityEngine; + +[SelectionBase] +public class PlayerController : MonoBehaviour { + public float Speed = 5; + public float Gravity = 7; + + private CharacterController charC; + private AnimationHandler anim; + // Use this for initialization + void Start () { + charC = GetComponent(); + anim = GetComponent(); + } + + private float velY = 0; + + // Update is called once per frame + void Update () { + Vector3 dir = new Vector3(); + if (input != null) + { + if (charC.isGrounded) + { + dir.x = input.Axis(InputSource.InputAxis.MoveX); + dir.z = input.Axis(InputSource.InputAxis.MoveY); + + if (dir.magnitude > 0.3f) + { + dir.Normalize(); + dir *= Speed; + + float angle = Mathf.Atan2(dir.z, dir.x); + + if (angle < 0) angle += Mathf.PI * 2; + + if (angle < Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpRight); + if (angle < Mathf.PI && angle >= Mathf.PI / 2.0f) anim.SetDir(AnimationHandler.Direction.UpLeft); + if (angle < Mathf.PI * 3.0f / 2.0f && angle >= Mathf.PI) anim.SetDir(AnimationHandler.Direction.DownLeft); + if (angle >= Mathf.PI * 3.0f / 2.0f) anim.SetDir(AnimationHandler.Direction.DownRight); + + //Debug.Log("ANGLE: " + angle); + } + else + { + dir.x = 0; + dir.z = 0; + } + } + } + + dir.y = velY; + + velY -= Gravity * Time.deltaTime; + + gameObject.layer = LayerMask.NameToLayer("player_controller_no_collide"); + charC.Move(dir * Time.deltaTime); + gameObject.layer = LayerMask.NameToLayer("player_controller"); + + if (charC.isGrounded) + { + velY = 0; + } + } + + private InputSource input = null; + private InputManager.PlayerInfo playerInfo; + public void SetInput(InputSource newPlayerInput, InputManager.PlayerInfo playerInfo) + { + this.input = newPlayerInput; + this.playerInfo = playerInfo; + } +} diff --git a/FallUnity/Assets/Player/PlayerController.cs.meta b/FallUnity/Assets/Player/PlayerController.cs.meta new file mode 100644 index 0000000..fba9751 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea63365dedf6a964a84060ee654bd095 +timeCreated: 1572134152 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta index a500262..6041752 100644 --- a/FallUnity/Assets/Player/PlayerStand.png.meta +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -8,7 +8,7 @@ serializedVersion: 4 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 sRGBTexture: 1 linearTexture: 0 fadeOut: 0 @@ -37,7 +37,7 @@ wrapU: -1 wrapV: -1 wrapW: -1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -65,6 +65,33 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/FallUnity/Assets/PlayerInput.meta b/FallUnity/Assets/PlayerInput.meta new file mode 100644 index 0000000..cf49f1a --- /dev/null +++ b/FallUnity/Assets/PlayerInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e1ae1bf354760b14d9657158ca981675 +folderAsset: yes +timeCreated: 1572133741 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs b/FallUnity/Assets/PlayerInput/InputManager.cs new file mode 100644 index 0000000..8baf8c4 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using System.Collections; +using XboxCtrlrInput; +using PlayerInput; +using System.Collections.Generic; +using System; +using System.Linq; + +namespace PlayerInput +{ + public class InputManager : MonoBehaviour + { + // TODO old + //public GameManager GameManager; + + public PlayerController PlayerPrefab; + + + // Use this for initialization + void Start() + { + // TODO old + //GameManager.OnResolutionChanged += ResolutionChanged; + + RegisterControllerToPlayer(XboxController.First, FindObjectOfType(), PotentialPlayers[0]); + } + + public enum UICorner + { + TopLeft, + TopRight, + BottomLeft, + BottomRight + } + + public struct PlayerInfo + { + public int ID; + //public UICorner Corner; + //public Color Color; + //public string TextureName; + //public string PortraitName; + } + + public static readonly List PotentialPlayers = new List + { + new PlayerInfo { ID = 1, /*Corner = UICorner.TopLeft, Color = Color.green */ }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, /*Corner = UICorner.TopRight, Color = Color.red */ }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, /*Corner = UICorner.BottomLeft, Color = Color.yellow */ }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, /*Corner = UICorner.BottomRight, Color = Color.cyan */ }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + + /* + new PlayerInfo { ID = 1, Corner = UICorner.TopLeft, Color = new Color(104 / 255.0f, 98 / 255.0f, 182 / 255.0f) }, //, TextureName = "WizardAquaTex", PortraitName = "PlayerPortraitTeal" }, + new PlayerInfo { ID = 2, Corner = UICorner.TopRight, Color = new Color(146 / 255.0f, 55 / 255.0f, 64 / 255.0f) }, //, TextureName = "WizardBlackTex", PortraitName = "PlayerPortraitBlack" }, + new PlayerInfo { ID = 3, Corner = UICorner.BottomLeft, Color = new Color(37 / 255.0f, 122 / 255.0f, 97 / 255.0f) }, //, TextureName = "WizardRedTex", PortraitName = "PlayerPortraitRed" }, + new PlayerInfo { ID = 4, Corner = UICorner.BottomRight, Color = new Color(234 / 255.0f, 242 / 255.0f, 183 / 255.0f) }, //, TextureName = "WizardWhiteTex", PortraitName = "PlayerPortraitWhite" }, + */ + }; + + private Dictionary> controllersToInput = new Dictionary>(); + private HashSet usedPlayers = new HashSet(); + + public IEnumerable ActivePlayers + { + get + { + return controllersToInput.Values.Select(source => source.Target); + } + } + + public Action OnPlayerAdded; + + // Update is called once per frame + void Update() + { + for (int i = 1; i <= 4; i++) + { + XboxController controller = (XboxController)i; + if (XCI.GetButtonDown(XboxButton.Start, controller)) + { + if (!controllersToInput.ContainsKey(controller)) + { + PlayerInfo? newPlayerInfo = null; + foreach (PlayerInfo info in PotentialPlayers) + { + if (!usedPlayers.Contains(info)) + { + newPlayerInfo = info; + break; + } + } + if (newPlayerInfo.HasValue) + { + PlayerController p = GameObject.Instantiate(PlayerPrefab).GetComponentInChildren(); + RegisterControllerToPlayer(controller, p, newPlayerInfo.Value); + } + } + } + } + } + + public void RegisterControllerToPlayer(XboxController controller, PlayerController p, PlayerInfo newPlayerInfo) + { + XboxControllerInputSource newPlayerInput = new XboxControllerInputSource(controller); + + p.SetInput(newPlayerInput, newPlayerInfo); + newPlayerInput.SetTarget(p); + controllersToInput.Add(controller, newPlayerInput); + + //GameManager.RootDrawable.addChild(p.UI); + + //LayoutUI(p.UI, p.UICorner); + + usedPlayers.Add(newPlayerInfo); + + if (OnPlayerAdded != null) OnPlayerAdded(); + } + + private void ResolutionChanged(int width, int height) + { + foreach (PlayerController player in controllersToInput.Values.Select(input => input.Target)) + { + //LayoutUI(player.UI, player.UICorner); + } + } + + // TODO old + /* + private void LayoutUI(Drawable ui, UICorner uiCorner) + { + switch (uiCorner) + { + case UICorner.TopLeft: + ui.X = 0; + ui.Y = 0; + break; + case UICorner.TopRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = 0; + break; + case UICorner.BottomLeft: + ui.X = 0; + ui.Y = GameSettings.ScreenHeight; + break; + case UICorner.BottomRight: + ui.X = GameSettings.ScreenWidth; + ui.Y = GameSettings.ScreenHeight; + break; + } + } + */ + } +} \ No newline at end of file diff --git a/FallUnity/Assets/PlayerInput/InputManager.cs.meta b/FallUnity/Assets/PlayerInput/InputManager.cs.meta new file mode 100644 index 0000000..91aa280 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 33ec797898b03244e94c917f9503fe39 +timeCreated: 1507955983 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs b/FallUnity/Assets/PlayerInput/InputSource.cs new file mode 100644 index 0000000..2cccceb --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace PlayerInput +{ + public abstract class InputSource where TTarget : MonoBehaviour + { + public enum InputButton + { + MenuSelect, + MenuCancel, + } + + public enum InputAxis + { + MoveX, + MoveY, + + MenuX, + MenuY, + + RakeX, + RakeY, + } + + public abstract bool ButtonPressedThisFrame(InputButton button); + public abstract bool ButtonReleasedThisFrame(InputButton button); + public abstract bool ButtonDown(InputButton button); + + public abstract float Axis(InputAxis axis); + + // TODO old + //private SimpleTimer vibrateTimer = new SimpleTimer(); + public void Vibrate(float time, float left, float right) + { + /* + vibrateTimer.Stop(); + VibrateInternal(left, right); + vibrateTimer.Start(time, () => VibrateInternal(0, 0)); + */ + } + + private TTarget target; + public TTarget Target { get { return target; } } + public void SetTarget(TTarget target) + { + if (this.target != target) + { + this.target = target; + TargetUpdated(target); + } + } + + protected virtual void TargetUpdated(TTarget target) + { + + } + + protected virtual void VibrateInternal(float left, float right) + { + + } + } +} diff --git a/FallUnity/Assets/PlayerInput/InputSource.cs.meta b/FallUnity/Assets/PlayerInput/InputSource.cs.meta new file mode 100644 index 0000000..a798ad2 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/InputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6a802d5613e1bc4892c95460650dfce +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs new file mode 100644 index 0000000..fc97956 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.Networking; + +namespace PlayerInput +{ + public class KeyboardMouseInputSource : InputSource where TTarget : MonoBehaviour + { + private Dictionary buttonMappingKeyboard; + private Dictionary buttonMappingMouse; + private KeyCode rangedActivateMapping; + private KeyCode fireMapping; + + private KeyboardAxis moveAxis; + private KeyboardAxis menuAxis; + + private GameObject mouseCenterObject; + + private float perspectiveCorrectY = 0.7f; + + protected override void TargetUpdated(TTarget target) + { + mouseCenterObject = target.gameObject; + } + + private struct KeyboardAxis + { + public KeyCode Right; + public KeyCode Up; + public KeyCode Left; + public KeyCode Down; + } + + public KeyboardMouseInputSource() + { + buttonMappingKeyboard = new Dictionary + { + { InputButton.MenuSelect, KeyCode.Return }, + { InputButton.MenuCancel, KeyCode.Escape }, + + //{ InputButton.UseItem, KeyCode.Space }, + //{ InputButton.PickA, KeyCode.Q }, + //{ InputButton.PickB, KeyCode.E }, + + //{ InputButton.AnimalSelector, KeyCode.LeftControl }, + }; + + buttonMappingMouse = new Dictionary + { + }; + + rangedActivateMapping = KeyCode.LeftShift; + + moveAxis = new KeyboardAxis() + { + Right = KeyCode.D, + Up = KeyCode.W, + Left = KeyCode.A, + Down = KeyCode.S, + }; + + menuAxis = new KeyboardAxis() + { + Right = KeyCode.RightArrow, + Up = KeyCode.UpArrow, + Left = KeyCode.LeftArrow, + Down = KeyCode.DownArrow, + }; + } + + public override float Axis(InputAxis axis) + { + switch (axis) + { + case InputAxis.MoveX: + return (Input.GetKey(moveAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MoveY: + return (Input.GetKey(moveAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(moveAxis.Down) ? -1.0f : 0.0f); + /* + case InputAxis.RangedX: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().x; + case InputAxis.RangedY: + if (!Input.GetKey(rangedActivateMapping)) return 0.0f; + return GetHeroToMouseVector().y; + */ + case InputAxis.MenuX: + return (Input.GetKey(menuAxis.Right) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Left) ? -1.0f : 0.0f); + case InputAxis.MenuY: + return (Input.GetKey(menuAxis.Up) ? 1.0f : 0.0f) + (Input.GetKey(menuAxis.Down) ? -1.0f : 0.0f); + //case InputAxis.Throttle: + // return Input.GetKey(fireMapping) ? 1.0f : 0.0f; + } + return 0; + } + + private Vector3 GetHeroToMouseVector() + { + if (mouseCenterObject == null) return new Vector3(); + Vector3 m = Input.mousePosition; + Vector3 p = mouseCenterObject.transform.position; + Vector3 w = Camera.main.WorldToScreenPoint(p); + Vector3 delta = m - w; + delta.y *= perspectiveCorrectY; + return delta.normalized; + } + + public override bool ButtonDown(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButton(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKey(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonDown(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyDown(buttonMappingKeyboard[button]); + return false; + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + if (buttonMappingMouse.ContainsKey(button)) return Input.GetMouseButtonUp(buttonMappingMouse[button]); + if (buttonMappingKeyboard.ContainsKey(button)) return Input.GetKeyUp(buttonMappingKeyboard[button]); + return false; + } + } +} diff --git a/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta new file mode 100644 index 0000000..2d0e145 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/KeyboardMouseInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ada75d1768d6fad4eb285bd538323380 +timeCreated: 1472582191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs new file mode 100644 index 0000000..1106813 --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using XboxCtrlrInput; + +namespace PlayerInput +{ + public class XboxControllerInputSource : InputSource where TTarget : MonoBehaviour + { + private static List allControllers; + public static IEnumerable AllControllers { get { return allControllers; } } + static XboxControllerInputSource() + { + allControllers = new List() + { + XboxController.First, + XboxController.Second, + XboxController.Third, + XboxController.Fourth, + }; + } + + private Dictionary buttonMapping; + private Dictionary axisMapping; + + private XboxController controller; + public XboxController Controller { get { return controller; } } + + public XboxControllerInputSource(XboxController controller) + { + this.controller = controller; + + buttonMapping = new Dictionary() + { + { InputButton.MenuSelect, XboxButton.A }, + { InputButton.MenuCancel, XboxButton.B }, + + //{ InputButton.UseItem, XboxButton.A }, + //{ InputButton.PickA, XboxButton.LeftBumper }, + //{ InputButton.PickB, XboxButton.RightBumper }, + + //{ InputButton.AnimalSelector, XboxButton.LeftBumper }, + }; + + axisMapping = new Dictionary() + { + { InputAxis.MenuX, XboxAxis.LeftStickX }, + { InputAxis.MenuY, XboxAxis.LeftStickY }, + + { InputAxis.RakeX, XboxAxis.RightStickX }, + { InputAxis.RakeY, XboxAxis.RightStickY }, + + { InputAxis.MoveX, XboxAxis.LeftStickX }, + { InputAxis.MoveY, XboxAxis.LeftStickY }, + + //{ InputAxis.Throttle, XboxAxis.RightTrigger }, + //{ InputAxis.RevThrottle, XboxAxis.LeftTrigger }, + }; + } + + protected override void VibrateInternal(float left, float right) + { + XCI.SetVibration(controller, left, right); + } + + public override bool ButtonPressedThisFrame(InputButton button) + { + return XCI.GetButtonDown(buttonMapping[button], controller); + } + + public override bool ButtonReleasedThisFrame(InputButton button) + { + return XCI.GetButtonUp(buttonMapping[button], controller); + } + + public override bool ButtonDown(InputButton button) + { + return XCI.GetButton(buttonMapping[button], controller); + } + + public override float Axis(InputAxis axis) + { + return XCI.GetAxis(axisMapping[axis], controller); + } + } +} diff --git a/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta new file mode 100644 index 0000000..9f6859f --- /dev/null +++ b/FallUnity/Assets/PlayerInput/XboxControllerInputSource.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ec7d070ee2898544aa46811e0e3da197 +timeCreated: 1472578955 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins.meta b/FallUnity/Assets/Plugins.meta new file mode 100644 index 0000000..b7025e8 --- /dev/null +++ b/FallUnity/Assets/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: dca2b803c244eb540bbf437959ae5f51 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll b/FallUnity/Assets/Plugins/XInputDotNetPure.dll new file mode 100644 index 0000000..d345520 --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta new file mode 100644 index 0000000..c87585b --- /dev/null +++ b/FallUnity/Assets/Plugins/XInputDotNetPure.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: a05c5d8086133f648a3dd3229d764a63 +timeCreated: 1572134134 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs new file mode 100644 index 0000000..69ee3a8 --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs @@ -0,0 +1,1969 @@ +using UnityEngine; +using UnityEngine.SceneManagement; + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN +using XInputDotNetPure; +#endif + +namespace XboxCtrlrInput +{ + + // ================= Enumerations ==================== // + + /// + /// List of enumerated identifiers for Xbox controllers. + /// + /// + /// Do NOT change enum values + /// + public enum XboxController + { + /// + /// "All" Controllers is deprecated! Use "Any" instead. + /// + [System.Obsolete("Instead use XboxController.Any")] + All = 0, + + Any = 0, + + First = 1, + Second = 2, + Third = 3, + Fourth = 4 + } + + /// + /// List of enumerated identifiers for Xbox buttons. + /// + public enum XboxButton + { + A, + B, + X, + Y, + Start, + Back, + LeftStick, + RightStick, + LeftBumper, + RightBumper, + DPadUp, + DPadDown, + DPadLeft, + DPadRight + } + + /// + /// List of enumerated identifiers for Xbox D-Pad directions. + /// + public enum XboxDPad + { + Up, + Down, + Left, + Right + } + + /// + /// List of enumerated identifiers for Xbox axis. + /// + public enum XboxAxis + { + LeftStickX, + LeftStickY, + RightStickX, + RightStickY, + LeftTrigger, + RightTrigger + } + + // ================ Classes =================== // + + public static class XCI + { + // ------------ Public Methods --------------- // + + public static bool SetVibration(XboxController controller, float left, float right) + { + + int controllerNumber = (int)controller; + + if (OnWindowsNative()) + { + GamePad.SetVibration((PlayerIndex)(controllerNumber - 1), left, right); + } + else + { + + } + + return false; + } + + // >>> For Buttons <<< // + + /// + /// Returns true if the specified button is held down by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButton(XboxButton button) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true if the specified button is held down by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButton(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPad(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButton(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKey(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonDown(XboxButton button) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button starts to press down (not held down) by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonDown(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadDown(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonDown(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Pressed ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyDown(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by any controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetButtonUp(XboxButton button) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad()); + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, 0); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetButtonUp(XboxButton button, XboxController controller) + { + if (button.IsDPad()) + return GetDPadUp(button.ToDPad(), controller); + + if (controller == XboxController.Any) + return GetButtonUp(button); + + int controllerNumber = (int)controller; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetButtonState(ctrlrState.Buttons, button) == ButtonState.Released ) && + ( XInputGetButtonState(ctrlrStatePrev.Buttons, button) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string btnCode = DetermineButtonCode(button, controllerNumber); + + if(Input.GetKeyUp(btnCode)) + { + return true; + } + } + + return false; + } + + // >>> For D-Pad <<< // + + /// + /// Returns true if the specified D-Pad direction is pressed down by any controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + public static bool GetDPad(XboxDPad padDirection) + { + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, 0); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + /// + /// Returns true if the specified D-Pad direction is pressed down by a specified controller. + /// + /// + /// An identifier for the specified D-Pad direction to be tested. + /// + /// + /// An identifier for the specific controller on which to test the D-Pad. + /// + public static bool GetDPad(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPad(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKey(inputCode); + } + else // Windows Web Player and Linux Wired Controller + { + inputCode = DetermineDPad(padDirection, controllerNumber); + + switch(padDirection) + { + case XboxDPad.Up: r = Input.GetAxis(inputCode) > 0; break; + case XboxDPad.Down: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Left: r = Input.GetAxis(inputCode) < 0; break; + case XboxDPad.Right: r = Input.GetAxis(inputCode) > 0; break; + + default: r = false; break; + } + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadUp(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is released by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadUp(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadUp(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Released ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Pressed ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyUp(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + public static bool GetDPadDown(XboxDPad padDirection) + { + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + GamePadState ctrlrStatePrev = XInputGetSingleStatePrev(); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless()) + { + inputCode = DetermineDPadWirelessLinux(padDirection, 0); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // From @ProjectEnder + /// + /// Returns true at the frame the specified button is Pressed by a specified controller. + /// Does NOT work on Linux with Wired Controllers. + /// + /// + /// Identifier for the Xbox button to be tested. + /// + /// + /// An identifier for the specific controller on which to test the button. + /// + public static bool GetDPadDown(XboxDPad padDirection, XboxController controller) + { + if (controller == XboxController.Any) + return GetDPadDown(padDirection); + + int controllerNumber = (int)controller; + + bool r = false; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(Time.frameCount < 2) + { + return false; + } + + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + GamePadState ctrlrStatePrev = XInputGetPaticularStatePrev(controllerNumber); + + if( ( XInputGetDPadState(ctrlrState.DPad, padDirection) == ButtonState.Pressed ) && + ( XInputGetDPadState(ctrlrStatePrev.DPad, padDirection) == ButtonState.Released ) ) + { + return true; + } + #endif + } + + else + { + string inputCode = ""; + + if(OnMac()) + { + inputCode = DetermineDPadMac(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else if(OnLinux() && IsControllerWireless(controllerNumber)) + { + inputCode = DetermineDPadWirelessLinux(padDirection, controllerNumber); + r = Input.GetKeyDown(inputCode); + } + else + { + //Place Holder for Wired Linux + r = false; + } + } + + return r; + } + + // >>> For Axis <<< // + + /// + /// Returns the analog number of the specified axis from any controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxis(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxis(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxis(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + + #endif + } + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxis(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from any controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + public static float GetAxisRaw(XboxAxis axis) + { + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetSingleState(); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, 0); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, 0); + } + + return r; + } + + /// + /// Returns the float number of the specified axis from a specified controller without Unity's smoothing filter. + /// + /// + /// An identifier for the specified Xbox axis to be tested. + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// + public static float GetAxisRaw(XboxAxis axis, XboxController controller) + { + if (controller == XboxController.Any) + return GetAxisRaw(axis); + + int controllerNumber = (int)controller; + + float r = 0.0f; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + if(axis == XboxAxis.LeftTrigger || axis == XboxAxis.RightTrigger) + { + r = XInputGetAxisState(ctrlrState.Triggers, axis); + } + else + { + r = XInputGetAxisState(ctrlrState.ThumbSticks, axis); + } + #endif + } + + else + { + string axisCode = DetermineAxisCode(axis, controllerNumber); + + r = Input.GetAxisRaw(axisCode); + r = AdjustAxisValues(r, axis, controllerNumber); + } + + return r; + } + + // >>> Other important functions <<< // + + /// + /// Returns the number of Xbox controllers plugged to the computer. + /// + public static int GetNumPluggedCtrlrs() + { + int r = 0; + + if(OnWindowsNative()) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(!xiNumOfCtrlrsQueried || !XInputStillInCurrFrame()) + { + xiNumOfCtrlrsQueried = true; + XInputUpdateAllStates(); + } + + for(int i = 0; i < 4; i++) + { + if(xInputCtrlrs[i].IsConnected) + { + r++; + } + } + #endif + } + + else + { + string[] ctrlrNames = Input.GetJoystickNames(); + for(int i = 0; i < ctrlrNames.Length; i++) + { + if(ctrlrNames[i].Contains("Xbox") || ctrlrNames[i].Contains("XBOX") || ctrlrNames[i].Contains("Microsoft")) + { + r++; + } + } + } + + return r; + } + + /// + /// DEBUG function. Log all controller names to Unity's console. + /// + public static void DEBUG_LogControllerNames() + { + string[] cNames = Input.GetJoystickNames(); + + for(int i = 0; i < cNames.Length; i++) + { + Debug.Log("Ctrlr " + i.ToString() + ": " + cNames[i]); + } + } + + + + + + // From @xoorath + /// + /// DEPRECATED: + /// Determines if the controller is plugged in the specified controllerNumber. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. An int between 1 and 4. + /// + [System.Obsolete("Instead use IsPluggedIn(XboxController)")] + public static bool IsPluggedIn(int controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + if(OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState = XInputGetPaticularState(controllerNumber); + + return ctrlrState.IsConnected; + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + // Based off @xoorath 's implementation + /// + /// Determines if the controller is plugged in the specified controllerNumber. + /// Passing Any will evaluate if any controller is connected. + /// CAUTION: Only works on Windows Native (Desktop and Editor)! + /// + /// + /// An identifier for the specific controller on which to test the axis. + /// Passing Any will evaluate if any controller is connected. + /// + public static bool IsPluggedIn(XboxController controllerNumber) + { + #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + { + if (OnWindowsNative()) + { + if (!XInputStillInCurrFrame()) + { + XInputUpdateAllStates(); + } + + GamePadState ctrlrState; + + + // If inquiring about any controller + + // TODO: Remove condition for XboxController.All when the time comes + // Users of XCI: Feel free to remove XboxController.All if you like having no warnings + if(controllerNumber == XboxController.Any || controllerNumber == XboxController.All) + { + // Examine all controllers it see if any are connected + for(int i = 1; i <= 4; i++) + { + ctrlrState = XInputGetPaticularState(i); + if(ctrlrState.IsConnected) + { + return true; + } + } + } + + + // If specifying a specific controller + + // Note: Casting only works if XboxController enums are values 1 to 4 (First, Second, Third, Fourth) + ctrlrState = XInputGetPaticularState((int)controllerNumber); + + return ctrlrState.IsConnected; + } + } + #endif + + // NOT IMPLEMENTED for other platforms + return false; + } + + + + + //// + // ------------- Private -------------- // + //// + + // ------------ Methods --------------- // + + private static bool OnMac() + { + // All Mac mappings are based off TattieBogle Xbox Controller drivers + // http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver + // http://wiki.unity3d.com/index.php?title=Xbox360Controller + return (Application.platform == RuntimePlatform.OSXEditor || + Application.platform == RuntimePlatform.OSXPlayer ); + } + + private static bool OnWindows() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnWindowsNative() + { + return (Application.platform == RuntimePlatform.WindowsEditor || + Application.platform == RuntimePlatform.WindowsPlayer ); + } + + private static bool OnLinux() + { + // Linux mapping based on observation of mapping from default drivers on Ubuntu 13.04 + return Application.platform == RuntimePlatform.LinuxPlayer; + } + + private static bool IsControllerWireless() + { + // 0 means for any controller + return IsControllerWireless(0); + } + + private static bool IsControllerWireless(int ctrlNum) + { + if (ctrlNum < 0 || ctrlNum > 4) return false; + + // If 0 is passed in, that assumes that only 1 controller is plugged in. + if(ctrlNum == 0) + { + return ( (string) Input.GetJoystickNames()[0]).Contains("Wireless"); + } + + return ( (string) Input.GetJoystickNames()[ctrlNum-1]).Contains("Wireless"); + } + + private static bool IsControllerNumberValid(int ctrlrNum) + { + if(ctrlrNum > 0 && ctrlrNum <= 4) + { + return true; + } + else + { + Debug.LogError("XCI.IsControllerNumberValid(): " + + "Invalid contoller number! Should be between 1 and 4."); + } + return false; + } + + private static float RefactorRange(float oldRangeValue, int ctrlrNum, XboxAxis axis) + { + // HACK: On OS X, Left and right trigger under OSX return 0.5 until touched + // Issue #16 on Github: https://github.com/JISyed/Unity-XboxCtrlrInput/issues/16 + if(XCI.OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4LeftIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + else if(axis == XboxAxis.RightTrigger) + { + switch(ctrlrNum) + { + case 0: + { + if(!XCI.XciHandler.Instance.u3dTrigger0RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger0RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 1: + { + if(!XCI.XciHandler.Instance.u3dTrigger1RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger1RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 2: + { + if(!XCI.XciHandler.Instance.u3dTrigger2RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger2RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 3: + { + if(!XCI.XciHandler.Instance.u3dTrigger3RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger3RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + case 4: + { + if(!XCI.XciHandler.Instance.u3dTrigger4RightIsTouched) + { + if(oldRangeValue != 0.0f) + { + XCI.XciHandler.Instance.u3dTrigger4RightIsTouched = true; + } + else + { + return 0.0f; + } + } + break; + } + default: + break; + } + } + } + + // Assumes you want to take a number from -1 to 1 range + // And turn it into a number from a 0 to 1 range + return ((oldRangeValue + 1.0f) / 2.0f ); + } + + private static string DetermineButtonCode(XboxButton btn, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sKeyCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + if(OnMac()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "16"; break; + case XboxButton.B: sKeyCode = "17"; break; + case XboxButton.X: sKeyCode = "18"; break; + case XboxButton.Y: sKeyCode = "19"; break; + case XboxButton.Start: sKeyCode = "9"; break; + case XboxButton.Back: sKeyCode = "10"; break; + case XboxButton.LeftStick: sKeyCode = "11"; break; + case XboxButton.RightStick: sKeyCode = "12"; break; + case XboxButton.LeftBumper: sKeyCode = "13"; break; + case XboxButton.RightBumper: sKeyCode = "14"; break; + + default: invalidCode = true; break; + } + } + else if (OnLinux()) + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "9"; break; + case XboxButton.RightStick: sKeyCode = "10"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(btn) + { + case XboxButton.A: sKeyCode = "0"; break; + case XboxButton.B: sKeyCode = "1"; break; + case XboxButton.X: sKeyCode = "2"; break; + case XboxButton.Y: sKeyCode = "3"; break; + case XboxButton.Start: sKeyCode = "7"; break; + case XboxButton.Back: sKeyCode = "6"; break; + case XboxButton.LeftStick: sKeyCode = "8"; break; + case XboxButton.RightStick: sKeyCode = "9"; break; + case XboxButton.LeftBumper: sKeyCode = "4"; break; + case XboxButton.RightBumper: sKeyCode = "5"; break; + + default: invalidCode = true; break; + } + } + + r = "joystick" + sJoyCode + " button " + sKeyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineAxisCode(XboxAxis axs, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sAxisCode = ""; + bool invalidCode = false; + + + if(OnMac()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "3"; break; + case XboxAxis.RightStickY: sAxisCode = "4"; break; + case XboxAxis.LeftTrigger: sAxisCode = "5"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else if(OnLinux()) + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "3"; break; + case XboxAxis.RightTrigger: sAxisCode = "6"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(axs) + { + case XboxAxis.LeftStickX: sAxisCode = "X"; break; + case XboxAxis.LeftStickY: sAxisCode = "Y"; break; + case XboxAxis.RightStickX: sAxisCode = "4"; break; + case XboxAxis.RightStickY: sAxisCode = "5"; break; + case XboxAxis.LeftTrigger: sAxisCode = "9"; break; + case XboxAxis.RightTrigger: sAxisCode = "10"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sAxisCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static float AdjustAxisValues(float axisValue, XboxAxis axis, int ctrlrNum) + { + float newAxisValue = axisValue; + + if(OnMac()) + { + if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = -newAxisValue; + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.RightStickY) + { + newAxisValue = -newAxisValue; + } + } + else if(OnLinux()) + { + if(axis == XboxAxis.RightTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + else if(axis == XboxAxis.LeftTrigger) + { + newAxisValue = RefactorRange(newAxisValue, ctrlrNum, axis); + } + } + + return newAxisValue; + } + + private static string DetermineDPad(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ctrlrNum.ToString(); + string sPadCode = ""; + bool invalidCode = false; + + if(OnLinux()) + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "8"; break; + case XboxDPad.Down: sPadCode = "8"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "7"; break; + + default: invalidCode = true; break; + } + } + else // Windows Web Player + { + switch(padDir) + { + case XboxDPad.Up: sPadCode = "7"; break; + case XboxDPad.Down: sPadCode = "7"; break; + case XboxDPad.Left: sPadCode = "6"; break; + case XboxDPad.Right: sPadCode = "6"; break; + + default: invalidCode = true; break; + } + } + + r = "XboxAxis" + sPadCode + "Joy" + sJoyCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadMac(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "5"; break; + case XboxDPad.Down: sPadCode = "6"; break; + case XboxDPad.Left: sPadCode = "7"; break; + case XboxDPad.Right: sPadCode = "8"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + private static string DetermineDPadWirelessLinux(XboxDPad padDir, int ctrlrNum) + { + string r = ""; + string sJoyCode = ""; + string sPadCode = ""; + bool invalidCode = false; + + if(ctrlrNum == 0) + { + sJoyCode = ""; + } + else + { + sJoyCode = " " + ctrlrNum.ToString(); + } + + switch(padDir) + { + case XboxDPad.Up: sPadCode = "13"; break; + case XboxDPad.Down: sPadCode = "14"; break; + case XboxDPad.Left: sPadCode = "11"; break; + case XboxDPad.Right: sPadCode = "12"; break; + + default: invalidCode = true; break; + } + + r = "joystick" + sJoyCode + " button " + sPadCode; + + if(invalidCode) + { + r = ""; + } + + return r; + } + + + // ------------- Private XInput Wrappers (for Windows Native player and editor only) -------------- // + +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + + // ------------ Inner Class ------------// + + // Used to setup XInput for Windows + class XciXInputInitializer + { + // Ctor + public XciXInputInitializer() + { + // Only runs once. + // Setup XInput here... + + + // Call input states twice in order to make sure that + // the previous states and current states are the same. + // This is needed to prevent errors where GetButtonUp will trigger unexpectledly + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + for (int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex)i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + } + + public void Dummy() + { + // Intentionally does nothing to prevent warnings + } + } + + + + // ------------ Members --------------- // + + // Windows variables + private static GamePadState[] xInputCtrlrs = new GamePadState[4]; + private static GamePadState[] xInputCtrlrsPrev = new GamePadState[4]; + private static int xiPrevFrameCount = -1; + private static bool xiUpdateAlreadyCalled = false; + private static bool xiNumOfCtrlrsQueried = false; + private static XciXInputInitializer xinputInitalizer = new XCI.XciXInputInitializer(); + + + + // This can be set to something different if you want + private const GamePadDeadZone WindowsDeadzoneMethod = GamePadDeadZone.Circular; + + + + // ------------ Methods --------------- // + + //>> For updating states << + + private static void XInputUpdateAllStates() + { + if(xiUpdateAlreadyCalled) return; + + for(int i = 0; i < 4; i++) + { + PlayerIndex plyNum = (PlayerIndex) i; + xInputCtrlrsPrev[i] = xInputCtrlrs[i]; + xInputCtrlrs[i] = GamePad.GetState(plyNum, XCI.WindowsDeadzoneMethod); + } + + xiUpdateAlreadyCalled = true; + } + + + //>> For getting states << + private static GamePadState XInputGetSingleState() + { + return xInputCtrlrs[0]; + } + + private static GamePadState XInputGetPaticularState(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrs[0]; + + return xInputCtrlrs[ctrlNum-1]; + } + + private static GamePadState XInputGetSingleStatePrev() + { + return xInputCtrlrsPrev[0]; + } + + private static GamePadState XInputGetPaticularStatePrev(int ctrlNum) + { + if (!IsControllerNumberValid(ctrlNum)) return xInputCtrlrsPrev[0]; + + return xInputCtrlrsPrev[ctrlNum-1]; + } + + //>> For getting input << + private static ButtonState XInputGetButtonState(GamePadButtons xiButtons, XboxButton xciBtn) + { + ButtonState stateToReturn = ButtonState.Pressed; + + switch(xciBtn) + { + case XboxButton.A: stateToReturn = xiButtons.A; break; + case XboxButton.B: stateToReturn = xiButtons.B; break; + case XboxButton.X: stateToReturn = xiButtons.X; break; + case XboxButton.Y: stateToReturn = xiButtons.Y; break; + case XboxButton.Start: stateToReturn = xiButtons.Start; break; + case XboxButton.Back: stateToReturn = xiButtons.Back; break; + case XboxButton.LeftBumper: stateToReturn = xiButtons.LeftShoulder; break; + case XboxButton.RightBumper: stateToReturn = xiButtons.RightShoulder; break; + case XboxButton.LeftStick: stateToReturn = xiButtons.LeftStick; break; + case XboxButton.RightStick: stateToReturn = xiButtons.RightStick; break; + } + + return stateToReturn; + } + + private static ButtonState XInputGetDPadState(GamePadDPad xiDPad, XboxDPad xciDPad) + { + ButtonState stateToReturn = ButtonState.Released; + + switch(xciDPad) + { + case XboxDPad.Up: stateToReturn = xiDPad.Up; break; + case XboxDPad.Down: stateToReturn = xiDPad.Down; break; + case XboxDPad.Left: stateToReturn = xiDPad.Left; break; + case XboxDPad.Right: stateToReturn = xiDPad.Right; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadTriggers xiTriggers, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftTrigger: stateToReturn = xiTriggers.Left; break; + case XboxAxis.RightTrigger: stateToReturn = xiTriggers.Right; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static float XInputGetAxisState(GamePadThumbSticks xiThumbSticks, XboxAxis xciAxis) + { + float stateToReturn = 0.0f; + + switch(xciAxis) + { + case XboxAxis.LeftStickX: stateToReturn = xiThumbSticks.Left.X; break; + case XboxAxis.LeftStickY: stateToReturn = xiThumbSticks.Left.Y; break; + case XboxAxis.RightStickX: stateToReturn = xiThumbSticks.Right.X; break; + case XboxAxis.RightStickY: stateToReturn = xiThumbSticks.Right.Y; break; + default: stateToReturn = 0.0f; break; + } + + return stateToReturn; + } + + private static bool XInputStillInCurrFrame() + { + bool r = false; + xinputInitalizer.Dummy(); // Stop warnings about not using the initilaizer + + // Get the current frame + int currFrame = Time.frameCount; + + // Are we still in the current frame? + if(xiPrevFrameCount == currFrame) + { + r = true; + } + else + { + r = false; + xiUpdateAlreadyCalled = false; + } + + // Assign the previous frame count regardless of whether it's the same or not. + xiPrevFrameCount = currFrame; + + return r; + } + + + #endif + + // END of Windows only subsystem ========================================== + + + + // -------------------------- Handler Script ------------------- + + // Secret Private Script that does some maintainace work for XCI states. User should not use this script at all. + private class XciHandler : MonoBehaviour + { + private static XciHandler instance = null; + + public bool u3dTrigger0LeftIsTouched = false; + public bool u3dTrigger0RightIsTouched = false; + public bool u3dTrigger1LeftIsTouched = false; + public bool u3dTrigger1RightIsTouched = false; + public bool u3dTrigger2LeftIsTouched = false; + public bool u3dTrigger2RightIsTouched = false; + public bool u3dTrigger3LeftIsTouched = false; + public bool u3dTrigger3RightIsTouched = false; + public bool u3dTrigger4LeftIsTouched = false; + public bool u3dTrigger4RightIsTouched = false; + + void Awake() + { + if(XciHandler.instance != null) + { + GameObject.Destroy(this.gameObject); + } + + XciHandler.instance = this; + + // Lives for the life of the game + DontDestroyOnLoad(this.gameObject); + } + + void OnEnable() + { + SceneManager.sceneLoaded += OnSceneFinishedLoading; + } + + void OnDisable() + { + SceneManager.sceneLoaded -= OnSceneFinishedLoading; + } + + // Callback made to replace obsolete method OnLevelWasLoaded(int) + void OnSceneFinishedLoading(Scene currentScene, LoadSceneMode mode) + { + this.ResetTriggerTouches(); + } + + void OnApplicationFocus(bool isWindowInFocusNow) + { + if(!isWindowInFocusNow) + { + this.ResetTriggerTouches(); + } + } + + private void ResetTriggerTouches() + { + this.u3dTrigger0LeftIsTouched = false; + this.u3dTrigger0RightIsTouched = false; + this.u3dTrigger1LeftIsTouched = false; + this.u3dTrigger1RightIsTouched = false; + this.u3dTrigger2LeftIsTouched = false; + this.u3dTrigger2RightIsTouched = false; + this.u3dTrigger3LeftIsTouched = false; + this.u3dTrigger3RightIsTouched = false; + this.u3dTrigger4LeftIsTouched = false; + this.u3dTrigger4RightIsTouched = false; + } + + public static XciHandler Instance + { + get + { + if(XciHandler.instance == null) + { + GameObject xciHandleObj = new GameObject("XboxCtrlrInput Handler Object"); + xciHandleObj.AddComponent(); + } + + return XciHandler.instance; + } + } + } // end of XciHandler + } // end of XCI + + public static class XboxButtonExtensions + { + public static bool IsDPad(this XboxButton button) + { + return (button == XboxButton.DPadUp || + button == XboxButton.DPadDown || + button == XboxButton.DPadLeft || + button == XboxButton.DPadRight); + } + + public static XboxDPad ToDPad(this XboxButton button) + { + if (button == XboxButton.DPadUp) + return XboxDPad.Up; + if (button == XboxButton.DPadDown) + return XboxDPad.Down; + if (button == XboxButton.DPadLeft) + return XboxDPad.Left; + if (button == XboxButton.DPadRight) + return XboxDPad.Right; + return default(XboxDPad); + } + + + } + + +} diff --git a/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta new file mode 100644 index 0000000..25d63aa --- /dev/null +++ b/FallUnity/Assets/Plugins/XboxCtrlrInput.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 928025f6ea24748418044e4479b4c446 +timeCreated: 1572134135 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64.meta b/FallUnity/Assets/Plugins/x86_64.meta new file mode 100644 index 0000000..fb502ad --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9cd457a246db3a2458768c6d00ed39e6 +folderAsset: yes +timeCreated: 1572134133 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll new file mode 100644 index 0000000..8a2d764 --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll Binary files differ diff --git a/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta new file mode 100644 index 0000000..88fa34e --- /dev/null +++ b/FallUnity/Assets/Plugins/x86_64/XInputInterface.dll.meta @@ -0,0 +1,95 @@ +fileFormatVersion: 2 +guid: ea895df4f09804d47ac0a43ce22418cb +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: ARMv7 + Any: + enabled: 1 + settings: + Exclude Android: 0 + Exclude Editor: 0 + Exclude Linux: 0 + Exclude Linux64: 0 + Exclude LinuxUniversal: 0 + Exclude OSXIntel: 0 + Exclude OSXIntel64: 0 + Exclude OSXUniversal: 0 + Exclude SamsungTV: 0 + Exclude Tizen: 0 + Exclude WebGL: 0 + Exclude Win: 1 + Exclude Win64: 0 + Exclude WindowsStoreApps: 0 + Exclude iOS: 0 + Editor: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 1 + settings: + CPU: None + Linux64: + enabled: 1 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel: + enabled: 1 + settings: + CPU: None + OSXIntel64: + enabled: 1 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 1 + settings: + CPU: AnyCPU + SamsungTV: + enabled: 1 + settings: + STV_MODEL: STANDARD_15 + Tizen: + enabled: 1 + settings: {} + WebGL: + enabled: 1 + settings: {} + Win: + enabled: 0 + settings: + CPU: None + Win64: + enabled: 1 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + iOS: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/RedDebug.mat b/FallUnity/Assets/RedDebug.mat new file mode 100644 index 0000000..7786680 --- /dev/null +++ b/FallUnity/Assets/RedDebug.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: RedDebug + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 0, b: 0, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/FallUnity/Assets/RedDebug.mat.meta b/FallUnity/Assets/RedDebug.mat.meta new file mode 100644 index 0000000..c65627f --- /dev/null +++ b/FallUnity/Assets/RedDebug.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 30ca106f1a02e19498baabb238d01d50 +timeCreated: 1572133462 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/XboxCtrlrInput.meta b/FallUnity/Assets/XboxCtrlrInput.meta new file mode 100644 index 0000000..7b92c68 --- /dev/null +++ b/FallUnity/Assets/XboxCtrlrInput.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 03c20217de43a304b9db30d8f9cf01af +folderAsset: yes +timeCreated: 1572134146 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/level.unity b/FallUnity/Assets/level.unity index eee2288..6f0f3c1 100755 --- a/FallUnity/Assets/level.unity +++ b/FallUnity/Assets/level.unity @@ -223,6 +223,8 @@ m_Script: {fileID: 11500000, guid: e9e45b67a184f38439d0136610b1d1cb, type: 3} m_Name: m_EditorClassIdentifier: + ChunksX: 20 + ChunksY: 20 --- !u!1 &257733088 GameObject: m_ObjectHideFlags: 0 @@ -365,9 +367,12 @@ m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - ManualDepth: 1 - Depth: 995 + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 LinkedImage: {fileID: 1777425976} + IsoRadius: 0 + IsoPerspective: 0 + IsoType: 1 --- !u!1 &418505720 GameObject: m_ObjectHideFlags: 0 @@ -405,14 +410,14 @@ m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 418505720} - m_Enabled: 1 + m_Enabled: 0 --- !u!124 &418505723 Behaviour: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 418505720} - m_Enabled: 1 + m_Enabled: 0 --- !u!20 &418505724 Camera: m_ObjectHideFlags: 0 @@ -744,7 +749,7 @@ m_GameObject: {fileID: 1076119174} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0.08, y: -0.41, z: -3.74} - m_LocalScale: {x: 13.190122, y: 1.2632968, z: 0.18388264} + m_LocalScale: {x: 13.190122, y: 1.7437512, z: 0.18388264} m_Children: [] m_Father: {fileID: 468371543} m_RootOrder: 0 @@ -763,7 +768,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: d76887554d5b2e441b3ecb5e4e52b392, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -813,9 +818,12 @@ m_Script: {fileID: 11500000, guid: b34189096d561ef48859c46a7d8eac3b, type: 3} m_Name: m_EditorClassIdentifier: - ManualDepth: 0 - Depth: 0 + CameraSpace: {x: 0, y: 0, z: 0} + SetDepth: 0 LinkedImage: {fileID: 1548969793} + IsoRadius: 0 + IsoPerspective: 0 + IsoType: 1 --- !u!1 &1206131915 GameObject: m_ObjectHideFlags: 0 @@ -857,7 +865,7 @@ m_Name: m_EditorClassIdentifier: Radius: 5 - Rate: 52.6 + Rate: 33.04 Leaf: {fileID: 114579094665962866, guid: 1701be1f15e160d4d904862548ae69de, type: 2} --- !u!1 &1272122407 GameObject: @@ -988,7 +996,7 @@ m_Depth: 0 m_CullingMask: serializedVersion: 2 - m_Bits: 4294964479 + m_Bits: 4294952191 m_RenderingPath: -1 m_TargetTexture: {fileID: 0} m_TargetDisplay: 0 @@ -1174,6 +1182,48 @@ m_Father: {fileID: 257733089} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1774596164 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1774596166} + - component: {fileID: 1774596165} + m_Layer: 0 + m_Name: InputManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1774596165 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1774596164} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 33ec797898b03244e94c917f9503fe39, type: 3} + m_Name: + m_EditorClassIdentifier: + PlayerPrefab: {fileID: 114770286734950254, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, + type: 2} +--- !u!4 &1774596166 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1774596164} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 24.684563, z: -35.583923} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1777425976 GameObject: m_ObjectHideFlags: 0 @@ -1242,15 +1292,15 @@ m_Modifications: - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} propertyPath: m_LocalPosition.x - value: 0.55 + value: -2.25 objectReference: {fileID: 0} - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} propertyPath: m_LocalPosition.y - value: -1 + value: -0.84 objectReference: {fileID: 0} - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} propertyPath: m_LocalPosition.z - value: 0.24 + value: -1.05 objectReference: {fileID: 0} - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} propertyPath: m_LocalRotation.x @@ -1272,19 +1322,6 @@ propertyPath: m_RootOrder value: 5 objectReference: {fileID: 0} - - target: {fileID: 114432391297954942, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, - type: 2} - propertyPath: PixelScale - value: 0.01 - objectReference: {fileID: 0} - - target: {fileID: 1217361112803688, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} - propertyPath: m_Layer - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1127561252628422, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} - propertyPath: m_IsActive - value: 0 - objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} m_IsPrefabParent: 0 diff --git a/FallUnity/ProjectSettings/DynamicsManager.asset b/FallUnity/ProjectSettings/DynamicsManager.asset index 4095a05..aec42ed 100755 --- a/FallUnity/ProjectSettings/DynamicsManager.asset +++ b/FallUnity/ProjectSettings/DynamicsManager.asset @@ -5,7 +5,7 @@ m_ObjectHideFlags: 0 serializedVersion: 3 m_Gravity: {x: 0, y: -2.55, z: 0} - m_DefaultMaterial: {fileID: 0} + m_DefaultMaterial: {fileID: 13400000, guid: b7da08e26ab67394da4bd04c31cbe10a, type: 2} m_BounceThreshold: 2 m_SleepThreshold: 0.005 m_DefaultContactOffset: 0.01 @@ -15,6 +15,6 @@ m_QueriesHitTriggers: 1 m_EnableAdaptiveForce: 0 m_EnablePCM: 1 - m_LayerCollisionMatrix: fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdbfffffffffffffffffffffffbffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff m_AutoSimulation: 1 m_AutoSyncTransforms: 1 diff --git a/FallUnity/ProjectSettings/TagManager.asset b/FallUnity/ProjectSettings/TagManager.asset index 74fe74e..64c03e1 100644 --- a/FallUnity/ProjectSettings/TagManager.asset +++ b/FallUnity/ProjectSettings/TagManager.asset @@ -17,8 +17,8 @@ - hide - leaf - iso_piece - - - - + - player_controller + - player_controller_no_collide - - - diff --git a/Flash/Player.fla b/Flash/Player.fla index 45fff20..2642f51 100644 --- a/Flash/Player.fla +++ b/Flash/Player.fla Binary files differ