diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs index 5898e50..187e42c 100644 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ b/FallUnity/Assets/IsoSorting/IsoPiece.cs @@ -1,16 +1,16 @@ -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 float CameraDepth; +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() { @@ -25,7 +25,7 @@ } // Update is called once per frame - void Update () { - - } -} + void Update () { + + } +} diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs index 5898e50..187e42c 100644 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ b/FallUnity/Assets/IsoSorting/IsoPiece.cs @@ -1,16 +1,16 @@ -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 float CameraDepth; +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() { @@ -25,7 +25,7 @@ } // Update is called once per frame - void Update () { - - } -} + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs index c82edcf..1873476 100644 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ b/FallUnity/Assets/IsoSorting/IsoSprite.cs @@ -2,13 +2,21 @@ using System.Collections.Generic; using UnityEngine; +[SelectionBase] public class IsoSprite : MonoBehaviour { - internal float CameraDepth; + 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() diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs index 5898e50..187e42c 100644 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ b/FallUnity/Assets/IsoSorting/IsoPiece.cs @@ -1,16 +1,16 @@ -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 float CameraDepth; +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() { @@ -25,7 +25,7 @@ } // Update is called once per frame - void Update () { - - } -} + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs index c82edcf..1873476 100644 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ b/FallUnity/Assets/IsoSorting/IsoSprite.cs @@ -2,13 +2,21 @@ using System.Collections.Generic; using UnityEngine; +[SelectionBase] public class IsoSprite : MonoBehaviour { - internal float CameraDepth; + 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() diff --git a/FallUnity/Assets/IsoSorting/LeafSpawner.cs b/FallUnity/Assets/IsoSorting/LeafSpawner.cs index 820fca1..9eee552 100644 --- a/FallUnity/Assets/IsoSorting/LeafSpawner.cs +++ b/FallUnity/Assets/IsoSorting/LeafSpawner.cs @@ -28,6 +28,9 @@ leaves.Add(leaf); leaf.transform.position = point; leaf.transform.rotation = Quaternion.Euler(new Vector3((Random.value - 0.5f) * 25, Random.value * 360, (Random.value - 0.5f) * 25)); + + float scale = Random.Range(0.9f, 1.3f); + leaf.transform.localScale = new Vector3(scale, scale, scale); } } diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs index 5898e50..187e42c 100644 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ b/FallUnity/Assets/IsoSorting/IsoPiece.cs @@ -1,16 +1,16 @@ -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 float CameraDepth; +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() { @@ -25,7 +25,7 @@ } // Update is called once per frame - void Update () { - - } -} + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs index c82edcf..1873476 100644 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ b/FallUnity/Assets/IsoSorting/IsoSprite.cs @@ -2,13 +2,21 @@ using System.Collections.Generic; using UnityEngine; +[SelectionBase] public class IsoSprite : MonoBehaviour { - internal float CameraDepth; + 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() diff --git a/FallUnity/Assets/IsoSorting/LeafSpawner.cs b/FallUnity/Assets/IsoSorting/LeafSpawner.cs index 820fca1..9eee552 100644 --- a/FallUnity/Assets/IsoSorting/LeafSpawner.cs +++ b/FallUnity/Assets/IsoSorting/LeafSpawner.cs @@ -28,6 +28,9 @@ leaves.Add(leaf); leaf.transform.position = point; leaf.transform.rotation = Quaternion.Euler(new Vector3((Random.value - 0.5f) * 25, Random.value * 360, (Random.value - 0.5f) * 25)); + + float scale = Random.Range(0.9f, 1.3f); + leaf.transform.localScale = new Vector3(scale, scale, scale); } } diff --git a/FallUnity/Assets/Leaves/LeafPhysics.cs b/FallUnity/Assets/Leaves/LeafPhysics.cs index 980971e..7dda907 100755 --- a/FallUnity/Assets/Leaves/LeafPhysics.cs +++ b/FallUnity/Assets/Leaves/LeafPhysics.cs @@ -86,39 +86,41 @@ // Update is called once per frame void Update () { - - if (Debug) + if (body.velocity.sqrMagnitude > 0.01f) { - bool bp = true; + if (Debug) + { + bool bp = true; + } + + float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); + + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); + + /* + if (body.velocity.y < -StartPushVelDown) + { + PushUpCurrent = PushUpForce; + } + + body.AddForce(Vector3.up * PushUpCurrent); + + PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); + */ + + float torqueX = -transform.up.x; + float torqueZ = -transform.up.z; + + float velYScale = Math.Max(0, -body.velocity.y); + + body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); + //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); + body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); + + body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } - - float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); - - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); - - /* - if (body.velocity.y < -StartPushVelDown) - { - PushUpCurrent = PushUpForce; - } - - body.AddForce(Vector3.up * PushUpCurrent); - - PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); - */ - - float torqueX = -transform.up.x; - float torqueZ = -transform.up.z; - - float velYScale = Math.Max(0, -body.velocity.y); - - body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); - //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); - body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); - - body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } } \ No newline at end of file diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs index 5898e50..187e42c 100644 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ b/FallUnity/Assets/IsoSorting/IsoPiece.cs @@ -1,16 +1,16 @@ -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 float CameraDepth; +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() { @@ -25,7 +25,7 @@ } // Update is called once per frame - void Update () { - - } -} + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs index c82edcf..1873476 100644 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ b/FallUnity/Assets/IsoSorting/IsoSprite.cs @@ -2,13 +2,21 @@ using System.Collections.Generic; using UnityEngine; +[SelectionBase] public class IsoSprite : MonoBehaviour { - internal float CameraDepth; + 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() diff --git a/FallUnity/Assets/IsoSorting/LeafSpawner.cs b/FallUnity/Assets/IsoSorting/LeafSpawner.cs index 820fca1..9eee552 100644 --- a/FallUnity/Assets/IsoSorting/LeafSpawner.cs +++ b/FallUnity/Assets/IsoSorting/LeafSpawner.cs @@ -28,6 +28,9 @@ leaves.Add(leaf); leaf.transform.position = point; leaf.transform.rotation = Quaternion.Euler(new Vector3((Random.value - 0.5f) * 25, Random.value * 360, (Random.value - 0.5f) * 25)); + + float scale = Random.Range(0.9f, 1.3f); + leaf.transform.localScale = new Vector3(scale, scale, scale); } } diff --git a/FallUnity/Assets/Leaves/LeafPhysics.cs b/FallUnity/Assets/Leaves/LeafPhysics.cs index 980971e..7dda907 100755 --- a/FallUnity/Assets/Leaves/LeafPhysics.cs +++ b/FallUnity/Assets/Leaves/LeafPhysics.cs @@ -86,39 +86,41 @@ // Update is called once per frame void Update () { - - if (Debug) + if (body.velocity.sqrMagnitude > 0.01f) { - bool bp = true; + if (Debug) + { + bool bp = true; + } + + float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); + + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); + + /* + if (body.velocity.y < -StartPushVelDown) + { + PushUpCurrent = PushUpForce; + } + + body.AddForce(Vector3.up * PushUpCurrent); + + PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); + */ + + float torqueX = -transform.up.x; + float torqueZ = -transform.up.z; + + float velYScale = Math.Max(0, -body.velocity.y); + + body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); + //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); + body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); + + body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } - - float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); - - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); - - /* - if (body.velocity.y < -StartPushVelDown) - { - PushUpCurrent = PushUpForce; - } - - body.AddForce(Vector3.up * PushUpCurrent); - - PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); - */ - - float torqueX = -transform.up.x; - float torqueZ = -transform.up.z; - - float velYScale = Math.Max(0, -body.velocity.y); - - body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); - //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); - body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); - - body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } } \ No newline at end of file diff --git a/FallUnity/Assets/Player.meta b/FallUnity/Assets/Player.meta new file mode 100644 index 0000000..aae7e98 --- /dev/null +++ b/FallUnity/Assets/Player.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 74568edad9b78934fa13e51935563f9b +folderAsset: yes +timeCreated: 1572128077 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs index 5898e50..187e42c 100644 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ b/FallUnity/Assets/IsoSorting/IsoPiece.cs @@ -1,16 +1,16 @@ -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 float CameraDepth; +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() { @@ -25,7 +25,7 @@ } // Update is called once per frame - void Update () { - - } -} + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs index c82edcf..1873476 100644 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ b/FallUnity/Assets/IsoSorting/IsoSprite.cs @@ -2,13 +2,21 @@ using System.Collections.Generic; using UnityEngine; +[SelectionBase] public class IsoSprite : MonoBehaviour { - internal float CameraDepth; + 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() diff --git a/FallUnity/Assets/IsoSorting/LeafSpawner.cs b/FallUnity/Assets/IsoSorting/LeafSpawner.cs index 820fca1..9eee552 100644 --- a/FallUnity/Assets/IsoSorting/LeafSpawner.cs +++ b/FallUnity/Assets/IsoSorting/LeafSpawner.cs @@ -28,6 +28,9 @@ leaves.Add(leaf); leaf.transform.position = point; leaf.transform.rotation = Quaternion.Euler(new Vector3((Random.value - 0.5f) * 25, Random.value * 360, (Random.value - 0.5f) * 25)); + + float scale = Random.Range(0.9f, 1.3f); + leaf.transform.localScale = new Vector3(scale, scale, scale); } } diff --git a/FallUnity/Assets/Leaves/LeafPhysics.cs b/FallUnity/Assets/Leaves/LeafPhysics.cs index 980971e..7dda907 100755 --- a/FallUnity/Assets/Leaves/LeafPhysics.cs +++ b/FallUnity/Assets/Leaves/LeafPhysics.cs @@ -86,39 +86,41 @@ // Update is called once per frame void Update () { - - if (Debug) + if (body.velocity.sqrMagnitude > 0.01f) { - bool bp = true; + if (Debug) + { + bool bp = true; + } + + float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); + + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); + + /* + if (body.velocity.y < -StartPushVelDown) + { + PushUpCurrent = PushUpForce; + } + + body.AddForce(Vector3.up * PushUpCurrent); + + PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); + */ + + float torqueX = -transform.up.x; + float torqueZ = -transform.up.z; + + float velYScale = Math.Max(0, -body.velocity.y); + + body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); + //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); + body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); + + body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } - - float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); - - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); - - /* - if (body.velocity.y < -StartPushVelDown) - { - PushUpCurrent = PushUpForce; - } - - body.AddForce(Vector3.up * PushUpCurrent); - - PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); - */ - - float torqueX = -transform.up.x; - float torqueZ = -transform.up.z; - - float velYScale = Math.Max(0, -body.velocity.y); - - body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); - //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); - body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); - - body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } } \ No newline at end of file diff --git a/FallUnity/Assets/Player.meta b/FallUnity/Assets/Player.meta new file mode 100644 index 0000000..aae7e98 --- /dev/null +++ b/FallUnity/Assets/Player.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 74568edad9b78934fa13e51935563f9b +folderAsset: yes +timeCreated: 1572128077 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials.meta b/FallUnity/Assets/Player/Materials.meta new file mode 100644 index 0000000..4eb4294 --- /dev/null +++ b/FallUnity/Assets/Player/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e90bde3d0c3f595438a5eb4ef7ebe2a3 +folderAsset: yes +timeCreated: 1572130006 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs index 5898e50..187e42c 100644 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ b/FallUnity/Assets/IsoSorting/IsoPiece.cs @@ -1,16 +1,16 @@ -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 float CameraDepth; +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() { @@ -25,7 +25,7 @@ } // Update is called once per frame - void Update () { - - } -} + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs index c82edcf..1873476 100644 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ b/FallUnity/Assets/IsoSorting/IsoSprite.cs @@ -2,13 +2,21 @@ using System.Collections.Generic; using UnityEngine; +[SelectionBase] public class IsoSprite : MonoBehaviour { - internal float CameraDepth; + 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() diff --git a/FallUnity/Assets/IsoSorting/LeafSpawner.cs b/FallUnity/Assets/IsoSorting/LeafSpawner.cs index 820fca1..9eee552 100644 --- a/FallUnity/Assets/IsoSorting/LeafSpawner.cs +++ b/FallUnity/Assets/IsoSorting/LeafSpawner.cs @@ -28,6 +28,9 @@ leaves.Add(leaf); leaf.transform.position = point; leaf.transform.rotation = Quaternion.Euler(new Vector3((Random.value - 0.5f) * 25, Random.value * 360, (Random.value - 0.5f) * 25)); + + float scale = Random.Range(0.9f, 1.3f); + leaf.transform.localScale = new Vector3(scale, scale, scale); } } diff --git a/FallUnity/Assets/Leaves/LeafPhysics.cs b/FallUnity/Assets/Leaves/LeafPhysics.cs index 980971e..7dda907 100755 --- a/FallUnity/Assets/Leaves/LeafPhysics.cs +++ b/FallUnity/Assets/Leaves/LeafPhysics.cs @@ -86,39 +86,41 @@ // Update is called once per frame void Update () { - - if (Debug) + if (body.velocity.sqrMagnitude > 0.01f) { - bool bp = true; + if (Debug) + { + bool bp = true; + } + + float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); + + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); + + /* + if (body.velocity.y < -StartPushVelDown) + { + PushUpCurrent = PushUpForce; + } + + body.AddForce(Vector3.up * PushUpCurrent); + + PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); + */ + + float torqueX = -transform.up.x; + float torqueZ = -transform.up.z; + + float velYScale = Math.Max(0, -body.velocity.y); + + body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); + //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); + body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); + + body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } - - float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); - - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); - - /* - if (body.velocity.y < -StartPushVelDown) - { - PushUpCurrent = PushUpForce; - } - - body.AddForce(Vector3.up * PushUpCurrent); - - PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); - */ - - float torqueX = -transform.up.x; - float torqueZ = -transform.up.z; - - float velYScale = Math.Max(0, -body.velocity.y); - - body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); - //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); - body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); - - body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } } \ No newline at end of file diff --git a/FallUnity/Assets/Player.meta b/FallUnity/Assets/Player.meta new file mode 100644 index 0000000..aae7e98 --- /dev/null +++ b/FallUnity/Assets/Player.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 74568edad9b78934fa13e51935563f9b +folderAsset: yes +timeCreated: 1572128077 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials.meta b/FallUnity/Assets/Player/Materials.meta new file mode 100644 index 0000000..4eb4294 --- /dev/null +++ b/FallUnity/Assets/Player/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e90bde3d0c3f595438a5eb4ef7ebe2a3 +folderAsset: yes +timeCreated: 1572130006 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat b/FallUnity/Assets/Player/Materials/PlayerStand.mat new file mode 100644 index 0000000..f806f40 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat @@ -0,0 +1,62 @@ +%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: PlayerStand + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BackTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DownTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _FrontTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _LeftTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _RightTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _UpTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - PixelSnap: 0 + - _EnableExternalAlpha: 0 + - _Exposure: 1 + - _Rotation: 0 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} + - _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 0.5} diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs index 5898e50..187e42c 100644 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ b/FallUnity/Assets/IsoSorting/IsoPiece.cs @@ -1,16 +1,16 @@ -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 float CameraDepth; +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() { @@ -25,7 +25,7 @@ } // Update is called once per frame - void Update () { - - } -} + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs index c82edcf..1873476 100644 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ b/FallUnity/Assets/IsoSorting/IsoSprite.cs @@ -2,13 +2,21 @@ using System.Collections.Generic; using UnityEngine; +[SelectionBase] public class IsoSprite : MonoBehaviour { - internal float CameraDepth; + 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() diff --git a/FallUnity/Assets/IsoSorting/LeafSpawner.cs b/FallUnity/Assets/IsoSorting/LeafSpawner.cs index 820fca1..9eee552 100644 --- a/FallUnity/Assets/IsoSorting/LeafSpawner.cs +++ b/FallUnity/Assets/IsoSorting/LeafSpawner.cs @@ -28,6 +28,9 @@ leaves.Add(leaf); leaf.transform.position = point; leaf.transform.rotation = Quaternion.Euler(new Vector3((Random.value - 0.5f) * 25, Random.value * 360, (Random.value - 0.5f) * 25)); + + float scale = Random.Range(0.9f, 1.3f); + leaf.transform.localScale = new Vector3(scale, scale, scale); } } diff --git a/FallUnity/Assets/Leaves/LeafPhysics.cs b/FallUnity/Assets/Leaves/LeafPhysics.cs index 980971e..7dda907 100755 --- a/FallUnity/Assets/Leaves/LeafPhysics.cs +++ b/FallUnity/Assets/Leaves/LeafPhysics.cs @@ -86,39 +86,41 @@ // Update is called once per frame void Update () { - - if (Debug) + if (body.velocity.sqrMagnitude > 0.01f) { - bool bp = true; + if (Debug) + { + bool bp = true; + } + + float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); + + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); + + /* + if (body.velocity.y < -StartPushVelDown) + { + PushUpCurrent = PushUpForce; + } + + body.AddForce(Vector3.up * PushUpCurrent); + + PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); + */ + + float torqueX = -transform.up.x; + float torqueZ = -transform.up.z; + + float velYScale = Math.Max(0, -body.velocity.y); + + body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); + //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); + body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); + + body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } - - float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); - - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); - - /* - if (body.velocity.y < -StartPushVelDown) - { - PushUpCurrent = PushUpForce; - } - - body.AddForce(Vector3.up * PushUpCurrent); - - PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); - */ - - float torqueX = -transform.up.x; - float torqueZ = -transform.up.z; - - float velYScale = Math.Max(0, -body.velocity.y); - - body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); - //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); - body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); - - body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } } \ No newline at end of file diff --git a/FallUnity/Assets/Player.meta b/FallUnity/Assets/Player.meta new file mode 100644 index 0000000..aae7e98 --- /dev/null +++ b/FallUnity/Assets/Player.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 74568edad9b78934fa13e51935563f9b +folderAsset: yes +timeCreated: 1572128077 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials.meta b/FallUnity/Assets/Player/Materials.meta new file mode 100644 index 0000000..4eb4294 --- /dev/null +++ b/FallUnity/Assets/Player/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e90bde3d0c3f595438a5eb4ef7ebe2a3 +folderAsset: yes +timeCreated: 1572130006 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat b/FallUnity/Assets/Player/Materials/PlayerStand.mat new file mode 100644 index 0000000..f806f40 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat @@ -0,0 +1,62 @@ +%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: PlayerStand + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BackTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DownTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _FrontTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _LeftTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _RightTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _UpTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - PixelSnap: 0 + - _EnableExternalAlpha: 0 + - _Exposure: 1 + - _Rotation: 0 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} + - _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 0.5} diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta new file mode 100644 index 0000000..5f32303 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 22b37cb1f671b1444b44cd6060a893a3 +timeCreated: 1572130006 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs index 5898e50..187e42c 100644 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ b/FallUnity/Assets/IsoSorting/IsoPiece.cs @@ -1,16 +1,16 @@ -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 float CameraDepth; +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() { @@ -25,7 +25,7 @@ } // Update is called once per frame - void Update () { - - } -} + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs index c82edcf..1873476 100644 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ b/FallUnity/Assets/IsoSorting/IsoSprite.cs @@ -2,13 +2,21 @@ using System.Collections.Generic; using UnityEngine; +[SelectionBase] public class IsoSprite : MonoBehaviour { - internal float CameraDepth; + 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() diff --git a/FallUnity/Assets/IsoSorting/LeafSpawner.cs b/FallUnity/Assets/IsoSorting/LeafSpawner.cs index 820fca1..9eee552 100644 --- a/FallUnity/Assets/IsoSorting/LeafSpawner.cs +++ b/FallUnity/Assets/IsoSorting/LeafSpawner.cs @@ -28,6 +28,9 @@ leaves.Add(leaf); leaf.transform.position = point; leaf.transform.rotation = Quaternion.Euler(new Vector3((Random.value - 0.5f) * 25, Random.value * 360, (Random.value - 0.5f) * 25)); + + float scale = Random.Range(0.9f, 1.3f); + leaf.transform.localScale = new Vector3(scale, scale, scale); } } diff --git a/FallUnity/Assets/Leaves/LeafPhysics.cs b/FallUnity/Assets/Leaves/LeafPhysics.cs index 980971e..7dda907 100755 --- a/FallUnity/Assets/Leaves/LeafPhysics.cs +++ b/FallUnity/Assets/Leaves/LeafPhysics.cs @@ -86,39 +86,41 @@ // Update is called once per frame void Update () { - - if (Debug) + if (body.velocity.sqrMagnitude > 0.01f) { - bool bp = true; + if (Debug) + { + bool bp = true; + } + + float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); + + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); + + /* + if (body.velocity.y < -StartPushVelDown) + { + PushUpCurrent = PushUpForce; + } + + body.AddForce(Vector3.up * PushUpCurrent); + + PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); + */ + + float torqueX = -transform.up.x; + float torqueZ = -transform.up.z; + + float velYScale = Math.Max(0, -body.velocity.y); + + body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); + //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); + body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); + + body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } - - float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); - - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); - - /* - if (body.velocity.y < -StartPushVelDown) - { - PushUpCurrent = PushUpForce; - } - - body.AddForce(Vector3.up * PushUpCurrent); - - PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); - */ - - float torqueX = -transform.up.x; - float torqueZ = -transform.up.z; - - float velYScale = Math.Max(0, -body.velocity.y); - - body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); - //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); - body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); - - body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } } \ No newline at end of file diff --git a/FallUnity/Assets/Player.meta b/FallUnity/Assets/Player.meta new file mode 100644 index 0000000..aae7e98 --- /dev/null +++ b/FallUnity/Assets/Player.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 74568edad9b78934fa13e51935563f9b +folderAsset: yes +timeCreated: 1572128077 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials.meta b/FallUnity/Assets/Player/Materials.meta new file mode 100644 index 0000000..4eb4294 --- /dev/null +++ b/FallUnity/Assets/Player/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e90bde3d0c3f595438a5eb4ef7ebe2a3 +folderAsset: yes +timeCreated: 1572130006 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat b/FallUnity/Assets/Player/Materials/PlayerStand.mat new file mode 100644 index 0000000..f806f40 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat @@ -0,0 +1,62 @@ +%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: PlayerStand + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BackTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DownTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _FrontTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _LeftTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _RightTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _UpTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - PixelSnap: 0 + - _EnableExternalAlpha: 0 + - _Exposure: 1 + - _Rotation: 0 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} + - _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 0.5} diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta new file mode 100644 index 0000000..5f32303 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 22b37cb1f671b1444b44cd6060a893a3 +timeCreated: 1572130006 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab new file mode 100644 index 0000000..11e8bf5 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab @@ -0,0 +1,234 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1127561252628422} + m_IsPrefabParent: 1 +--- !u!1 &1127561252628422 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4968172230546488} + - component: {fileID: 114432391297954942} + - component: {fileID: 114045144791326304} + m_Layer: 0 + m_Name: Player + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1217361112803688 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4644232291033494} + - component: {fileID: 33712194424262930} + - component: {fileID: 136032829821990682} + - component: {fileID: 23824139775216508} + m_Layer: 0 + m_Name: Cylinder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1369658487247200 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4834656431490232} + - component: {fileID: 33325744505029598} + - component: {fileID: 23509338961759882} + m_Layer: 0 + m_Name: Quad + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4644232291033494 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4834656431490232 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4968172230546488 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4644232291033494} + - {fileID: 4834656431490232} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23509338961759882 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 22b37cb1f671b1444b44cd6060a893a3, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!23 &23824139775216508 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &33325744505029598 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Mesh: {fileID: 0} +--- !u!33 &33712194424262930 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} + m_Name: + m_EditorClassIdentifier: + PixelScale: 0.1 + Animations: + - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + Frames: 1 + Offset: {x: 125, y: 300} + Name: Stand + Target: {fileID: 1369658487247200} + Dir: 0 + Frame: 0 +--- !u!136 &136032829821990682 +CapsuleCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.5 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs index 5898e50..187e42c 100644 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ b/FallUnity/Assets/IsoSorting/IsoPiece.cs @@ -1,16 +1,16 @@ -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 float CameraDepth; +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() { @@ -25,7 +25,7 @@ } // Update is called once per frame - void Update () { - - } -} + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs index c82edcf..1873476 100644 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ b/FallUnity/Assets/IsoSorting/IsoSprite.cs @@ -2,13 +2,21 @@ using System.Collections.Generic; using UnityEngine; +[SelectionBase] public class IsoSprite : MonoBehaviour { - internal float CameraDepth; + 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() diff --git a/FallUnity/Assets/IsoSorting/LeafSpawner.cs b/FallUnity/Assets/IsoSorting/LeafSpawner.cs index 820fca1..9eee552 100644 --- a/FallUnity/Assets/IsoSorting/LeafSpawner.cs +++ b/FallUnity/Assets/IsoSorting/LeafSpawner.cs @@ -28,6 +28,9 @@ leaves.Add(leaf); leaf.transform.position = point; leaf.transform.rotation = Quaternion.Euler(new Vector3((Random.value - 0.5f) * 25, Random.value * 360, (Random.value - 0.5f) * 25)); + + float scale = Random.Range(0.9f, 1.3f); + leaf.transform.localScale = new Vector3(scale, scale, scale); } } diff --git a/FallUnity/Assets/Leaves/LeafPhysics.cs b/FallUnity/Assets/Leaves/LeafPhysics.cs index 980971e..7dda907 100755 --- a/FallUnity/Assets/Leaves/LeafPhysics.cs +++ b/FallUnity/Assets/Leaves/LeafPhysics.cs @@ -86,39 +86,41 @@ // Update is called once per frame void Update () { - - if (Debug) + if (body.velocity.sqrMagnitude > 0.01f) { - bool bp = true; + if (Debug) + { + bool bp = true; + } + + float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); + + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); + + /* + if (body.velocity.y < -StartPushVelDown) + { + PushUpCurrent = PushUpForce; + } + + body.AddForce(Vector3.up * PushUpCurrent); + + PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); + */ + + float torqueX = -transform.up.x; + float torqueZ = -transform.up.z; + + float velYScale = Math.Max(0, -body.velocity.y); + + body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); + //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); + body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); + + body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } - - float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); - - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); - - /* - if (body.velocity.y < -StartPushVelDown) - { - PushUpCurrent = PushUpForce; - } - - body.AddForce(Vector3.up * PushUpCurrent); - - PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); - */ - - float torqueX = -transform.up.x; - float torqueZ = -transform.up.z; - - float velYScale = Math.Max(0, -body.velocity.y); - - body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); - //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); - body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); - - body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } } \ No newline at end of file diff --git a/FallUnity/Assets/Player.meta b/FallUnity/Assets/Player.meta new file mode 100644 index 0000000..aae7e98 --- /dev/null +++ b/FallUnity/Assets/Player.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 74568edad9b78934fa13e51935563f9b +folderAsset: yes +timeCreated: 1572128077 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials.meta b/FallUnity/Assets/Player/Materials.meta new file mode 100644 index 0000000..4eb4294 --- /dev/null +++ b/FallUnity/Assets/Player/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e90bde3d0c3f595438a5eb4ef7ebe2a3 +folderAsset: yes +timeCreated: 1572130006 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat b/FallUnity/Assets/Player/Materials/PlayerStand.mat new file mode 100644 index 0000000..f806f40 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat @@ -0,0 +1,62 @@ +%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: PlayerStand + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BackTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DownTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _FrontTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _LeftTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _RightTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _UpTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - PixelSnap: 0 + - _EnableExternalAlpha: 0 + - _Exposure: 1 + - _Rotation: 0 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} + - _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 0.5} diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta new file mode 100644 index 0000000..5f32303 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 22b37cb1f671b1444b44cd6060a893a3 +timeCreated: 1572130006 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab new file mode 100644 index 0000000..11e8bf5 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab @@ -0,0 +1,234 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1127561252628422} + m_IsPrefabParent: 1 +--- !u!1 &1127561252628422 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4968172230546488} + - component: {fileID: 114432391297954942} + - component: {fileID: 114045144791326304} + m_Layer: 0 + m_Name: Player + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1217361112803688 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4644232291033494} + - component: {fileID: 33712194424262930} + - component: {fileID: 136032829821990682} + - component: {fileID: 23824139775216508} + m_Layer: 0 + m_Name: Cylinder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1369658487247200 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4834656431490232} + - component: {fileID: 33325744505029598} + - component: {fileID: 23509338961759882} + m_Layer: 0 + m_Name: Quad + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4644232291033494 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4834656431490232 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4968172230546488 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4644232291033494} + - {fileID: 4834656431490232} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23509338961759882 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 22b37cb1f671b1444b44cd6060a893a3, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!23 &23824139775216508 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &33325744505029598 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Mesh: {fileID: 0} +--- !u!33 &33712194424262930 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} + m_Name: + m_EditorClassIdentifier: + PixelScale: 0.1 + Animations: + - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + Frames: 1 + Offset: {x: 125, y: 300} + Name: Stand + Target: {fileID: 1369658487247200} + Dir: 0 + Frame: 0 +--- !u!136 &136032829821990682 +CapsuleCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.5 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} diff --git a/FallUnity/Assets/Player/Player.prefab.meta b/FallUnity/Assets/Player/Player.prefab.meta new file mode 100644 index 0000000..0d6d363 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9f3dd22cf8fe21a43a067ab4b4ab708f +timeCreated: 1572129898 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs index 5898e50..187e42c 100644 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ b/FallUnity/Assets/IsoSorting/IsoPiece.cs @@ -1,16 +1,16 @@ -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 float CameraDepth; +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() { @@ -25,7 +25,7 @@ } // Update is called once per frame - void Update () { - - } -} + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs index c82edcf..1873476 100644 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ b/FallUnity/Assets/IsoSorting/IsoSprite.cs @@ -2,13 +2,21 @@ using System.Collections.Generic; using UnityEngine; +[SelectionBase] public class IsoSprite : MonoBehaviour { - internal float CameraDepth; + 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() diff --git a/FallUnity/Assets/IsoSorting/LeafSpawner.cs b/FallUnity/Assets/IsoSorting/LeafSpawner.cs index 820fca1..9eee552 100644 --- a/FallUnity/Assets/IsoSorting/LeafSpawner.cs +++ b/FallUnity/Assets/IsoSorting/LeafSpawner.cs @@ -28,6 +28,9 @@ leaves.Add(leaf); leaf.transform.position = point; leaf.transform.rotation = Quaternion.Euler(new Vector3((Random.value - 0.5f) * 25, Random.value * 360, (Random.value - 0.5f) * 25)); + + float scale = Random.Range(0.9f, 1.3f); + leaf.transform.localScale = new Vector3(scale, scale, scale); } } diff --git a/FallUnity/Assets/Leaves/LeafPhysics.cs b/FallUnity/Assets/Leaves/LeafPhysics.cs index 980971e..7dda907 100755 --- a/FallUnity/Assets/Leaves/LeafPhysics.cs +++ b/FallUnity/Assets/Leaves/LeafPhysics.cs @@ -86,39 +86,41 @@ // Update is called once per frame void Update () { - - if (Debug) + if (body.velocity.sqrMagnitude > 0.01f) { - bool bp = true; + if (Debug) + { + bool bp = true; + } + + float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); + + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); + + /* + if (body.velocity.y < -StartPushVelDown) + { + PushUpCurrent = PushUpForce; + } + + body.AddForce(Vector3.up * PushUpCurrent); + + PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); + */ + + float torqueX = -transform.up.x; + float torqueZ = -transform.up.z; + + float velYScale = Math.Max(0, -body.velocity.y); + + body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); + //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); + body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); + + body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } - - float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); - - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); - - /* - if (body.velocity.y < -StartPushVelDown) - { - PushUpCurrent = PushUpForce; - } - - body.AddForce(Vector3.up * PushUpCurrent); - - PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); - */ - - float torqueX = -transform.up.x; - float torqueZ = -transform.up.z; - - float velYScale = Math.Max(0, -body.velocity.y); - - body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); - //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); - body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); - - body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } } \ No newline at end of file diff --git a/FallUnity/Assets/Player.meta b/FallUnity/Assets/Player.meta new file mode 100644 index 0000000..aae7e98 --- /dev/null +++ b/FallUnity/Assets/Player.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 74568edad9b78934fa13e51935563f9b +folderAsset: yes +timeCreated: 1572128077 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials.meta b/FallUnity/Assets/Player/Materials.meta new file mode 100644 index 0000000..4eb4294 --- /dev/null +++ b/FallUnity/Assets/Player/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e90bde3d0c3f595438a5eb4ef7ebe2a3 +folderAsset: yes +timeCreated: 1572130006 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat b/FallUnity/Assets/Player/Materials/PlayerStand.mat new file mode 100644 index 0000000..f806f40 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat @@ -0,0 +1,62 @@ +%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: PlayerStand + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BackTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DownTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _FrontTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _LeftTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _RightTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _UpTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - PixelSnap: 0 + - _EnableExternalAlpha: 0 + - _Exposure: 1 + - _Rotation: 0 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} + - _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 0.5} diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta new file mode 100644 index 0000000..5f32303 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 22b37cb1f671b1444b44cd6060a893a3 +timeCreated: 1572130006 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab new file mode 100644 index 0000000..11e8bf5 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab @@ -0,0 +1,234 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1127561252628422} + m_IsPrefabParent: 1 +--- !u!1 &1127561252628422 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4968172230546488} + - component: {fileID: 114432391297954942} + - component: {fileID: 114045144791326304} + m_Layer: 0 + m_Name: Player + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1217361112803688 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4644232291033494} + - component: {fileID: 33712194424262930} + - component: {fileID: 136032829821990682} + - component: {fileID: 23824139775216508} + m_Layer: 0 + m_Name: Cylinder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1369658487247200 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4834656431490232} + - component: {fileID: 33325744505029598} + - component: {fileID: 23509338961759882} + m_Layer: 0 + m_Name: Quad + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4644232291033494 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4834656431490232 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4968172230546488 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4644232291033494} + - {fileID: 4834656431490232} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23509338961759882 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 22b37cb1f671b1444b44cd6060a893a3, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!23 &23824139775216508 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &33325744505029598 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Mesh: {fileID: 0} +--- !u!33 &33712194424262930 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} + m_Name: + m_EditorClassIdentifier: + PixelScale: 0.1 + Animations: + - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + Frames: 1 + Offset: {x: 125, y: 300} + Name: Stand + Target: {fileID: 1369658487247200} + Dir: 0 + Frame: 0 +--- !u!136 &136032829821990682 +CapsuleCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.5 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} diff --git a/FallUnity/Assets/Player/Player.prefab.meta b/FallUnity/Assets/Player/Player.prefab.meta new file mode 100644 index 0000000..0d6d363 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9f3dd22cf8fe21a43a067ab4b4ab708f +timeCreated: 1572129898 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerMat.mat b/FallUnity/Assets/Player/PlayerMat.mat new file mode 100644 index 0000000..2aeba5e --- /dev/null +++ b/FallUnity/Assets/Player/PlayerMat.mat @@ -0,0 +1,84 @@ +%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: PlayerMat + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _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: + - PixelSnap: 0 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _EnableExternalAlpha: 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: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs index 5898e50..187e42c 100644 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ b/FallUnity/Assets/IsoSorting/IsoPiece.cs @@ -1,16 +1,16 @@ -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 float CameraDepth; +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() { @@ -25,7 +25,7 @@ } // Update is called once per frame - void Update () { - - } -} + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs index c82edcf..1873476 100644 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ b/FallUnity/Assets/IsoSorting/IsoSprite.cs @@ -2,13 +2,21 @@ using System.Collections.Generic; using UnityEngine; +[SelectionBase] public class IsoSprite : MonoBehaviour { - internal float CameraDepth; + 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() diff --git a/FallUnity/Assets/IsoSorting/LeafSpawner.cs b/FallUnity/Assets/IsoSorting/LeafSpawner.cs index 820fca1..9eee552 100644 --- a/FallUnity/Assets/IsoSorting/LeafSpawner.cs +++ b/FallUnity/Assets/IsoSorting/LeafSpawner.cs @@ -28,6 +28,9 @@ leaves.Add(leaf); leaf.transform.position = point; leaf.transform.rotation = Quaternion.Euler(new Vector3((Random.value - 0.5f) * 25, Random.value * 360, (Random.value - 0.5f) * 25)); + + float scale = Random.Range(0.9f, 1.3f); + leaf.transform.localScale = new Vector3(scale, scale, scale); } } diff --git a/FallUnity/Assets/Leaves/LeafPhysics.cs b/FallUnity/Assets/Leaves/LeafPhysics.cs index 980971e..7dda907 100755 --- a/FallUnity/Assets/Leaves/LeafPhysics.cs +++ b/FallUnity/Assets/Leaves/LeafPhysics.cs @@ -86,39 +86,41 @@ // Update is called once per frame void Update () { - - if (Debug) + if (body.velocity.sqrMagnitude > 0.01f) { - bool bp = true; + if (Debug) + { + bool bp = true; + } + + float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); + + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); + + /* + if (body.velocity.y < -StartPushVelDown) + { + PushUpCurrent = PushUpForce; + } + + body.AddForce(Vector3.up * PushUpCurrent); + + PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); + */ + + float torqueX = -transform.up.x; + float torqueZ = -transform.up.z; + + float velYScale = Math.Max(0, -body.velocity.y); + + body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); + //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); + body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); + + body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } - - float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); - - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); - - /* - if (body.velocity.y < -StartPushVelDown) - { - PushUpCurrent = PushUpForce; - } - - body.AddForce(Vector3.up * PushUpCurrent); - - PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); - */ - - float torqueX = -transform.up.x; - float torqueZ = -transform.up.z; - - float velYScale = Math.Max(0, -body.velocity.y); - - body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); - //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); - body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); - - body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } } \ No newline at end of file diff --git a/FallUnity/Assets/Player.meta b/FallUnity/Assets/Player.meta new file mode 100644 index 0000000..aae7e98 --- /dev/null +++ b/FallUnity/Assets/Player.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 74568edad9b78934fa13e51935563f9b +folderAsset: yes +timeCreated: 1572128077 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials.meta b/FallUnity/Assets/Player/Materials.meta new file mode 100644 index 0000000..4eb4294 --- /dev/null +++ b/FallUnity/Assets/Player/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e90bde3d0c3f595438a5eb4ef7ebe2a3 +folderAsset: yes +timeCreated: 1572130006 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat b/FallUnity/Assets/Player/Materials/PlayerStand.mat new file mode 100644 index 0000000..f806f40 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat @@ -0,0 +1,62 @@ +%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: PlayerStand + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BackTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DownTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _FrontTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _LeftTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _RightTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _UpTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - PixelSnap: 0 + - _EnableExternalAlpha: 0 + - _Exposure: 1 + - _Rotation: 0 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} + - _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 0.5} diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta new file mode 100644 index 0000000..5f32303 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 22b37cb1f671b1444b44cd6060a893a3 +timeCreated: 1572130006 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab new file mode 100644 index 0000000..11e8bf5 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab @@ -0,0 +1,234 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1127561252628422} + m_IsPrefabParent: 1 +--- !u!1 &1127561252628422 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4968172230546488} + - component: {fileID: 114432391297954942} + - component: {fileID: 114045144791326304} + m_Layer: 0 + m_Name: Player + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1217361112803688 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4644232291033494} + - component: {fileID: 33712194424262930} + - component: {fileID: 136032829821990682} + - component: {fileID: 23824139775216508} + m_Layer: 0 + m_Name: Cylinder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1369658487247200 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4834656431490232} + - component: {fileID: 33325744505029598} + - component: {fileID: 23509338961759882} + m_Layer: 0 + m_Name: Quad + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4644232291033494 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4834656431490232 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4968172230546488 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4644232291033494} + - {fileID: 4834656431490232} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23509338961759882 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 22b37cb1f671b1444b44cd6060a893a3, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!23 &23824139775216508 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &33325744505029598 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Mesh: {fileID: 0} +--- !u!33 &33712194424262930 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} + m_Name: + m_EditorClassIdentifier: + PixelScale: 0.1 + Animations: + - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + Frames: 1 + Offset: {x: 125, y: 300} + Name: Stand + Target: {fileID: 1369658487247200} + Dir: 0 + Frame: 0 +--- !u!136 &136032829821990682 +CapsuleCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.5 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} diff --git a/FallUnity/Assets/Player/Player.prefab.meta b/FallUnity/Assets/Player/Player.prefab.meta new file mode 100644 index 0000000..0d6d363 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9f3dd22cf8fe21a43a067ab4b4ab708f +timeCreated: 1572129898 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerMat.mat b/FallUnity/Assets/Player/PlayerMat.mat new file mode 100644 index 0000000..2aeba5e --- /dev/null +++ b/FallUnity/Assets/Player/PlayerMat.mat @@ -0,0 +1,84 @@ +%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: PlayerMat + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _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: + - PixelSnap: 0 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _EnableExternalAlpha: 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: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} diff --git a/FallUnity/Assets/Player/PlayerMat.mat.meta b/FallUnity/Assets/Player/PlayerMat.mat.meta new file mode 100644 index 0000000..56210cd --- /dev/null +++ b/FallUnity/Assets/Player/PlayerMat.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 147767df5de196944a384ad0041f325e +timeCreated: 1572129629 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs index 5898e50..187e42c 100644 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ b/FallUnity/Assets/IsoSorting/IsoPiece.cs @@ -1,16 +1,16 @@ -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 float CameraDepth; +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() { @@ -25,7 +25,7 @@ } // Update is called once per frame - void Update () { - - } -} + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs index c82edcf..1873476 100644 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ b/FallUnity/Assets/IsoSorting/IsoSprite.cs @@ -2,13 +2,21 @@ using System.Collections.Generic; using UnityEngine; +[SelectionBase] public class IsoSprite : MonoBehaviour { - internal float CameraDepth; + 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() diff --git a/FallUnity/Assets/IsoSorting/LeafSpawner.cs b/FallUnity/Assets/IsoSorting/LeafSpawner.cs index 820fca1..9eee552 100644 --- a/FallUnity/Assets/IsoSorting/LeafSpawner.cs +++ b/FallUnity/Assets/IsoSorting/LeafSpawner.cs @@ -28,6 +28,9 @@ leaves.Add(leaf); leaf.transform.position = point; leaf.transform.rotation = Quaternion.Euler(new Vector3((Random.value - 0.5f) * 25, Random.value * 360, (Random.value - 0.5f) * 25)); + + float scale = Random.Range(0.9f, 1.3f); + leaf.transform.localScale = new Vector3(scale, scale, scale); } } diff --git a/FallUnity/Assets/Leaves/LeafPhysics.cs b/FallUnity/Assets/Leaves/LeafPhysics.cs index 980971e..7dda907 100755 --- a/FallUnity/Assets/Leaves/LeafPhysics.cs +++ b/FallUnity/Assets/Leaves/LeafPhysics.cs @@ -86,39 +86,41 @@ // Update is called once per frame void Update () { - - if (Debug) + if (body.velocity.sqrMagnitude > 0.01f) { - bool bp = true; + if (Debug) + { + bool bp = true; + } + + float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); + + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); + + /* + if (body.velocity.y < -StartPushVelDown) + { + PushUpCurrent = PushUpForce; + } + + body.AddForce(Vector3.up * PushUpCurrent); + + PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); + */ + + float torqueX = -transform.up.x; + float torqueZ = -transform.up.z; + + float velYScale = Math.Max(0, -body.velocity.y); + + body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); + //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); + body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); + + body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } - - float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); - - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); - - /* - if (body.velocity.y < -StartPushVelDown) - { - PushUpCurrent = PushUpForce; - } - - body.AddForce(Vector3.up * PushUpCurrent); - - PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); - */ - - float torqueX = -transform.up.x; - float torqueZ = -transform.up.z; - - float velYScale = Math.Max(0, -body.velocity.y); - - body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); - //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); - body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); - - body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } } \ No newline at end of file diff --git a/FallUnity/Assets/Player.meta b/FallUnity/Assets/Player.meta new file mode 100644 index 0000000..aae7e98 --- /dev/null +++ b/FallUnity/Assets/Player.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 74568edad9b78934fa13e51935563f9b +folderAsset: yes +timeCreated: 1572128077 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials.meta b/FallUnity/Assets/Player/Materials.meta new file mode 100644 index 0000000..4eb4294 --- /dev/null +++ b/FallUnity/Assets/Player/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e90bde3d0c3f595438a5eb4ef7ebe2a3 +folderAsset: yes +timeCreated: 1572130006 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat b/FallUnity/Assets/Player/Materials/PlayerStand.mat new file mode 100644 index 0000000..f806f40 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat @@ -0,0 +1,62 @@ +%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: PlayerStand + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BackTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DownTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _FrontTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _LeftTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _RightTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _UpTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - PixelSnap: 0 + - _EnableExternalAlpha: 0 + - _Exposure: 1 + - _Rotation: 0 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} + - _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 0.5} diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta new file mode 100644 index 0000000..5f32303 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 22b37cb1f671b1444b44cd6060a893a3 +timeCreated: 1572130006 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab new file mode 100644 index 0000000..11e8bf5 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab @@ -0,0 +1,234 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1127561252628422} + m_IsPrefabParent: 1 +--- !u!1 &1127561252628422 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4968172230546488} + - component: {fileID: 114432391297954942} + - component: {fileID: 114045144791326304} + m_Layer: 0 + m_Name: Player + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1217361112803688 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4644232291033494} + - component: {fileID: 33712194424262930} + - component: {fileID: 136032829821990682} + - component: {fileID: 23824139775216508} + m_Layer: 0 + m_Name: Cylinder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1369658487247200 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4834656431490232} + - component: {fileID: 33325744505029598} + - component: {fileID: 23509338961759882} + m_Layer: 0 + m_Name: Quad + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4644232291033494 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4834656431490232 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4968172230546488 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4644232291033494} + - {fileID: 4834656431490232} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23509338961759882 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 22b37cb1f671b1444b44cd6060a893a3, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!23 &23824139775216508 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &33325744505029598 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Mesh: {fileID: 0} +--- !u!33 &33712194424262930 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} + m_Name: + m_EditorClassIdentifier: + PixelScale: 0.1 + Animations: + - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + Frames: 1 + Offset: {x: 125, y: 300} + Name: Stand + Target: {fileID: 1369658487247200} + Dir: 0 + Frame: 0 +--- !u!136 &136032829821990682 +CapsuleCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.5 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} diff --git a/FallUnity/Assets/Player/Player.prefab.meta b/FallUnity/Assets/Player/Player.prefab.meta new file mode 100644 index 0000000..0d6d363 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9f3dd22cf8fe21a43a067ab4b4ab708f +timeCreated: 1572129898 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerMat.mat b/FallUnity/Assets/Player/PlayerMat.mat new file mode 100644 index 0000000..2aeba5e --- /dev/null +++ b/FallUnity/Assets/Player/PlayerMat.mat @@ -0,0 +1,84 @@ +%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: PlayerMat + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _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: + - PixelSnap: 0 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _EnableExternalAlpha: 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: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} diff --git a/FallUnity/Assets/Player/PlayerMat.mat.meta b/FallUnity/Assets/Player/PlayerMat.mat.meta new file mode 100644 index 0000000..56210cd --- /dev/null +++ b/FallUnity/Assets/Player/PlayerMat.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 147767df5de196944a384ad0041f325e +timeCreated: 1572129629 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png b/FallUnity/Assets/Player/PlayerStand.png new file mode 100644 index 0000000..667bc50 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerStand.png Binary files differ diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs index 5898e50..187e42c 100644 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ b/FallUnity/Assets/IsoSorting/IsoPiece.cs @@ -1,16 +1,16 @@ -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 float CameraDepth; +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() { @@ -25,7 +25,7 @@ } // Update is called once per frame - void Update () { - - } -} + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs index c82edcf..1873476 100644 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ b/FallUnity/Assets/IsoSorting/IsoSprite.cs @@ -2,13 +2,21 @@ using System.Collections.Generic; using UnityEngine; +[SelectionBase] public class IsoSprite : MonoBehaviour { - internal float CameraDepth; + 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() diff --git a/FallUnity/Assets/IsoSorting/LeafSpawner.cs b/FallUnity/Assets/IsoSorting/LeafSpawner.cs index 820fca1..9eee552 100644 --- a/FallUnity/Assets/IsoSorting/LeafSpawner.cs +++ b/FallUnity/Assets/IsoSorting/LeafSpawner.cs @@ -28,6 +28,9 @@ leaves.Add(leaf); leaf.transform.position = point; leaf.transform.rotation = Quaternion.Euler(new Vector3((Random.value - 0.5f) * 25, Random.value * 360, (Random.value - 0.5f) * 25)); + + float scale = Random.Range(0.9f, 1.3f); + leaf.transform.localScale = new Vector3(scale, scale, scale); } } diff --git a/FallUnity/Assets/Leaves/LeafPhysics.cs b/FallUnity/Assets/Leaves/LeafPhysics.cs index 980971e..7dda907 100755 --- a/FallUnity/Assets/Leaves/LeafPhysics.cs +++ b/FallUnity/Assets/Leaves/LeafPhysics.cs @@ -86,39 +86,41 @@ // Update is called once per frame void Update () { - - if (Debug) + if (body.velocity.sqrMagnitude > 0.01f) { - bool bp = true; + if (Debug) + { + bool bp = true; + } + + float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); + + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); + + /* + if (body.velocity.y < -StartPushVelDown) + { + PushUpCurrent = PushUpForce; + } + + body.AddForce(Vector3.up * PushUpCurrent); + + PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); + */ + + float torqueX = -transform.up.x; + float torqueZ = -transform.up.z; + + float velYScale = Math.Max(0, -body.velocity.y); + + body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); + //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); + body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); + + body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } - - float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); - - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); - - /* - if (body.velocity.y < -StartPushVelDown) - { - PushUpCurrent = PushUpForce; - } - - body.AddForce(Vector3.up * PushUpCurrent); - - PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); - */ - - float torqueX = -transform.up.x; - float torqueZ = -transform.up.z; - - float velYScale = Math.Max(0, -body.velocity.y); - - body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); - //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); - body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); - - body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } } \ No newline at end of file diff --git a/FallUnity/Assets/Player.meta b/FallUnity/Assets/Player.meta new file mode 100644 index 0000000..aae7e98 --- /dev/null +++ b/FallUnity/Assets/Player.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 74568edad9b78934fa13e51935563f9b +folderAsset: yes +timeCreated: 1572128077 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials.meta b/FallUnity/Assets/Player/Materials.meta new file mode 100644 index 0000000..4eb4294 --- /dev/null +++ b/FallUnity/Assets/Player/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e90bde3d0c3f595438a5eb4ef7ebe2a3 +folderAsset: yes +timeCreated: 1572130006 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat b/FallUnity/Assets/Player/Materials/PlayerStand.mat new file mode 100644 index 0000000..f806f40 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat @@ -0,0 +1,62 @@ +%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: PlayerStand + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BackTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DownTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _FrontTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _LeftTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _RightTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _UpTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - PixelSnap: 0 + - _EnableExternalAlpha: 0 + - _Exposure: 1 + - _Rotation: 0 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} + - _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 0.5} diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta new file mode 100644 index 0000000..5f32303 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 22b37cb1f671b1444b44cd6060a893a3 +timeCreated: 1572130006 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab new file mode 100644 index 0000000..11e8bf5 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab @@ -0,0 +1,234 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1127561252628422} + m_IsPrefabParent: 1 +--- !u!1 &1127561252628422 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4968172230546488} + - component: {fileID: 114432391297954942} + - component: {fileID: 114045144791326304} + m_Layer: 0 + m_Name: Player + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1217361112803688 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4644232291033494} + - component: {fileID: 33712194424262930} + - component: {fileID: 136032829821990682} + - component: {fileID: 23824139775216508} + m_Layer: 0 + m_Name: Cylinder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1369658487247200 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4834656431490232} + - component: {fileID: 33325744505029598} + - component: {fileID: 23509338961759882} + m_Layer: 0 + m_Name: Quad + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4644232291033494 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4834656431490232 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4968172230546488 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4644232291033494} + - {fileID: 4834656431490232} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23509338961759882 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 22b37cb1f671b1444b44cd6060a893a3, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!23 &23824139775216508 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &33325744505029598 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Mesh: {fileID: 0} +--- !u!33 &33712194424262930 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} + m_Name: + m_EditorClassIdentifier: + PixelScale: 0.1 + Animations: + - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + Frames: 1 + Offset: {x: 125, y: 300} + Name: Stand + Target: {fileID: 1369658487247200} + Dir: 0 + Frame: 0 +--- !u!136 &136032829821990682 +CapsuleCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.5 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} diff --git a/FallUnity/Assets/Player/Player.prefab.meta b/FallUnity/Assets/Player/Player.prefab.meta new file mode 100644 index 0000000..0d6d363 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9f3dd22cf8fe21a43a067ab4b4ab708f +timeCreated: 1572129898 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerMat.mat b/FallUnity/Assets/Player/PlayerMat.mat new file mode 100644 index 0000000..2aeba5e --- /dev/null +++ b/FallUnity/Assets/Player/PlayerMat.mat @@ -0,0 +1,84 @@ +%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: PlayerMat + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _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: + - PixelSnap: 0 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _EnableExternalAlpha: 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: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} diff --git a/FallUnity/Assets/Player/PlayerMat.mat.meta b/FallUnity/Assets/Player/PlayerMat.mat.meta new file mode 100644 index 0000000..56210cd --- /dev/null +++ b/FallUnity/Assets/Player/PlayerMat.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 147767df5de196944a384ad0041f325e +timeCreated: 1572129629 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png b/FallUnity/Assets/Player/PlayerStand.png new file mode 100644 index 0000000..667bc50 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerStand.png Binary files differ diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta new file mode 100644 index 0000000..a500262 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -0,0 +1,76 @@ +fileFormatVersion: 2 +guid: c1b50d664eb6c564ab4f8126c93ffbb3 +timeCreated: 1572128077 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs index 5898e50..187e42c 100644 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ b/FallUnity/Assets/IsoSorting/IsoPiece.cs @@ -1,16 +1,16 @@ -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 float CameraDepth; +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() { @@ -25,7 +25,7 @@ } // Update is called once per frame - void Update () { - - } -} + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs index c82edcf..1873476 100644 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ b/FallUnity/Assets/IsoSorting/IsoSprite.cs @@ -2,13 +2,21 @@ using System.Collections.Generic; using UnityEngine; +[SelectionBase] public class IsoSprite : MonoBehaviour { - internal float CameraDepth; + 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() diff --git a/FallUnity/Assets/IsoSorting/LeafSpawner.cs b/FallUnity/Assets/IsoSorting/LeafSpawner.cs index 820fca1..9eee552 100644 --- a/FallUnity/Assets/IsoSorting/LeafSpawner.cs +++ b/FallUnity/Assets/IsoSorting/LeafSpawner.cs @@ -28,6 +28,9 @@ leaves.Add(leaf); leaf.transform.position = point; leaf.transform.rotation = Quaternion.Euler(new Vector3((Random.value - 0.5f) * 25, Random.value * 360, (Random.value - 0.5f) * 25)); + + float scale = Random.Range(0.9f, 1.3f); + leaf.transform.localScale = new Vector3(scale, scale, scale); } } diff --git a/FallUnity/Assets/Leaves/LeafPhysics.cs b/FallUnity/Assets/Leaves/LeafPhysics.cs index 980971e..7dda907 100755 --- a/FallUnity/Assets/Leaves/LeafPhysics.cs +++ b/FallUnity/Assets/Leaves/LeafPhysics.cs @@ -86,39 +86,41 @@ // Update is called once per frame void Update () { - - if (Debug) + if (body.velocity.sqrMagnitude > 0.01f) { - bool bp = true; + if (Debug) + { + bool bp = true; + } + + float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); + + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); + + /* + if (body.velocity.y < -StartPushVelDown) + { + PushUpCurrent = PushUpForce; + } + + body.AddForce(Vector3.up * PushUpCurrent); + + PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); + */ + + float torqueX = -transform.up.x; + float torqueZ = -transform.up.z; + + float velYScale = Math.Max(0, -body.velocity.y); + + body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); + //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); + body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); + + body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } - - float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); - - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); - - /* - if (body.velocity.y < -StartPushVelDown) - { - PushUpCurrent = PushUpForce; - } - - body.AddForce(Vector3.up * PushUpCurrent); - - PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); - */ - - float torqueX = -transform.up.x; - float torqueZ = -transform.up.z; - - float velYScale = Math.Max(0, -body.velocity.y); - - body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); - //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); - body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); - - body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } } \ No newline at end of file diff --git a/FallUnity/Assets/Player.meta b/FallUnity/Assets/Player.meta new file mode 100644 index 0000000..aae7e98 --- /dev/null +++ b/FallUnity/Assets/Player.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 74568edad9b78934fa13e51935563f9b +folderAsset: yes +timeCreated: 1572128077 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials.meta b/FallUnity/Assets/Player/Materials.meta new file mode 100644 index 0000000..4eb4294 --- /dev/null +++ b/FallUnity/Assets/Player/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e90bde3d0c3f595438a5eb4ef7ebe2a3 +folderAsset: yes +timeCreated: 1572130006 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat b/FallUnity/Assets/Player/Materials/PlayerStand.mat new file mode 100644 index 0000000..f806f40 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat @@ -0,0 +1,62 @@ +%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: PlayerStand + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BackTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DownTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _FrontTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _LeftTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _RightTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _UpTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - PixelSnap: 0 + - _EnableExternalAlpha: 0 + - _Exposure: 1 + - _Rotation: 0 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} + - _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 0.5} diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta new file mode 100644 index 0000000..5f32303 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 22b37cb1f671b1444b44cd6060a893a3 +timeCreated: 1572130006 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab new file mode 100644 index 0000000..11e8bf5 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab @@ -0,0 +1,234 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1127561252628422} + m_IsPrefabParent: 1 +--- !u!1 &1127561252628422 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4968172230546488} + - component: {fileID: 114432391297954942} + - component: {fileID: 114045144791326304} + m_Layer: 0 + m_Name: Player + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1217361112803688 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4644232291033494} + - component: {fileID: 33712194424262930} + - component: {fileID: 136032829821990682} + - component: {fileID: 23824139775216508} + m_Layer: 0 + m_Name: Cylinder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1369658487247200 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4834656431490232} + - component: {fileID: 33325744505029598} + - component: {fileID: 23509338961759882} + m_Layer: 0 + m_Name: Quad + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4644232291033494 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4834656431490232 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4968172230546488 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4644232291033494} + - {fileID: 4834656431490232} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23509338961759882 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 22b37cb1f671b1444b44cd6060a893a3, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!23 &23824139775216508 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &33325744505029598 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Mesh: {fileID: 0} +--- !u!33 &33712194424262930 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} + m_Name: + m_EditorClassIdentifier: + PixelScale: 0.1 + Animations: + - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + Frames: 1 + Offset: {x: 125, y: 300} + Name: Stand + Target: {fileID: 1369658487247200} + Dir: 0 + Frame: 0 +--- !u!136 &136032829821990682 +CapsuleCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.5 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} diff --git a/FallUnity/Assets/Player/Player.prefab.meta b/FallUnity/Assets/Player/Player.prefab.meta new file mode 100644 index 0000000..0d6d363 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9f3dd22cf8fe21a43a067ab4b4ab708f +timeCreated: 1572129898 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerMat.mat b/FallUnity/Assets/Player/PlayerMat.mat new file mode 100644 index 0000000..2aeba5e --- /dev/null +++ b/FallUnity/Assets/Player/PlayerMat.mat @@ -0,0 +1,84 @@ +%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: PlayerMat + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _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: + - PixelSnap: 0 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _EnableExternalAlpha: 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: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} diff --git a/FallUnity/Assets/Player/PlayerMat.mat.meta b/FallUnity/Assets/Player/PlayerMat.mat.meta new file mode 100644 index 0000000..56210cd --- /dev/null +++ b/FallUnity/Assets/Player/PlayerMat.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 147767df5de196944a384ad0041f325e +timeCreated: 1572129629 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png b/FallUnity/Assets/Player/PlayerStand.png new file mode 100644 index 0000000..667bc50 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerStand.png Binary files differ diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta new file mode 100644 index 0000000..a500262 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -0,0 +1,76 @@ +fileFormatVersion: 2 +guid: c1b50d664eb6c564ab4f8126c93ffbb3 +timeCreated: 1572128077 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Utils/Utils.cs b/FallUnity/Assets/Utils/Utils.cs index 13d959e..6d0252a 100644 --- a/FallUnity/Assets/Utils/Utils.cs +++ b/FallUnity/Assets/Utils/Utils.cs @@ -4,15 +4,29 @@ public static class Utils { + /* public static float GetDepthInOrthoCam(GameObject g, Camera c) { return Vector3.Dot(g.transform.position - c.transform.position, c.transform.forward); } + public static float GetDepthIn(GameObject g, Vector3 pos, Vector3 forward) + { + return Vector3.Dot(g.transform.position - pos, forward); + } + public static Vector2 GetPosInOrthoCam(GameObject g, Camera c) { float x = Vector3.Dot(g.transform.position - c.transform.position, c.transform.right); float y = Vector3.Dot(g.transform.position - c.transform.position, c.transform.up); return new Vector2(x, y); } + + public static Vector2 GetPosIn(GameObject g, Vector3 pos, Vector3 right, Vector3 up) + { + float x = Vector3.Dot(g.transform.position - pos, right); + float y = Vector3.Dot(g.transform.position - pos, up); + return new Vector2(x, y); + } + */ } diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs index 5898e50..187e42c 100644 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ b/FallUnity/Assets/IsoSorting/IsoPiece.cs @@ -1,16 +1,16 @@ -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 float CameraDepth; +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() { @@ -25,7 +25,7 @@ } // Update is called once per frame - void Update () { - - } -} + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs index c82edcf..1873476 100644 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ b/FallUnity/Assets/IsoSorting/IsoSprite.cs @@ -2,13 +2,21 @@ using System.Collections.Generic; using UnityEngine; +[SelectionBase] public class IsoSprite : MonoBehaviour { - internal float CameraDepth; + 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() diff --git a/FallUnity/Assets/IsoSorting/LeafSpawner.cs b/FallUnity/Assets/IsoSorting/LeafSpawner.cs index 820fca1..9eee552 100644 --- a/FallUnity/Assets/IsoSorting/LeafSpawner.cs +++ b/FallUnity/Assets/IsoSorting/LeafSpawner.cs @@ -28,6 +28,9 @@ leaves.Add(leaf); leaf.transform.position = point; leaf.transform.rotation = Quaternion.Euler(new Vector3((Random.value - 0.5f) * 25, Random.value * 360, (Random.value - 0.5f) * 25)); + + float scale = Random.Range(0.9f, 1.3f); + leaf.transform.localScale = new Vector3(scale, scale, scale); } } diff --git a/FallUnity/Assets/Leaves/LeafPhysics.cs b/FallUnity/Assets/Leaves/LeafPhysics.cs index 980971e..7dda907 100755 --- a/FallUnity/Assets/Leaves/LeafPhysics.cs +++ b/FallUnity/Assets/Leaves/LeafPhysics.cs @@ -86,39 +86,41 @@ // Update is called once per frame void Update () { - - if (Debug) + if (body.velocity.sqrMagnitude > 0.01f) { - bool bp = true; + if (Debug) + { + bool bp = true; + } + + float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); + + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); + + /* + if (body.velocity.y < -StartPushVelDown) + { + PushUpCurrent = PushUpForce; + } + + body.AddForce(Vector3.up * PushUpCurrent); + + PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); + */ + + float torqueX = -transform.up.x; + float torqueZ = -transform.up.z; + + float velYScale = Math.Max(0, -body.velocity.y); + + body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); + //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); + body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); + + body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } - - float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); - - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); - - /* - if (body.velocity.y < -StartPushVelDown) - { - PushUpCurrent = PushUpForce; - } - - body.AddForce(Vector3.up * PushUpCurrent); - - PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); - */ - - float torqueX = -transform.up.x; - float torqueZ = -transform.up.z; - - float velYScale = Math.Max(0, -body.velocity.y); - - body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); - //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); - body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); - - body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } } \ No newline at end of file diff --git a/FallUnity/Assets/Player.meta b/FallUnity/Assets/Player.meta new file mode 100644 index 0000000..aae7e98 --- /dev/null +++ b/FallUnity/Assets/Player.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 74568edad9b78934fa13e51935563f9b +folderAsset: yes +timeCreated: 1572128077 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials.meta b/FallUnity/Assets/Player/Materials.meta new file mode 100644 index 0000000..4eb4294 --- /dev/null +++ b/FallUnity/Assets/Player/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e90bde3d0c3f595438a5eb4ef7ebe2a3 +folderAsset: yes +timeCreated: 1572130006 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat b/FallUnity/Assets/Player/Materials/PlayerStand.mat new file mode 100644 index 0000000..f806f40 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat @@ -0,0 +1,62 @@ +%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: PlayerStand + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BackTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DownTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _FrontTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _LeftTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _RightTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _UpTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - PixelSnap: 0 + - _EnableExternalAlpha: 0 + - _Exposure: 1 + - _Rotation: 0 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} + - _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 0.5} diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta new file mode 100644 index 0000000..5f32303 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 22b37cb1f671b1444b44cd6060a893a3 +timeCreated: 1572130006 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab new file mode 100644 index 0000000..11e8bf5 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab @@ -0,0 +1,234 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1127561252628422} + m_IsPrefabParent: 1 +--- !u!1 &1127561252628422 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4968172230546488} + - component: {fileID: 114432391297954942} + - component: {fileID: 114045144791326304} + m_Layer: 0 + m_Name: Player + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1217361112803688 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4644232291033494} + - component: {fileID: 33712194424262930} + - component: {fileID: 136032829821990682} + - component: {fileID: 23824139775216508} + m_Layer: 0 + m_Name: Cylinder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1369658487247200 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4834656431490232} + - component: {fileID: 33325744505029598} + - component: {fileID: 23509338961759882} + m_Layer: 0 + m_Name: Quad + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4644232291033494 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4834656431490232 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4968172230546488 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4644232291033494} + - {fileID: 4834656431490232} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23509338961759882 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 22b37cb1f671b1444b44cd6060a893a3, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!23 &23824139775216508 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &33325744505029598 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Mesh: {fileID: 0} +--- !u!33 &33712194424262930 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} + m_Name: + m_EditorClassIdentifier: + PixelScale: 0.1 + Animations: + - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + Frames: 1 + Offset: {x: 125, y: 300} + Name: Stand + Target: {fileID: 1369658487247200} + Dir: 0 + Frame: 0 +--- !u!136 &136032829821990682 +CapsuleCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.5 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} diff --git a/FallUnity/Assets/Player/Player.prefab.meta b/FallUnity/Assets/Player/Player.prefab.meta new file mode 100644 index 0000000..0d6d363 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9f3dd22cf8fe21a43a067ab4b4ab708f +timeCreated: 1572129898 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerMat.mat b/FallUnity/Assets/Player/PlayerMat.mat new file mode 100644 index 0000000..2aeba5e --- /dev/null +++ b/FallUnity/Assets/Player/PlayerMat.mat @@ -0,0 +1,84 @@ +%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: PlayerMat + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _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: + - PixelSnap: 0 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _EnableExternalAlpha: 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: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} diff --git a/FallUnity/Assets/Player/PlayerMat.mat.meta b/FallUnity/Assets/Player/PlayerMat.mat.meta new file mode 100644 index 0000000..56210cd --- /dev/null +++ b/FallUnity/Assets/Player/PlayerMat.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 147767df5de196944a384ad0041f325e +timeCreated: 1572129629 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png b/FallUnity/Assets/Player/PlayerStand.png new file mode 100644 index 0000000..667bc50 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerStand.png Binary files differ diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta new file mode 100644 index 0000000..a500262 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -0,0 +1,76 @@ +fileFormatVersion: 2 +guid: c1b50d664eb6c564ab4f8126c93ffbb3 +timeCreated: 1572128077 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Utils/Utils.cs b/FallUnity/Assets/Utils/Utils.cs index 13d959e..6d0252a 100644 --- a/FallUnity/Assets/Utils/Utils.cs +++ b/FallUnity/Assets/Utils/Utils.cs @@ -4,15 +4,29 @@ public static class Utils { + /* public static float GetDepthInOrthoCam(GameObject g, Camera c) { return Vector3.Dot(g.transform.position - c.transform.position, c.transform.forward); } + public static float GetDepthIn(GameObject g, Vector3 pos, Vector3 forward) + { + return Vector3.Dot(g.transform.position - pos, forward); + } + public static Vector2 GetPosInOrthoCam(GameObject g, Camera c) { float x = Vector3.Dot(g.transform.position - c.transform.position, c.transform.right); float y = Vector3.Dot(g.transform.position - c.transform.position, c.transform.up); return new Vector2(x, y); } + + public static Vector2 GetPosIn(GameObject g, Vector3 pos, Vector3 right, Vector3 up) + { + float x = Vector3.Dot(g.transform.position - pos, right); + float y = Vector3.Dot(g.transform.position - pos, up); + return new Vector2(x, y); + } + */ } diff --git a/FallUnity/Assets/level.unity b/FallUnity/Assets/level.unity index 38173d0..eee2288 100755 --- a/FallUnity/Assets/level.unity +++ b/FallUnity/Assets/level.unity @@ -121,7 +121,6 @@ m_Component: - component: {fileID: 11289496} - component: {fileID: 11289499} - - component: {fileID: 11289498} - component: {fileID: 11289497} m_Layer: 0 m_Name: Quad @@ -177,20 +176,6 @@ m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!64 &11289498 -MeshCollider: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 11289495} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Convex: 0 - m_InflateMesh: 0 - m_SkinWidth: 0.01 - m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} --- !u!33 &11289499 MeshFilter: m_ObjectHideFlags: 0 @@ -238,79 +223,6 @@ m_Script: {fileID: 11500000, guid: e9e45b67a184f38439d0136610b1d1cb, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!1 &254672675 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 - m_Component: - - component: {fileID: 254672676} - - component: {fileID: 254672677} - m_Layer: 0 - m_Name: Mountains - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &254672676 -Transform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 254672675} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 26.08, y: -106.07, z: 0} - m_LocalScale: {x: 0.33448413, y: 4.7954674, z: 1.6724206} - m_Children: [] - m_Father: {fileID: 594869234} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!212 &254672677 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 254672675} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 0 - m_SelectedEditorRenderState: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_Sprite: {fileID: 21300000, guid: 86a105eac732f8b49b390ab7ec09b69c, type: 3} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 15, y: 8} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 - m_MaskInteraction: 0 --- !u!1 &257733088 GameObject: m_ObjectHideFlags: 0 @@ -592,7 +504,6 @@ m_LocalScale: {x: 1, y: 0.3487503, z: 1} m_Children: - {fileID: 1272122408} - - {fileID: 254672676} m_Father: {fileID: 1464748117} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -744,7 +655,6 @@ m_Component: - component: {fileID: 864402135} - component: {fileID: 864402138} - - component: {fileID: 864402137} - component: {fileID: 864402136} m_Layer: 0 m_Name: Quad @@ -800,20 +710,6 @@ m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!64 &864402137 -MeshCollider: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 864402134} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Convex: 0 - m_InflateMesh: 0 - m_SkinWidth: 0.01 - m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} --- !u!33 &864402138 MeshFilter: m_ObjectHideFlags: 0 @@ -961,7 +857,7 @@ m_Name: m_EditorClassIdentifier: Radius: 5 - Rate: 19.64 + Rate: 52.6 Leaf: {fileID: 114579094665962866, guid: 1701be1f15e160d4d904862548ae69de, type: 2} --- !u!1 &1272122407 GameObject: @@ -1199,7 +1095,7 @@ m_Component: - component: {fileID: 1529148493} m_Layer: 0 - m_Name: World + m_Name: IsoWorld m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -1337,3 +1233,58 @@ m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 31.29, y: 0, z: 0} +--- !u!1001 &1863673254 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalPosition.x + value: 0.55 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalPosition.y + value: -1 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalPosition.z + value: 0.24 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + 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/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs index 5898e50..187e42c 100644 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ b/FallUnity/Assets/IsoSorting/IsoPiece.cs @@ -1,16 +1,16 @@ -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 float CameraDepth; +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() { @@ -25,7 +25,7 @@ } // Update is called once per frame - void Update () { - - } -} + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs index c82edcf..1873476 100644 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ b/FallUnity/Assets/IsoSorting/IsoSprite.cs @@ -2,13 +2,21 @@ using System.Collections.Generic; using UnityEngine; +[SelectionBase] public class IsoSprite : MonoBehaviour { - internal float CameraDepth; + 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() diff --git a/FallUnity/Assets/IsoSorting/LeafSpawner.cs b/FallUnity/Assets/IsoSorting/LeafSpawner.cs index 820fca1..9eee552 100644 --- a/FallUnity/Assets/IsoSorting/LeafSpawner.cs +++ b/FallUnity/Assets/IsoSorting/LeafSpawner.cs @@ -28,6 +28,9 @@ leaves.Add(leaf); leaf.transform.position = point; leaf.transform.rotation = Quaternion.Euler(new Vector3((Random.value - 0.5f) * 25, Random.value * 360, (Random.value - 0.5f) * 25)); + + float scale = Random.Range(0.9f, 1.3f); + leaf.transform.localScale = new Vector3(scale, scale, scale); } } diff --git a/FallUnity/Assets/Leaves/LeafPhysics.cs b/FallUnity/Assets/Leaves/LeafPhysics.cs index 980971e..7dda907 100755 --- a/FallUnity/Assets/Leaves/LeafPhysics.cs +++ b/FallUnity/Assets/Leaves/LeafPhysics.cs @@ -86,39 +86,41 @@ // Update is called once per frame void Update () { - - if (Debug) + if (body.velocity.sqrMagnitude > 0.01f) { - bool bp = true; + if (Debug) + { + bool bp = true; + } + + float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); + + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); + + /* + if (body.velocity.y < -StartPushVelDown) + { + PushUpCurrent = PushUpForce; + } + + body.AddForce(Vector3.up * PushUpCurrent); + + PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); + */ + + float torqueX = -transform.up.x; + float torqueZ = -transform.up.z; + + float velYScale = Math.Max(0, -body.velocity.y); + + body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); + //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); + body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); + + body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } - - float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); - - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); - - /* - if (body.velocity.y < -StartPushVelDown) - { - PushUpCurrent = PushUpForce; - } - - body.AddForce(Vector3.up * PushUpCurrent); - - PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); - */ - - float torqueX = -transform.up.x; - float torqueZ = -transform.up.z; - - float velYScale = Math.Max(0, -body.velocity.y); - - body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); - //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); - body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); - - body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } } \ No newline at end of file diff --git a/FallUnity/Assets/Player.meta b/FallUnity/Assets/Player.meta new file mode 100644 index 0000000..aae7e98 --- /dev/null +++ b/FallUnity/Assets/Player.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 74568edad9b78934fa13e51935563f9b +folderAsset: yes +timeCreated: 1572128077 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials.meta b/FallUnity/Assets/Player/Materials.meta new file mode 100644 index 0000000..4eb4294 --- /dev/null +++ b/FallUnity/Assets/Player/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e90bde3d0c3f595438a5eb4ef7ebe2a3 +folderAsset: yes +timeCreated: 1572130006 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat b/FallUnity/Assets/Player/Materials/PlayerStand.mat new file mode 100644 index 0000000..f806f40 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat @@ -0,0 +1,62 @@ +%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: PlayerStand + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BackTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DownTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _FrontTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _LeftTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _RightTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _UpTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - PixelSnap: 0 + - _EnableExternalAlpha: 0 + - _Exposure: 1 + - _Rotation: 0 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} + - _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 0.5} diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta new file mode 100644 index 0000000..5f32303 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 22b37cb1f671b1444b44cd6060a893a3 +timeCreated: 1572130006 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab new file mode 100644 index 0000000..11e8bf5 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab @@ -0,0 +1,234 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1127561252628422} + m_IsPrefabParent: 1 +--- !u!1 &1127561252628422 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4968172230546488} + - component: {fileID: 114432391297954942} + - component: {fileID: 114045144791326304} + m_Layer: 0 + m_Name: Player + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1217361112803688 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4644232291033494} + - component: {fileID: 33712194424262930} + - component: {fileID: 136032829821990682} + - component: {fileID: 23824139775216508} + m_Layer: 0 + m_Name: Cylinder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1369658487247200 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4834656431490232} + - component: {fileID: 33325744505029598} + - component: {fileID: 23509338961759882} + m_Layer: 0 + m_Name: Quad + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4644232291033494 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4834656431490232 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4968172230546488 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4644232291033494} + - {fileID: 4834656431490232} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23509338961759882 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 22b37cb1f671b1444b44cd6060a893a3, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!23 &23824139775216508 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &33325744505029598 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Mesh: {fileID: 0} +--- !u!33 &33712194424262930 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} + m_Name: + m_EditorClassIdentifier: + PixelScale: 0.1 + Animations: + - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + Frames: 1 + Offset: {x: 125, y: 300} + Name: Stand + Target: {fileID: 1369658487247200} + Dir: 0 + Frame: 0 +--- !u!136 &136032829821990682 +CapsuleCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.5 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} diff --git a/FallUnity/Assets/Player/Player.prefab.meta b/FallUnity/Assets/Player/Player.prefab.meta new file mode 100644 index 0000000..0d6d363 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9f3dd22cf8fe21a43a067ab4b4ab708f +timeCreated: 1572129898 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerMat.mat b/FallUnity/Assets/Player/PlayerMat.mat new file mode 100644 index 0000000..2aeba5e --- /dev/null +++ b/FallUnity/Assets/Player/PlayerMat.mat @@ -0,0 +1,84 @@ +%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: PlayerMat + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _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: + - PixelSnap: 0 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _EnableExternalAlpha: 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: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} diff --git a/FallUnity/Assets/Player/PlayerMat.mat.meta b/FallUnity/Assets/Player/PlayerMat.mat.meta new file mode 100644 index 0000000..56210cd --- /dev/null +++ b/FallUnity/Assets/Player/PlayerMat.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 147767df5de196944a384ad0041f325e +timeCreated: 1572129629 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png b/FallUnity/Assets/Player/PlayerStand.png new file mode 100644 index 0000000..667bc50 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerStand.png Binary files differ diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta new file mode 100644 index 0000000..a500262 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -0,0 +1,76 @@ +fileFormatVersion: 2 +guid: c1b50d664eb6c564ab4f8126c93ffbb3 +timeCreated: 1572128077 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Utils/Utils.cs b/FallUnity/Assets/Utils/Utils.cs index 13d959e..6d0252a 100644 --- a/FallUnity/Assets/Utils/Utils.cs +++ b/FallUnity/Assets/Utils/Utils.cs @@ -4,15 +4,29 @@ public static class Utils { + /* public static float GetDepthInOrthoCam(GameObject g, Camera c) { return Vector3.Dot(g.transform.position - c.transform.position, c.transform.forward); } + public static float GetDepthIn(GameObject g, Vector3 pos, Vector3 forward) + { + return Vector3.Dot(g.transform.position - pos, forward); + } + public static Vector2 GetPosInOrthoCam(GameObject g, Camera c) { float x = Vector3.Dot(g.transform.position - c.transform.position, c.transform.right); float y = Vector3.Dot(g.transform.position - c.transform.position, c.transform.up); return new Vector2(x, y); } + + public static Vector2 GetPosIn(GameObject g, Vector3 pos, Vector3 right, Vector3 up) + { + float x = Vector3.Dot(g.transform.position - pos, right); + float y = Vector3.Dot(g.transform.position - pos, up); + return new Vector2(x, y); + } + */ } diff --git a/FallUnity/Assets/level.unity b/FallUnity/Assets/level.unity index 38173d0..eee2288 100755 --- a/FallUnity/Assets/level.unity +++ b/FallUnity/Assets/level.unity @@ -121,7 +121,6 @@ m_Component: - component: {fileID: 11289496} - component: {fileID: 11289499} - - component: {fileID: 11289498} - component: {fileID: 11289497} m_Layer: 0 m_Name: Quad @@ -177,20 +176,6 @@ m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!64 &11289498 -MeshCollider: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 11289495} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Convex: 0 - m_InflateMesh: 0 - m_SkinWidth: 0.01 - m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} --- !u!33 &11289499 MeshFilter: m_ObjectHideFlags: 0 @@ -238,79 +223,6 @@ m_Script: {fileID: 11500000, guid: e9e45b67a184f38439d0136610b1d1cb, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!1 &254672675 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 - m_Component: - - component: {fileID: 254672676} - - component: {fileID: 254672677} - m_Layer: 0 - m_Name: Mountains - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &254672676 -Transform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 254672675} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 26.08, y: -106.07, z: 0} - m_LocalScale: {x: 0.33448413, y: 4.7954674, z: 1.6724206} - m_Children: [] - m_Father: {fileID: 594869234} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!212 &254672677 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 254672675} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 0 - m_SelectedEditorRenderState: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_Sprite: {fileID: 21300000, guid: 86a105eac732f8b49b390ab7ec09b69c, type: 3} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 15, y: 8} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 - m_MaskInteraction: 0 --- !u!1 &257733088 GameObject: m_ObjectHideFlags: 0 @@ -592,7 +504,6 @@ m_LocalScale: {x: 1, y: 0.3487503, z: 1} m_Children: - {fileID: 1272122408} - - {fileID: 254672676} m_Father: {fileID: 1464748117} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -744,7 +655,6 @@ m_Component: - component: {fileID: 864402135} - component: {fileID: 864402138} - - component: {fileID: 864402137} - component: {fileID: 864402136} m_Layer: 0 m_Name: Quad @@ -800,20 +710,6 @@ m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!64 &864402137 -MeshCollider: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 864402134} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Convex: 0 - m_InflateMesh: 0 - m_SkinWidth: 0.01 - m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} --- !u!33 &864402138 MeshFilter: m_ObjectHideFlags: 0 @@ -961,7 +857,7 @@ m_Name: m_EditorClassIdentifier: Radius: 5 - Rate: 19.64 + Rate: 52.6 Leaf: {fileID: 114579094665962866, guid: 1701be1f15e160d4d904862548ae69de, type: 2} --- !u!1 &1272122407 GameObject: @@ -1199,7 +1095,7 @@ m_Component: - component: {fileID: 1529148493} m_Layer: 0 - m_Name: World + m_Name: IsoWorld m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -1337,3 +1233,58 @@ m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 31.29, y: 0, z: 0} +--- !u!1001 &1863673254 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalPosition.x + value: 0.55 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalPosition.y + value: -1 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalPosition.z + value: 0.24 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + 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/QualitySettings.asset b/FallUnity/ProjectSettings/QualitySettings.asset index 643dbb3..7ef343a 100644 --- a/FallUnity/ProjectSettings/QualitySettings.asset +++ b/FallUnity/ProjectSettings/QualitySettings.asset @@ -174,19 +174,4 @@ asyncUploadBufferSize: 4 resolutionScalingFixedDPIFactor: 1 excludedTargetPlatforms: [] - m_PerPlatformDefaultQuality: - Android: 2 - Nintendo 3DS: 5 - Nintendo Switch: 5 - PS4: 5 - PSM: 5 - PSP2: 2 - Samsung TV: 2 - Standalone: 5 - Tizen: 2 - WebGL: 3 - WiiU: 5 - Windows Store Apps: 5 - XboxOne: 5 - iPhone: 2 - tvOS: 2 + m_PerPlatformDefaultQuality: {} diff --git a/Build/fall_Data/Managed/Assembly-CSharp.dll b/Build/fall_Data/Managed/Assembly-CSharp.dll index a651b7a..8904122 100644 --- a/Build/fall_Data/Managed/Assembly-CSharp.dll +++ b/Build/fall_Data/Managed/Assembly-CSharp.dll Binary files differ diff --git a/Build/fall_Data/globalgamemanagers b/Build/fall_Data/globalgamemanagers index 4188680..b1de059 100644 --- a/Build/fall_Data/globalgamemanagers +++ b/Build/fall_Data/globalgamemanagers Binary files differ diff --git a/Build/fall_Data/globalgamemanagers.assets b/Build/fall_Data/globalgamemanagers.assets index 0290941..8efafba 100644 --- a/Build/fall_Data/globalgamemanagers.assets +++ b/Build/fall_Data/globalgamemanagers.assets Binary files differ diff --git a/Build/fall_Data/level0 b/Build/fall_Data/level0 index 425a338..c101784 100644 --- a/Build/fall_Data/level0 +++ b/Build/fall_Data/level0 Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets b/Build/fall_Data/sharedassets0.assets index 57b5962..b46f7e6 100644 --- a/Build/fall_Data/sharedassets0.assets +++ b/Build/fall_Data/sharedassets0.assets Binary files differ diff --git a/Build/fall_Data/sharedassets0.assets.resS b/Build/fall_Data/sharedassets0.assets.resS index f737f0e..a3f0fd1 100644 --- a/Build/fall_Data/sharedassets0.assets.resS +++ b/Build/fall_Data/sharedassets0.assets.resS Binary files differ diff --git a/FallUnity/Assets/Animations.meta b/FallUnity/Assets/Animations.meta new file mode 100644 index 0000000..a585f7d --- /dev/null +++ b/FallUnity/Assets/Animations.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1dba54c88c856a34eaeb05c3babfa8f2 +folderAsset: yes +timeCreated: 1572128085 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs b/FallUnity/Assets/Animations/AnimationHandler.cs new file mode 100644 index 0000000..9df9e44 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +[Serializable] +public struct AnimationInfo +{ + public Texture2D Sheet; + public int Frames; + public Vector2 Offset; + public string Name; +} + +[SelectionBase] +public class AnimationHandler : MonoBehaviour { + public float PixelScale = 0.1f; + + public AnimationInfo[] Animations; + public GameObject Target; + + private Material mat; + + private Mesh mesh; + + private AnimationInfo animationInfo; + + private Vector3 spriteSize = new Vector2(); + + // Use this for initialization + void Start () { + MeshFilter mf = Target.GetComponentInChildren(); + MeshRenderer rend = Target.GetComponentInChildren(); + mat = rend.material; + + animationInfo = Animations[0]; + UpdateMat(); + + mesh = new Mesh(); + mesh.SetVertices(verts); + + mesh.SetUVs(0, uvs); + + mesh.SetTriangles(new int[] + { + 0, 1, 2, + 0, 2, 3 + }, 0); + + UpdateMesh(); + + mf.sharedMesh = mesh; + } + + private void UpdateMat() + { + spriteSize = new Vector3(animationInfo.Sheet.width * 0.25f, animationInfo.Sheet.height / animationInfo.Frames, 1); + mat.SetTexture("_MainTex", animationInfo.Sheet); + } + + private List verts = new List + { + new Vector3(1, 1, 0), + new Vector3(1, -1, 0), + new Vector3(-1, -1, 0), + new Vector3(-1, 1, 0) + }; + + private List uvs = new List + { + new Vector2(1, 1), + new Vector2(1, 0), + new Vector2(0, 0), + new Vector2(0, 1) + }; + + private void UpdateMesh() + { + Vector3 offset = new Vector3(animationInfo.Offset.x, spriteSize.y - animationInfo.Offset.y, 0); + Vector3 spriteSizeMult = new Vector3(spriteSize.x, spriteSize.y); + verts[0] = (Vector3.Scale(new Vector3(1, 1, 0), spriteSize) - offset) * PixelScale; + verts[1] = (Vector3.Scale(new Vector3(1, 0, 0), spriteSize) - offset) * PixelScale; + verts[2] = (Vector3.Scale(new Vector3(0, 0, 0), spriteSize) - offset) * PixelScale; + verts[3] = (Vector3.Scale(new Vector3(0, 1, 0), spriteSize) - offset) * PixelScale; + mesh.SetVertices(verts); + + float uStart = ((int)Dir * spriteSize.x) / animationInfo.Sheet.width; + float uEnd = uStart + spriteSize.x / animationInfo.Sheet.width; + + float vStart = (Frame * spriteSize.y) / animationInfo.Sheet.height; + float vEnd = vStart + spriteSize.y / animationInfo.Sheet.height; + + + + uvs[0] = new Vector3(uEnd, vEnd); + uvs[1] = new Vector3(uEnd, vStart); + uvs[2] = new Vector3(uStart, vStart); + uvs[3] = new Vector3(uStart, vEnd); + mesh.SetUVs(0, uvs); + + mesh.RecalculateNormals(); + mesh.RecalculateBounds(); + } + + public enum Direction + { + DownRight = 0, + UpRight, + UpLeft, + DownLeft + } + + public void SetState(string animationName, Direction dir, int frame) + { + bool changed = false; + if (animationName != animationInfo.Name) + { + changed = true; + animationInfo = Animations.First(a => a.Name == animationName); + UpdateMat(); + } + + if (this.Dir != dir) + { + changed = true; + this.Dir = dir; + } + + if (this.Frame != frame) + { + changed = true; + this.Frame = frame; + } + + if (changed) + { + UpdateMesh(); + } + } + + public Direction Dir = Direction.DownRight; + public int Frame = 0; + + // Update is called once per frame + void Update () { + + } +} diff --git a/FallUnity/Assets/Animations/AnimationHandler.cs.meta b/FallUnity/Assets/Animations/AnimationHandler.cs.meta new file mode 100644 index 0000000..6b030a0 --- /dev/null +++ b/FallUnity/Assets/Animations/AnimationHandler.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7bcddcb25d3f2f0418f47d778e3320c6 +timeCreated: 1572129689 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/IsoSorting/IsoHandler.cs b/FallUnity/Assets/IsoSorting/IsoHandler.cs index fb84e24..640f193 100644 --- a/FallUnity/Assets/IsoSorting/IsoHandler.cs +++ b/FallUnity/Assets/IsoSorting/IsoHandler.cs @@ -41,7 +41,7 @@ int SpriteSort(IsoSprite a, IsoSprite b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -49,7 +49,7 @@ int PieceSort(IsoPiece a, IsoPiece b) { - float diff = b.CameraDepth - a.CameraDepth; + float diff = b.CameraSpace.z - a.CameraSpace.z; if (diff > 0) return 1; if (diff < 0) return -1; return 0; @@ -57,18 +57,27 @@ private List frontSort = new List(); private float nextDepth = 0; + private Vector3 camForward; + private Vector3 camRight; + private Vector3 camUp; + private Vector3 camPos; void LateUpdate() { + camForward = mainCamera.transform.forward; + camRight = mainCamera.transform.right; + camUp = mainCamera.transform.up; + camPos = mainCamera.transform.position; + frontSort.Clear(); for (int i = 0; i < pieceList.Count; i++) { pieceList[i].Behind.Clear(); - pieceList[i].CameraDepth = Utils.GetDepthInOrthoCam(pieceList[i].LinkedImage, mainCamera); + pieceList[i].CameraSpace = mainCamera.WorldToScreenPoint(pieceList[i].LinkedImage.transform.position); } for (int i = 0; i < spriteList.Count; i++) { - spriteList[i].CameraDepth = Utils.GetDepthInOrthoCam(spriteList[i].gameObject, mainCamera); + spriteList[i].CameraSpace = mainCamera.WorldToScreenPoint(spriteList[i].gameObject.transform.position); } spriteList.Sort(SpriteSort); @@ -77,7 +86,7 @@ for (int i = 0; i < spriteList.Count; i++) { IsoSprite sprite = spriteList[i]; - if (Physics.Raycast(new Ray(sprite.transform.position, -mainCamera.transform.forward), out hitInfo, sprite.CameraDepth, layer)) + if (Physics.Raycast(new Ray(sprite.transform.position, -camForward), out hitInfo, sprite.CameraSpace.z, layer)) { IsoPiece piece = hitInfo.collider.GetComponentInParent(); piece.Behind.Add(sprite); @@ -90,31 +99,28 @@ pieceList.Sort(PieceSort); - nextDepth = 990; + nextDepth = 50; for (int i = 0; i < pieceList.Count; i++) { IsoPiece piece = pieceList[i]; for (int j = 0; j < piece.Behind.Count; j++) { - SortObject(piece.Behind[j].gameObject, piece.Behind[j].Mesh); + SortObject(piece.Behind[j].CameraSpace, piece.Behind[j].gameObject, piece.Behind[j].Mesh); } - SortObject(piece.LinkedImage, piece.LinkedImage); + SortObject(piece.CameraSpace, piece.LinkedImage, piece.LinkedImage); } for (int i = 0; i < frontSort.Count; i++) { - SortObject(frontSort[i].gameObject, frontSort[i].Mesh); + SortObject(frontSort[i].CameraSpace, frontSort[i].gameObject, frontSort[i].Mesh); } } - private void SortObject(GameObject getPos, GameObject setPos) + private void SortObject(Vector3 camPoint, GameObject getPos, GameObject setPos) { - Vector2 xy = Utils.GetPosInOrthoCam(getPos, mainCamera); + camPoint.z = nextDepth; - Transform camT = mainCamera.transform; - - Vector3 p = camT.position + camT.right * xy.x + camT.up * xy.y + camT.forward * nextDepth; - setPos.transform.position = p; + setPos.transform.position = mainCamera.ScreenToWorldPoint(camPoint); nextDepth -= 0.001f; } diff --git a/FallUnity/Assets/IsoSorting/IsoPiece.cs b/FallUnity/Assets/IsoSorting/IsoPiece.cs index 5898e50..187e42c 100644 --- a/FallUnity/Assets/IsoSorting/IsoPiece.cs +++ b/FallUnity/Assets/IsoSorting/IsoPiece.cs @@ -1,16 +1,16 @@ -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 float CameraDepth; +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() { @@ -25,7 +25,7 @@ } // Update is called once per frame - void Update () { - - } -} + void Update () { + + } +} diff --git a/FallUnity/Assets/IsoSorting/IsoSprite.cs b/FallUnity/Assets/IsoSorting/IsoSprite.cs index c82edcf..1873476 100644 --- a/FallUnity/Assets/IsoSorting/IsoSprite.cs +++ b/FallUnity/Assets/IsoSorting/IsoSprite.cs @@ -2,13 +2,21 @@ using System.Collections.Generic; using UnityEngine; +[SelectionBase] public class IsoSprite : MonoBehaviour { - internal float CameraDepth; + 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() diff --git a/FallUnity/Assets/IsoSorting/LeafSpawner.cs b/FallUnity/Assets/IsoSorting/LeafSpawner.cs index 820fca1..9eee552 100644 --- a/FallUnity/Assets/IsoSorting/LeafSpawner.cs +++ b/FallUnity/Assets/IsoSorting/LeafSpawner.cs @@ -28,6 +28,9 @@ leaves.Add(leaf); leaf.transform.position = point; leaf.transform.rotation = Quaternion.Euler(new Vector3((Random.value - 0.5f) * 25, Random.value * 360, (Random.value - 0.5f) * 25)); + + float scale = Random.Range(0.9f, 1.3f); + leaf.transform.localScale = new Vector3(scale, scale, scale); } } diff --git a/FallUnity/Assets/Leaves/LeafPhysics.cs b/FallUnity/Assets/Leaves/LeafPhysics.cs index 980971e..7dda907 100755 --- a/FallUnity/Assets/Leaves/LeafPhysics.cs +++ b/FallUnity/Assets/Leaves/LeafPhysics.cs @@ -86,39 +86,41 @@ // Update is called once per frame void Update () { - - if (Debug) + if (body.velocity.sqrMagnitude > 0.01f) { - bool bp = true; + if (Debug) + { + bool bp = true; + } + + float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); + + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); + body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); + + /* + if (body.velocity.y < -StartPushVelDown) + { + PushUpCurrent = PushUpForce; + } + + body.AddForce(Vector3.up * PushUpCurrent); + + PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); + */ + + float torqueX = -transform.up.x; + float torqueZ = -transform.up.z; + + float velYScale = Math.Max(0, -body.velocity.y); + + body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); + //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); + body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); + + body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } - - float baseForceUp = Mathf.Max(BaseWindForce * Mathf.Pow(Mathf.Abs(transform.up.y), AnglePow) * -body.velocity.y); - - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusX.Current), transform.position + Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusX.Current), transform.position - Vector3.right * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + PlusZ.Current), transform.position + Vector3.forward * 0.4f); - body.AddForceAtPosition(Vector3.up * baseForceUp * (1 + MinusZ.Current), transform.position - Vector3.forward * 0.4f); - - /* - if (body.velocity.y < -StartPushVelDown) - { - PushUpCurrent = PushUpForce; - } - - body.AddForce(Vector3.up * PushUpCurrent); - - PushUpCurrent = Mathf.Max(0, PushUpCurrent - PushUpDecayRate * Time.deltaTime); - */ - - float torqueX = -transform.up.x; - float torqueZ = -transform.up.z; - - float velYScale = Math.Max(0, -body.velocity.y); - - body.AddRelativeForce(new Vector3(torqueX * TorqueSideScale, 0, torqueZ * TorqueSideScale) * velYScale); - //body.AddForce(Vector3.up * Mathf.Pow(Mathf.Max(-body.velocity.y / VelDownForceDivide), 2) * VelDownForceScale); - body.AddRelativeTorque(new Vector3(Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueX * TorqueScale * 1.2f)) + TorqueX.Current * 0.5f, 0, Mathf.Max(-TorqueBounds, Mathf.Min(TorqueBounds, torqueZ * TorqueScale)) + TorqueZ.Current * 0.5f) * velYScale); - - body.AddForce(new Vector3(-body.velocity.x, 0, -body.velocity.z) * SideRestitution); } } \ No newline at end of file diff --git a/FallUnity/Assets/Player.meta b/FallUnity/Assets/Player.meta new file mode 100644 index 0000000..aae7e98 --- /dev/null +++ b/FallUnity/Assets/Player.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 74568edad9b78934fa13e51935563f9b +folderAsset: yes +timeCreated: 1572128077 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials.meta b/FallUnity/Assets/Player/Materials.meta new file mode 100644 index 0000000..4eb4294 --- /dev/null +++ b/FallUnity/Assets/Player/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e90bde3d0c3f595438a5eb4ef7ebe2a3 +folderAsset: yes +timeCreated: 1572130006 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat b/FallUnity/Assets/Player/Materials/PlayerStand.mat new file mode 100644 index 0000000..f806f40 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat @@ -0,0 +1,62 @@ +%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: PlayerStand + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BackTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DownTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _FrontTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _LeftTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _RightTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _UpTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - PixelSnap: 0 + - _EnableExternalAlpha: 0 + - _Exposure: 1 + - _Rotation: 0 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} + - _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 0.5} diff --git a/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta new file mode 100644 index 0000000..5f32303 --- /dev/null +++ b/FallUnity/Assets/Player/Materials/PlayerStand.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 22b37cb1f671b1444b44cd6060a893a3 +timeCreated: 1572130006 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/Player.prefab b/FallUnity/Assets/Player/Player.prefab new file mode 100644 index 0000000..11e8bf5 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab @@ -0,0 +1,234 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1127561252628422} + m_IsPrefabParent: 1 +--- !u!1 &1127561252628422 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4968172230546488} + - component: {fileID: 114432391297954942} + - component: {fileID: 114045144791326304} + m_Layer: 0 + m_Name: Player + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1217361112803688 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4644232291033494} + - component: {fileID: 33712194424262930} + - component: {fileID: 136032829821990682} + - component: {fileID: 23824139775216508} + m_Layer: 0 + m_Name: Cylinder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1369658487247200 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4834656431490232} + - component: {fileID: 33325744505029598} + - component: {fileID: 23509338961759882} + m_Layer: 0 + m_Name: Quad + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4644232291033494 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4834656431490232 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4968172230546488} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4968172230546488 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4644232291033494} + - {fileID: 4834656431490232} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23509338961759882 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 22b37cb1f671b1444b44cd6060a893a3, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!23 &23824139775216508 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &33325744505029598 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1369658487247200} + m_Mesh: {fileID: 0} +--- !u!33 &33712194424262930 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1127561252628422} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7bcddcb25d3f2f0418f47d778e3320c6, type: 3} + m_Name: + m_EditorClassIdentifier: + PixelScale: 0.1 + Animations: + - Sheet: {fileID: 2800000, guid: c1b50d664eb6c564ab4f8126c93ffbb3, type: 3} + Frames: 1 + Offset: {x: 125, y: 300} + Name: Stand + Target: {fileID: 1369658487247200} + Dir: 0 + Frame: 0 +--- !u!136 &136032829821990682 +CapsuleCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1217361112803688} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.5 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} diff --git a/FallUnity/Assets/Player/Player.prefab.meta b/FallUnity/Assets/Player/Player.prefab.meta new file mode 100644 index 0000000..0d6d363 --- /dev/null +++ b/FallUnity/Assets/Player/Player.prefab.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9f3dd22cf8fe21a43a067ab4b4ab708f +timeCreated: 1572129898 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerMat.mat b/FallUnity/Assets/Player/PlayerMat.mat new file mode 100644 index 0000000..2aeba5e --- /dev/null +++ b/FallUnity/Assets/Player/PlayerMat.mat @@ -0,0 +1,84 @@ +%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: PlayerMat + m_Shader: {fileID: 10753, 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: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _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: + - PixelSnap: 0 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _EnableExternalAlpha: 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: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} diff --git a/FallUnity/Assets/Player/PlayerMat.mat.meta b/FallUnity/Assets/Player/PlayerMat.mat.meta new file mode 100644 index 0000000..56210cd --- /dev/null +++ b/FallUnity/Assets/Player/PlayerMat.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 147767df5de196944a384ad0041f325e +timeCreated: 1572129629 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Player/PlayerStand.png b/FallUnity/Assets/Player/PlayerStand.png new file mode 100644 index 0000000..667bc50 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerStand.png Binary files differ diff --git a/FallUnity/Assets/Player/PlayerStand.png.meta b/FallUnity/Assets/Player/PlayerStand.png.meta new file mode 100644 index 0000000..a500262 --- /dev/null +++ b/FallUnity/Assets/Player/PlayerStand.png.meta @@ -0,0 +1,76 @@ +fileFormatVersion: 2 +guid: c1b50d664eb6c564ab4f8126c93ffbb3 +timeCreated: 1572128077 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/FallUnity/Assets/Utils/Utils.cs b/FallUnity/Assets/Utils/Utils.cs index 13d959e..6d0252a 100644 --- a/FallUnity/Assets/Utils/Utils.cs +++ b/FallUnity/Assets/Utils/Utils.cs @@ -4,15 +4,29 @@ public static class Utils { + /* public static float GetDepthInOrthoCam(GameObject g, Camera c) { return Vector3.Dot(g.transform.position - c.transform.position, c.transform.forward); } + public static float GetDepthIn(GameObject g, Vector3 pos, Vector3 forward) + { + return Vector3.Dot(g.transform.position - pos, forward); + } + public static Vector2 GetPosInOrthoCam(GameObject g, Camera c) { float x = Vector3.Dot(g.transform.position - c.transform.position, c.transform.right); float y = Vector3.Dot(g.transform.position - c.transform.position, c.transform.up); return new Vector2(x, y); } + + public static Vector2 GetPosIn(GameObject g, Vector3 pos, Vector3 right, Vector3 up) + { + float x = Vector3.Dot(g.transform.position - pos, right); + float y = Vector3.Dot(g.transform.position - pos, up); + return new Vector2(x, y); + } + */ } diff --git a/FallUnity/Assets/level.unity b/FallUnity/Assets/level.unity index 38173d0..eee2288 100755 --- a/FallUnity/Assets/level.unity +++ b/FallUnity/Assets/level.unity @@ -121,7 +121,6 @@ m_Component: - component: {fileID: 11289496} - component: {fileID: 11289499} - - component: {fileID: 11289498} - component: {fileID: 11289497} m_Layer: 0 m_Name: Quad @@ -177,20 +176,6 @@ m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!64 &11289498 -MeshCollider: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 11289495} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Convex: 0 - m_InflateMesh: 0 - m_SkinWidth: 0.01 - m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} --- !u!33 &11289499 MeshFilter: m_ObjectHideFlags: 0 @@ -238,79 +223,6 @@ m_Script: {fileID: 11500000, guid: e9e45b67a184f38439d0136610b1d1cb, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!1 &254672675 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 - m_Component: - - component: {fileID: 254672676} - - component: {fileID: 254672677} - m_Layer: 0 - m_Name: Mountains - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &254672676 -Transform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 254672675} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 26.08, y: -106.07, z: 0} - m_LocalScale: {x: 0.33448413, y: 4.7954674, z: 1.6724206} - m_Children: [] - m_Father: {fileID: 594869234} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!212 &254672677 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 254672675} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 0 - m_SelectedEditorRenderState: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_Sprite: {fileID: 21300000, guid: 86a105eac732f8b49b390ab7ec09b69c, type: 3} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 15, y: 8} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 - m_MaskInteraction: 0 --- !u!1 &257733088 GameObject: m_ObjectHideFlags: 0 @@ -592,7 +504,6 @@ m_LocalScale: {x: 1, y: 0.3487503, z: 1} m_Children: - {fileID: 1272122408} - - {fileID: 254672676} m_Father: {fileID: 1464748117} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -744,7 +655,6 @@ m_Component: - component: {fileID: 864402135} - component: {fileID: 864402138} - - component: {fileID: 864402137} - component: {fileID: 864402136} m_Layer: 0 m_Name: Quad @@ -800,20 +710,6 @@ m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!64 &864402137 -MeshCollider: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 864402134} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Convex: 0 - m_InflateMesh: 0 - m_SkinWidth: 0.01 - m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} --- !u!33 &864402138 MeshFilter: m_ObjectHideFlags: 0 @@ -961,7 +857,7 @@ m_Name: m_EditorClassIdentifier: Radius: 5 - Rate: 19.64 + Rate: 52.6 Leaf: {fileID: 114579094665962866, guid: 1701be1f15e160d4d904862548ae69de, type: 2} --- !u!1 &1272122407 GameObject: @@ -1199,7 +1095,7 @@ m_Component: - component: {fileID: 1529148493} m_Layer: 0 - m_Name: World + m_Name: IsoWorld m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -1337,3 +1233,58 @@ m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 31.29, y: 0, z: 0} +--- !u!1001 &1863673254 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalPosition.x + value: 0.55 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalPosition.y + value: -1 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalPosition.z + value: 0.24 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4968172230546488, guid: 9f3dd22cf8fe21a43a067ab4b4ab708f, type: 2} + 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/QualitySettings.asset b/FallUnity/ProjectSettings/QualitySettings.asset index 643dbb3..7ef343a 100644 --- a/FallUnity/ProjectSettings/QualitySettings.asset +++ b/FallUnity/ProjectSettings/QualitySettings.asset @@ -174,19 +174,4 @@ asyncUploadBufferSize: 4 resolutionScalingFixedDPIFactor: 1 excludedTargetPlatforms: [] - m_PerPlatformDefaultQuality: - Android: 2 - Nintendo 3DS: 5 - Nintendo Switch: 5 - PS4: 5 - PSM: 5 - PSP2: 2 - Samsung TV: 2 - Standalone: 5 - Tizen: 2 - WebGL: 3 - WiiU: 5 - Windows Store Apps: 5 - XboxOne: 5 - iPhone: 2 - tvOS: 2 + m_PerPlatformDefaultQuality: {} diff --git a/Flash/Player.fla b/Flash/Player.fla new file mode 100644 index 0000000..45fff20 --- /dev/null +++ b/Flash/Player.fla Binary files differ