diff --git a/Assets/Prefabs/Enemy/JumpEnemy.prefab b/Assets/Prefabs/Enemy/JumpEnemy.prefab new file mode 100644 index 0000000000000000000000000000000000000000..904e7813a8708f72e436d010c64e001bac79ee0f Binary files /dev/null and b/Assets/Prefabs/Enemy/JumpEnemy.prefab differ diff --git a/Assets/Prefabs/Enemy/JumpEnemy.prefab.meta b/Assets/Prefabs/Enemy/JumpEnemy.prefab.meta new file mode 100644 index 0000000000000000000000000000000000000000..7f589dad8fbcbbcd68767fb9aade3d68970e9e2e --- /dev/null +++ b/Assets/Prefabs/Enemy/JumpEnemy.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e4a9d79f80fd9a446b4290b9f47ece1f +timeCreated: 1490918557 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Lunge Enemy.prefab b/Assets/Prefabs/Lunge Enemy.prefab new file mode 100644 index 0000000000000000000000000000000000000000..fe6c7d1abb9b29b24ae7c3748cef6d73b9e202b2 Binary files /dev/null and b/Assets/Prefabs/Lunge Enemy.prefab differ diff --git a/Assets/Prefabs/Lunge Enemy.prefab.meta b/Assets/Prefabs/Lunge Enemy.prefab.meta new file mode 100644 index 0000000000000000000000000000000000000000..72647c86c59848064fb459abd70835d49d272e7e --- /dev/null +++ b/Assets/Prefabs/Lunge Enemy.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 662f53d653f63834597b5983de9d8859 +timeCreated: 1492125460 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index 247f6c2dac6e037c717cf51831e92eb8df799eca..d08d1688d392fdab700000553c3895c29f390c85 100755 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -41,22 +41,6 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1239394936941194 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4610411104157988} - - component: {fileID: 114119099780513746} - m_Layer: 0 - m_Name: InputManager - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 --- !u!1 &1292833923080258 GameObject: m_ObjectHideFlags: 1 @@ -296,7 +280,7 @@ GameObject: - component: {fileID: 114296284101528218} - component: {fileID: 114496983445290320} - component: {fileID: 114468523229820794} - - component: {fileID: 114201504414302498} + - component: {fileID: 114912600304330566} m_Layer: 8 m_Name: Player m_TagString: Player @@ -536,19 +520,6 @@ Transform: m_Father: {fileID: 4857202340971982} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4610411104157988 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1239394936941194} - 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: 4766587421979404} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &4653745076668720 Transform: m_ObjectHideFlags: 1 @@ -582,12 +553,11 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1784255690954616} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 1.2, y: 2.77, z: 0} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 1, y: 1, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4838104525842692} - - {fileID: 4610411104157988} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -915,51 +885,6 @@ Animator: m_WarningMessage: m_HasTransformHierarchy: 1 m_AllowConstantClipSamplingOptimization: 1 ---- !u!114 &114119099780513746 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1239394936941194} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5a7bd8d106353a247bd436ee1baa2061, type: 3} - m_Name: - m_EditorClassIdentifier: - inputs: - - axisName: Horizontal - offValue: 0 - buttons: 1 - condition: 1 - - axisName: Horizontal - offValue: 0 - buttons: 0 - condition: 0 - - axisName: A - offValue: 0 - buttons: 4 - condition: 0 - - axisName: B - offValue: 0 - buttons: 5 - condition: 0 - inputState: {fileID: 114343537035820548} ---- !u!114 &114201504414302498 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1784255690954616} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0cad1638cf0899c4584bad64f0af5112, type: 3} - m_Name: - m_EditorClassIdentifier: - smoothSpeed: 1 - UpBuffer: 5 - DownBuffer: 5 - RightBuffer: 5 - LeftBuffer: 5 --- !u!114 &114296284101528218 MonoBehaviour: m_ObjectHideFlags: 1 @@ -975,23 +900,11 @@ MonoBehaviour: disableScripts: [] dashVelocityCurve: serializedVersion: 2 - m_Curve: - - serializedVersion: 2 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - - serializedVersion: 2 - time: 1 - value: 0.48125005 - inSlope: 0 - outSlope: 0 - tangentMode: 0 + m_Curve: [] m_PreInfinity: 2 m_PostInfinity: 2 - m_RotationOrder: 0 - dashDistance: 1 + m_RotationOrder: 4 + dashDistance: 0 coolDown: 1 holdTime: 1 --- !u!114 &114343537035820548 @@ -1019,11 +932,10 @@ MonoBehaviour: inputButtons: 0100000000000000 disableScripts: [] speed: 5 - airAcceleration: 0.5 - friction: 0.5 + airAcceleration: 0.07 + groundAcceleration: 1 wallClingTime: 0.25 clingSpeed: 0.25 - realSpeed: 0 isWallSliding: 0 --- !u!114 &114496983445290320 MonoBehaviour: @@ -1062,6 +974,22 @@ MonoBehaviour: m_Bits: 1 skinWidth: 0 groundCheckDistance: 0.1 +--- !u!114 &114912600304330566 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1784255690954616} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0cad1638cf0899c4584bad64f0af5112, type: 3} + m_Name: + m_EditorClassIdentifier: + smoothSpeed: 1 + UpBuffer: 5 + DownBuffer: 5 + RightBuffer: 5 + LeftBuffer: 5 --- !u!137 &137216855547286664 SkinnedMeshRenderer: m_ObjectHideFlags: 1 @@ -1164,7 +1092,7 @@ ParticleSystem: m_GameObject: {fileID: 1812230161422426} serializedVersion: 5 lengthInSec: 0.1 - simulationSpeed: 1 + speed: 1 looping: 1 prewarm: 0 playOnAwake: 1 @@ -3801,7 +3729,7 @@ ParticleSystem: m_GameObject: {fileID: 1560513321517206} serializedVersion: 5 lengthInSec: 0.1 - simulationSpeed: 1 + speed: 1 looping: 0 prewarm: 0 playOnAwake: 1 diff --git a/Assets/Scenes/jumptest.unity b/Assets/Scenes/jumptest.unity index 7ea0353f90d37ded91675afeb144b698d418ca80..f9c4e070eb1c9ee2958cf631e7f8aa608a7d725f 100644 Binary files a/Assets/Scenes/jumptest.unity and b/Assets/Scenes/jumptest.unity differ diff --git a/Assets/Scripts/Birb/Dash.cs b/Assets/Scripts/Birb/Dash.cs index f06b154d784a98832b972543d89f2c6913e05734..07f799dd4711c1ea9fea3ae9ed9ffbedf228bcf9 100644 --- a/Assets/Scripts/Birb/Dash.cs +++ b/Assets/Scripts/Birb/Dash.cs @@ -66,6 +66,7 @@ public class Dash : AbstractBehavior { distTraveled /= samples; + return (dashDistance / distTraveled); } diff --git a/Assets/Scripts/Enemy/BaseEnemy.cs b/Assets/Scripts/Enemy/BaseEnemy.cs index 4670f597a8bd83b62a36f14b0e6a0753123ca1bd..f091e5f4a1fca5e3f482a46351bc30bd900fd6f9 100644 --- a/Assets/Scripts/Enemy/BaseEnemy.cs +++ b/Assets/Scripts/Enemy/BaseEnemy.cs @@ -8,7 +8,8 @@ public class BaseEnemy : MonoBehaviour { public float speed = 2f; public float maxMoveDistance = 5f; protected float moveDistanceLeft; - Rigidbody2D body; + public Rigidbody2D body; + protected SpriteRenderer sr; protected float startMoveTime; public Transform rightCollisionPos; diff --git a/Assets/Scripts/Enemy/JumpEnemy.cs b/Assets/Scripts/Enemy/JumpEnemy.cs new file mode 100644 index 0000000000000000000000000000000000000000..2d669a6dcc82b7d56c5f467af3f7ff4032fd6d56 --- /dev/null +++ b/Assets/Scripts/Enemy/JumpEnemy.cs @@ -0,0 +1,62 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class JumpEnemy : BaseEnemy +{ + public float jumpHeight = 5f; + private Vector2 gravity; + public bool onGround = false; + public bool isJumping = false; + public float jumpIntervalTime = 5f; //Time it takes after enemy lands and before it jumps again + // Use this for initialization + void Start() + { + // rightCollisionPos = body.transform; + body = GetComponent(); + gravity = Physics2D.gravity; + } + + // Update is called once per frame + void Update() + { + if (onGround && !isJumping) + { + isJumping = true; + StartCoroutine("Jump"); + } + } + + IEnumerator Jump() + { + yield return new WaitForSeconds(jumpIntervalTime); + + float verticalVelocity; + verticalVelocity = Mathf.Sqrt(2 * -gravity.y * jumpHeight); + if(onGround) + body.velocity = new Vector2(body.velocity.x, verticalVelocity); + + yield return new WaitForSeconds(0.1f); + isJumping = false; + } + + + void OnCollisionStay2D(Collision2D collision) + { + onGround = false; + foreach (ContactPoint2D contact in collision.contacts) + { + Vector2 normal = contact.normal; + + if (normal == Vector2.up) + { + onGround = true; + } + } + } + + void OnCollisionExit2D() + { + onGround = false; + } +} diff --git a/Assets/Scripts/Enemy/JumpEnemy.cs.meta b/Assets/Scripts/Enemy/JumpEnemy.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..8f0ca2dd590c08ab975c114eee9c567ae76e287b --- /dev/null +++ b/Assets/Scripts/Enemy/JumpEnemy.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a27794eaa09b64942a463f5fa9ccac31 +timeCreated: 1490917502 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Enemy/Lunge_Attack.cs b/Assets/Scripts/Enemy/Lunge_Attack.cs new file mode 100644 index 0000000000000000000000000000000000000000..59ab9924414db0634642cfa812f4ffb72bc73bf3 Binary files /dev/null and b/Assets/Scripts/Enemy/Lunge_Attack.cs differ diff --git a/Assets/Scripts/Enemy/Lunge_Attack.cs.meta b/Assets/Scripts/Enemy/Lunge_Attack.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..b9fd316264bd3b7215ae71f9a3030e6ffc3241c1 --- /dev/null +++ b/Assets/Scripts/Enemy/Lunge_Attack.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 017ab18b4c3d0ea43be073a58863ab7a +timeCreated: 1487896683 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Enemy/desktop.ini b/Assets/Scripts/Enemy/desktop.ini new file mode 100644 index 0000000000000000000000000000000000000000..730fba97f2474300ca84a937f6e71ea5c827a635 --- /dev/null +++ b/Assets/Scripts/Enemy/desktop.ini @@ -0,0 +1,2 @@ +[LocalizedFileNames] +Lunge_Attack.cs=@Lunge_Attack.cs,0 diff --git a/Assets/Scripts/Enemy/desktop.ini.meta b/Assets/Scripts/Enemy/desktop.ini.meta new file mode 100644 index 0000000000000000000000000000000000000000..717e6e9d149ba3d2bdd65df61f9c0888378c1993 --- /dev/null +++ b/Assets/Scripts/Enemy/desktop.ini.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5b3d6d680ead1a941852d0097afe0f49 +timeCreated: 1487901782 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Player/Walk.cs b/Assets/Scripts/Player/Walk.cs index c2999edfc06d295d301aec2d839997f709bba356..7e81a335286f9438f70725eb45c53910be7a7388 100644 --- a/Assets/Scripts/Player/Walk.cs +++ b/Assets/Scripts/Player/Walk.cs @@ -5,12 +5,15 @@ using UnityEngine; public class Walk : AbstractBehavior { public float speed; private float airSpeed; - public float airAcceleration; - public float friction; - public float wallClingTime; //time you will 'stick' to the wall after releasing slide button + + private float groundSpeed; + public float airAcceleration; //float from 0.0 to 1.0 + public float groundAcceleration; //float from 0.0 to 1.0 + public float wallClingTime; //time you will 'stick' to the wall after pressing the opposite direction + public float clingSpeed = 0.1f; - public float realSpeed; + //public float realSpeed; public bool isWallSliding = false; private int rightInt = 0; @@ -49,23 +52,34 @@ public class Walk : AbstractBehavior { if (collisionState.onGround) //movement on ground { - realSpeed = body.velocity.x; - if (inputState.GetButtonValue(right) || inputState.GetButtonValue(left)) - { - - realSpeed = Mathf.Clamp(realSpeed + speed * (rightInt + leftInt), -speed, speed); - } - else + groundSpeed = body.velocity.x; + if (inputState.GetButtonValue(right) || inputState.GetButtonValue(left)) + { + if (Mathf.Abs(groundSpeed) <= speed) + groundSpeed = Mathf.Clamp(groundSpeed + groundAcceleration * speed * (rightInt + leftInt), -speed, speed); + else + { + if (groundSpeed != 0) + { + groundSpeed += (-1) * Mathf.Sign(groundSpeed) * groundAcceleration * speed; + if (Mathf.Abs(groundSpeed) < groundAcceleration * speed) + groundSpeed = 0; + } + } + } + else // ground deceleration while pressing nothing { - if (realSpeed != 0) + if (groundSpeed != 0) { - realSpeed += (-1) * Mathf.Sign(realSpeed) * friction; - if (Mathf.Abs(realSpeed) < friction) - realSpeed = 0; + groundSpeed += (-1) * Mathf.Sign(groundSpeed) * groundAcceleration * speed; + if (Mathf.Abs(groundSpeed) < groundAcceleration * speed) + groundSpeed = 0; } } - body.velocity = new Vector2(realSpeed, body.velocity.y); - } + + body.velocity = new Vector2(groundSpeed, body.velocity.y); + + } //in air and not sliding else if (!collisionState.onWall || body.velocity.y > 0) { @@ -75,13 +89,13 @@ public class Walk : AbstractBehavior { if (inputState.GetButtonValue(right) || inputState.GetButtonValue(left)) { if(Mathf.Abs(airSpeed) <= speed) - airSpeed = Mathf.Clamp(airSpeed + airAcceleration * (rightInt + leftInt), -speed, speed); + airSpeed = Mathf.Clamp(airSpeed + airAcceleration * speed * (rightInt + leftInt), -speed, speed); else { if (airSpeed != 0) { - airSpeed += (-1) * Mathf.Sign(airSpeed) * airAcceleration; - if (Mathf.Abs(airSpeed) < airAcceleration) + airSpeed += (-1) * Mathf.Sign(airSpeed) * airAcceleration * speed; + if (Mathf.Abs(airSpeed) < airAcceleration * speed) airSpeed = 0; } } @@ -90,8 +104,8 @@ public class Walk : AbstractBehavior { { if (airSpeed != 0) { - airSpeed += (-1) * Mathf.Sign(airSpeed) * airAcceleration; - if (Mathf.Abs(airSpeed) < airAcceleration) + airSpeed += (-1) * Mathf.Sign(airSpeed) * airAcceleration * speed; + if (Mathf.Abs(airSpeed) < airAcceleration * speed) airSpeed = 0; } }*/ diff --git a/birb.sln b/birb.sln index 9e258316ed54e48f329c08fc74e058fb8286fa95..b65bf05e4d17cbe206fdbfe5466380f7fa43315f 100644 --- a/birb.sln +++ b/birb.sln @@ -1,7 +1,7 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Birb", "Assembly-CSharp.csproj", "{A490B848-188F-485C-9203-EFF824787523}" +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2015 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Birb", "Birb.csproj", "{0E1C9E80-2222-A473-1DED-289BBAAF06DC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -9,15 +9,12 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A490B848-188F-485C-9203-EFF824787523}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A490B848-188F-485C-9203-EFF824787523}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A490B848-188F-485C-9203-EFF824787523}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A490B848-188F-485C-9203-EFF824787523}.Release|Any CPU.Build.0 = Release|Any CPU + {0E1C9E80-2222-A473-1DED-289BBAAF06DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0E1C9E80-2222-A473-1DED-289BBAAF06DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0E1C9E80-2222-A473-1DED-289BBAAF06DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0E1C9E80-2222-A473-1DED-289BBAAF06DC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(MonoDevelopProperties) = preSolution - StartupItem = Assembly-CSharp.csproj - EndGlobalSection EndGlobal