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,16 +77,30 @@ public class PlayerController : MonoBehaviour ...@@ -77,16 +77,30 @@ public class PlayerController : MonoBehaviour
private void FixedUpdate() private void FixedUpdate()
{ {
isGrounded = IsGrounded(); isGrounded = IsGrounded();
if (GameManager.gameState == GameManager.GameState.Ingame)
{
if (isGrounded) if (isGrounded)
isJumpable = true; isJumpable = true;
if(isGrounded) if (isGrounded)
{ {
if (horizontalRaw == 1f) transform.localScale = new Vector3(1f, transform.localScale.y, transform.localScale.z); 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); else if (horizontalRaw == -1f) transform.localScale = new Vector3(-1f, transform.localScale.y, transform.localScale.z);
} }
if (verticalRaw == -1 && !isDownPlatform)
{
RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.down, rayDistance, platformLayer);
if (hit.collider != null && rb.velocity.y == 0)
{
Room curRoom = MapManager.mapGrid[Player.tx, Player.ty];
platformArray = curRoom.GetComponentsInChildren<TilemapCollider2D>();
isDownPlatform = true;
StartCoroutine(DownPlatform());
}
}
if (IsInRope()) if (IsInRope())
{ {
if (isInRope) if (isInRope)
...@@ -97,7 +111,7 @@ public class PlayerController : MonoBehaviour ...@@ -97,7 +111,7 @@ public class PlayerController : MonoBehaviour
rb.gravityScale = 2f; rb.gravityScale = 2f;
StartCoroutine(RopeDelay()); StartCoroutine(RopeDelay());
} }
rb.velocity = new Vector2(0f, verticalRaw * ropeSpeed); rb.velocity = new Vector2(0f, verticalRaw * ropeSpeed);
} }
...@@ -108,6 +122,7 @@ public class PlayerController : MonoBehaviour ...@@ -108,6 +122,7 @@ public class PlayerController : MonoBehaviour
transform.position = new Vector2(Mathf.Round(transform.position.x - 0.5f) + 0.5f, transform.position.y); transform.position = new Vector2(Mathf.Round(transform.position.x - 0.5f) + 0.5f, transform.position.y);
rb.velocity = new Vector2(0f, 0f); rb.velocity = new Vector2(0f, 0f);
} }
} }
else else
{ {
...@@ -129,47 +144,37 @@ public class PlayerController : MonoBehaviour ...@@ -129,47 +144,37 @@ public class PlayerController : MonoBehaviour
isJumpable = false; isJumpable = false;
} }
} }
if(verticalRaw == -1 && !isDownPlatform)
{
RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.down, rayDistance, platformLayer);
if (hit.collider != null && rb.velocity.y == 0)
{
Room curRoom = MapManager.mapGrid[Player.tx, Player.ty];
platformArray = curRoom.GetComponentsInChildren<TilemapCollider2D>();
isDownPlatform = true;
StartCoroutine(DownPlatform());
}
}
//rb.velocity = new Vector2(horizontal * speed * Time.smoothDeltaTime, vertical); //rb.velocity = new Vector2(horizontal * speed * Time.smoothDeltaTime, vertical);
// rb.velocity = new Vector2(rb.velocity.x, vertical); // rb.velocity = new Vector2(rb.velocity.x, vertical);
if(horizontalRaw != 0) if (horizontalRaw != 0)
{ {
if(horizontal != 1 && horizontal != -1 && dashStart == 0) if (horizontal != 1 && horizontal != -1 && dashStart == 0)
{ {
//짧게 눌렀을 때 //짧게 눌렀을 때
dashStart = 1; dashStart = 1;
} }
} }
if(horizontalRaw == 0 && horizontal != 0 && dashStart == 1) if (horizontalRaw == 0 && horizontal != 0 && dashStart == 1)
{ {
//방금 뗐을때 //방금 뗐을때
dashStart = 2; dashStart = 2;
//이제 빠르게 켜면 됨 //이제 빠르게 켜면 됨
} }
if(dashStart == 2 && horizontalRaw != 0) if (dashStart == 2 && horizontalRaw != 0)
{ {
isDashing = true; isDashing = true;
} }
if(horizontalRaw == 0 && horizontal == 0) if (horizontalRaw == 0 && horizontal == 0)
{ {
dashStart = 0; dashStart = 0;
isDashing = false; isDashing = false;
} }
if(isDashing) if (isDashing)
rb.AddForce(horizontalRaw * dashAccerlation * Time.smoothDeltaTime * Vector2.right); rb.AddForce(horizontalRaw * dashAccerlation * Time.smoothDeltaTime * Vector2.right);
else else
rb.AddForce(horizontalRaw * accerlation * Time.smoothDeltaTime * Vector2.right); rb.AddForce(horizontalRaw * accerlation * Time.smoothDeltaTime * Vector2.right);
...@@ -177,11 +182,14 @@ public class PlayerController : MonoBehaviour ...@@ -177,11 +182,14 @@ public class PlayerController : MonoBehaviour
if (((horizontalRaw == 0) || (rb.velocity.x > 0 && horizontalRaw < 0) if (((horizontalRaw == 0) || (rb.velocity.x > 0 && horizontalRaw < 0)
|| (rb.velocity.x < 0 && horizontalRaw > 0)) && (isGrounded)) || (rb.velocity.x < 0 && horizontalRaw > 0)) && (isGrounded))
{ {
rb.AddForce(rb.velocity.x * (-10f) * Vector2.right * Time.smoothDeltaTime); // 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); if (isDashing) rb.velocity = new Vector2(Mathf.Clamp(rb.velocity.x, -maxDashSpeed, maxDashSpeed), vertical);
else else
rb.velocity = new Vector2(Mathf.Clamp(rb.velocity.x, -maxSpeed , maxSpeed ), vertical); 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