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:
m_EditorClassIdentifier:
maxSpeed: 5
maxDashSpeed: 10
accerlation: 600
accerlation: 1200
jumpSpeed: 10
ropeSpeed: 3
doubleJumpSpeed: 10
dashAccerlation: 1000
dashAccerlation: 2000
isDashing: 0
platformArray: []
horizontal: 0
......@@ -348,7 +348,7 @@ BoxCollider2D:
m_GameObject: {fileID: 489222433}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_Material: {fileID: 6200000, guid: 90e689a435f304c469db49daef28ed89, type: 2}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
......
......@@ -77,16 +77,30 @@ public class PlayerController : MonoBehaviour
private void FixedUpdate()
{
isGrounded = IsGrounded();
if (GameManager.gameState == GameManager.GameState.Ingame)
{
if (isGrounded)
isJumpable = true;
if(isGrounded)
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 (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)
......@@ -97,7 +111,7 @@ public class PlayerController : MonoBehaviour
rb.gravityScale = 2f;
StartCoroutine(RopeDelay());
}
}
rb.velocity = new Vector2(0f, verticalRaw * ropeSpeed);
}
......@@ -108,6 +122,7 @@ public class PlayerController : MonoBehaviour
transform.position = new Vector2(Mathf.Round(transform.position.x - 0.5f) + 0.5f, transform.position.y);
rb.velocity = new Vector2(0f, 0f);
}
}
else
{
......@@ -129,47 +144,37 @@ public class PlayerController : MonoBehaviour
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(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;
}
}
if(horizontalRaw == 0 && horizontal != 0 && dashStart == 1)
if (horizontalRaw == 0 && horizontal != 0 && dashStart == 1)
{
//방금 뗐을때
dashStart = 2;
//이제 빠르게 켜면 됨
}
if(dashStart == 2 && horizontalRaw != 0)
if (dashStart == 2 && horizontalRaw != 0)
{
isDashing = true;
}
if(horizontalRaw == 0 && horizontal == 0)
if (horizontalRaw == 0 && horizontal == 0)
{
dashStart = 0;
isDashing = false;
}
if(isDashing)
if (isDashing)
rb.AddForce(horizontalRaw * dashAccerlation * Time.smoothDeltaTime * Vector2.right);
else
rb.AddForce(horizontalRaw * accerlation * Time.smoothDeltaTime * Vector2.right);
......@@ -177,11 +182,14 @@ public class PlayerController : MonoBehaviour
if (((horizontalRaw == 0) || (rb.velocity.x > 0 && horizontalRaw < 0)
|| (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
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;
}
......@@ -213,6 +221,7 @@ public class PlayerController : MonoBehaviour
{
element.enabled = false;
yield return new WaitForSeconds(0.3f);
while(isInRope) yield return new WaitForSeconds(0.1f);
element.enabled = true;
isDownPlatform = false;
}
......@@ -224,6 +233,7 @@ public class PlayerController : MonoBehaviour
isJumpable = true;
yield return new WaitForSeconds(0.5f);
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