Commit a8be51e1 authored by 18손재민's avatar 18손재민

Merge branch 'master' into tetris

parents 33a4595c 5e04126a
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!62 &6200000
PhysicsMaterial2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: nofriction
friction: 0
bounciness: 0
fileFormatVersion: 2
guid: 90e689a435f304c469db49daef28ed89
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 6200000
userData:
assetBundleName:
assetBundleVariant:
...@@ -255,11 +255,11 @@ MonoBehaviour: ...@@ -255,11 +255,11 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
maxSpeed: 5 maxSpeed: 5
maxDashSpeed: 10 maxDashSpeed: 10
accerlation: 600 accerlation: 1200
jumpSpeed: 10 jumpSpeed: 10
ropeSpeed: 3 ropeSpeed: 3
doubleJumpSpeed: 10 doubleJumpSpeed: 10
dashAccerlation: 1000 dashAccerlation: 2000
isDashing: 0 isDashing: 0
platformArray: [] platformArray: []
horizontal: 0 horizontal: 0
...@@ -348,7 +348,7 @@ BoxCollider2D: ...@@ -348,7 +348,7 @@ BoxCollider2D:
m_GameObject: {fileID: 489222433} m_GameObject: {fileID: 489222433}
m_Enabled: 1 m_Enabled: 1
m_Density: 1 m_Density: 1
m_Material: {fileID: 0} m_Material: {fileID: 6200000, guid: 90e689a435f304c469db49daef28ed89, type: 2}
m_IsTrigger: 0 m_IsTrigger: 0
m_UsedByEffector: 0 m_UsedByEffector: 0
m_UsedByComposite: 0 m_UsedByComposite: 0
......
...@@ -77,59 +77,20 @@ public class PlayerController : MonoBehaviour ...@@ -77,59 +77,20 @@ public class PlayerController : MonoBehaviour
private void FixedUpdate() private void FixedUpdate()
{ {
isGrounded = IsGrounded(); isGrounded = IsGrounded();
if (isGrounded)
isJumpable = true;
if(isGrounded)
{
if (horizontalRaw == 1f) transform.localScale = new Vector3(1f, transform.localScale.y, transform.localScale.z);
else if (horizontalRaw == -1f) transform.localScale = new Vector3(-1f, transform.localScale.y, transform.localScale.z);
}
if (GameManager.gameState == GameManager.GameState.Ingame)
if (IsInRope())
{ {
if (isInRope)
{
if (horizontalRaw != 0f && verticalRaw == 0f)
{
isInRope = false;
rb.gravityScale = 2f;
StartCoroutine(RopeDelay());
}
rb.velocity = new Vector2(0f, verticalRaw * ropeSpeed);
} if (isGrounded)
else if (verticalRaw != 0 && ropeEnabled && horizontalRaw == 0) isJumpable = true;
if (isGrounded)
{ {
isInRope = true; if (horizontalRaw == 1f) transform.localScale = new Vector3(1f, transform.localScale.y, transform.localScale.z);
rb.gravityScale = 0f; else if (horizontalRaw == -1f) transform.localScale = new Vector3(-1f, transform.localScale.y, transform.localScale.z);
transform.position = new Vector2(Mathf.Round(transform.position.x - 0.5f) + 0.5f, transform.position.y);
rb.velocity = new Vector2(0f, 0f);
} }
}
else
{ if (verticalRaw == -1 && !isDownPlatform)
isInRope = false;
rb.gravityScale = 2f;
}
if (!isInRope)
{
float vertical = rb.velocity.y;
if (jump)
{
if (isGrounded)
{
vertical = jumpSpeed;
}
else if (isJumpable)
{
vertical = doubleJumpSpeed;
isJumpable = false;
}
}
if(verticalRaw == -1 && !isDownPlatform)
{ {
RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.down, rayDistance, platformLayer); RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.down, rayDistance, platformLayer);
if (hit.collider != null && rb.velocity.y == 0) if (hit.collider != null && rb.velocity.y == 0)
...@@ -140,48 +101,95 @@ public class PlayerController : MonoBehaviour ...@@ -140,48 +101,95 @@ public class PlayerController : MonoBehaviour
StartCoroutine(DownPlatform()); StartCoroutine(DownPlatform());
} }
} }
if (IsInRope())
{
if (isInRope)
{
if (horizontalRaw != 0f && verticalRaw == 0f)
{
isInRope = false;
rb.gravityScale = 2f;
StartCoroutine(RopeDelay());
//rb.velocity = new Vector2(horizontal * speed * Time.smoothDeltaTime, vertical); }
// rb.velocity = new Vector2(rb.velocity.x, vertical); rb.velocity = new Vector2(0f, verticalRaw * ropeSpeed);
if(horizontalRaw != 0) }
{ else if (verticalRaw != 0 && ropeEnabled && horizontalRaw == 0)
if(horizontal != 1 && horizontal != -1 && dashStart == 0)
{ {
//짧게 눌렀을 때 isInRope = true;
dashStart = 1; rb.gravityScale = 0f;
transform.position = new Vector2(Mathf.Round(transform.position.x - 0.5f) + 0.5f, transform.position.y);
rb.velocity = new Vector2(0f, 0f);
} }
} }
if(horizontalRaw == 0 && horizontal != 0 && dashStart == 1) else
{
//방금 뗐을때
dashStart = 2;
//이제 빠르게 켜면 됨
}
if(dashStart == 2 && horizontalRaw != 0)
{ {
isDashing = true; isInRope = false;
rb.gravityScale = 2f;
} }
if(horizontalRaw == 0 && horizontal == 0) if (!isInRope)
{ {
dashStart = 0; float vertical = rb.velocity.y;
isDashing = false; if (jump)
} {
if (isGrounded)
{
if(isDashing) vertical = jumpSpeed;
rb.AddForce(horizontalRaw * dashAccerlation * Time.smoothDeltaTime * Vector2.right); }
else else if (isJumpable)
rb.AddForce(horizontalRaw * accerlation * Time.smoothDeltaTime * Vector2.right); {
vertical = doubleJumpSpeed;
isJumpable = false;
}
}
if (((horizontalRaw == 0) || (rb.velocity.x > 0 && horizontalRaw < 0)
|| (rb.velocity.x < 0 && horizontalRaw > 0)) && (isGrounded)) //rb.velocity = new Vector2(horizontal * speed * Time.smoothDeltaTime, vertical);
{ // rb.velocity = new Vector2(rb.velocity.x, vertical);
rb.AddForce(rb.velocity.x * (-10f) * Vector2.right * Time.smoothDeltaTime);
if (horizontalRaw != 0)
{
if (horizontal != 1 && horizontal != -1 && dashStart == 0)
{
//짧게 눌렀을 때
dashStart = 1;
}
}
if (horizontalRaw == 0 && horizontal != 0 && dashStart == 1)
{
//방금 뗐을때
dashStart = 2;
//이제 빠르게 켜면 됨
}
if (dashStart == 2 && horizontalRaw != 0)
{
isDashing = true;
}
if (horizontalRaw == 0 && horizontal == 0)
{
dashStart = 0;
isDashing = false;
}
if (isDashing)
rb.AddForce(horizontalRaw * dashAccerlation * Time.smoothDeltaTime * Vector2.right);
else
rb.AddForce(horizontalRaw * accerlation * Time.smoothDeltaTime * Vector2.right);
if (((horizontalRaw == 0) || (rb.velocity.x > 0 && horizontalRaw < 0)
|| (rb.velocity.x < 0 && horizontalRaw > 0)) && (isGrounded))
{
// rb.AddForce(rb.velocity.x * (-100f) * Vector2.right * Time.smoothDeltaTime);
rb.velocity = new Vector2(rb.velocity.x / (1.5f), rb.velocity.y);
}
if (isDashing) rb.velocity = new Vector2(Mathf.Clamp(rb.velocity.x, -maxDashSpeed, maxDashSpeed), vertical);
else
rb.velocity = new Vector2(Mathf.Clamp(rb.velocity.x, -maxSpeed, maxSpeed), vertical);
} }
if(isDashing) rb.velocity = new Vector2(Mathf.Clamp(rb.velocity.x, -maxDashSpeed, maxDashSpeed), vertical);
else
rb.velocity = new Vector2(Mathf.Clamp(rb.velocity.x, -maxSpeed , maxSpeed ), vertical);
} }
jump = false; jump = false;
} }
...@@ -213,6 +221,7 @@ public class PlayerController : MonoBehaviour ...@@ -213,6 +221,7 @@ public class PlayerController : MonoBehaviour
{ {
element.enabled = false; element.enabled = false;
yield return new WaitForSeconds(0.3f); yield return new WaitForSeconds(0.3f);
while(isInRope) yield return new WaitForSeconds(0.1f);
element.enabled = true; element.enabled = true;
isDownPlatform = false; isDownPlatform = false;
} }
...@@ -224,6 +233,7 @@ public class PlayerController : MonoBehaviour ...@@ -224,6 +233,7 @@ public class PlayerController : MonoBehaviour
isJumpable = true; isJumpable = true;
yield return new WaitForSeconds(0.5f); yield return new WaitForSeconds(0.5f);
ropeEnabled = true; ropeEnabled = true;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment