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

Merge branch 'master' into tetris

parents af70e9f8 4bbe3878
This diff is collapsed.
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: PlayerGoingDownAnim
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves:
- curve:
- time: 0
value: {fileID: 21300000, guid: c2f9f5a4cddceda4e941d2505563f825, type: 3}
attribute: m_Sprite
path:
classID: 212
script: {fileID: 0}
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 0
attribute: 0
script: {fileID: 0}
typeID: 212
customType: 23
isPPtrCurve: 1
pptrCurveMapping:
- {fileID: 21300000, guid: c2f9f5a4cddceda4e941d2505563f825, type: 3}
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.016666668
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves: []
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_GenerateMotionCurves: 0
m_Events: []
fileFormatVersion: 2
guid: f91c870ab8e91fd449c7928c7b149a1f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: PlayerGoingUpAnim
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves:
- curve:
- time: 0
value: {fileID: 21300000, guid: d8d54addde630d14aafacc31de2e47c7, type: 3}
attribute: m_Sprite
path:
classID: 212
script: {fileID: 0}
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 0
attribute: 0
script: {fileID: 0}
typeID: 212
customType: 23
isPPtrCurve: 1
pptrCurveMapping:
- {fileID: 21300000, guid: d8d54addde630d14aafacc31de2e47c7, type: 3}
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.016666668
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves: []
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_GenerateMotionCurves: 0
m_Events: []
fileFormatVersion: 2
guid: 44ed96ed5e7417f43abd7860211d6c11
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:
...@@ -59,7 +59,7 @@ Rigidbody2D: ...@@ -59,7 +59,7 @@ Rigidbody2D:
m_Mass: 1 m_Mass: 1
m_LinearDrag: 0 m_LinearDrag: 0
m_AngularDrag: 0.05 m_AngularDrag: 0.05
m_GravityScale: 2 m_GravityScale: 5
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Interpolate: 0 m_Interpolate: 0
m_SleepingMode: 1 m_SleepingMode: 1
...@@ -77,7 +77,7 @@ BoxCollider2D: ...@@ -77,7 +77,7 @@ BoxCollider2D:
m_IsTrigger: 0 m_IsTrigger: 0
m_UsedByEffector: 0 m_UsedByEffector: 0
m_UsedByComposite: 0 m_UsedByComposite: 0
m_Offset: {x: 0, y: -0.1} m_Offset: {x: 0, y: -0.09}
m_SpriteTilingProperty: m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0} border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5} pivot: {x: 0.5, y: 0.5}
...@@ -88,7 +88,7 @@ BoxCollider2D: ...@@ -88,7 +88,7 @@ BoxCollider2D:
adaptiveTiling: 0 adaptiveTiling: 0
m_AutoTiling: 0 m_AutoTiling: 0
serializedVersion: 2 serializedVersion: 2
m_Size: {x: 0.7, y: 1.4} m_Size: {x: 0.7, y: 1.5}
m_EdgeRadius: 0 m_EdgeRadius: 0
--- !u!95 &95992411616135034 --- !u!95 &95992411616135034
Animator: Animator:
...@@ -119,10 +119,11 @@ MonoBehaviour: ...@@ -119,10 +119,11 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f289cad4933d4bf42ae5c82c57bd88e4, type: 3} m_Script: {fileID: 11500000, guid: f289cad4933d4bf42ae5c82c57bd88e4, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
maxSpeed: 5 rbGravityScale: 3
maxDashSpeed: 10 maxSpeed: 3
maxDashSpeed: 6
accerlation: 1200 accerlation: 1200
jumpSpeed: 10 jumpSpeed: 11
ropeSpeed: 3 ropeSpeed: 3
doubleJumpSpeed: 10 doubleJumpSpeed: 10
dashAccerlation: 2000 dashAccerlation: 2000
......
...@@ -8,6 +8,8 @@ public class PlayerController : MonoBehaviour ...@@ -8,6 +8,8 @@ public class PlayerController : MonoBehaviour
private Rigidbody2D rb; // RigidBody2D of this game object private Rigidbody2D rb; // RigidBody2D of this game object
private Animator anim; private Animator anim;
[SerializeField]
private float rbGravityScale;
// Speeds of player // Speeds of player
[SerializeField] [SerializeField]
private float maxSpeed; private float maxSpeed;
...@@ -29,7 +31,6 @@ public class PlayerController : MonoBehaviour ...@@ -29,7 +31,6 @@ public class PlayerController : MonoBehaviour
// Bool values for jump & doublejump // Bool values for jump & doublejump
private bool isGrounded = true; private bool isGrounded = true;
private bool isJumpable = true; // Can player jump or doublejump? private bool isJumpable = true; // Can player jump or doublejump?
private bool isInRope = false;
private bool isDownPlatform = false; private bool isDownPlatform = false;
private bool ropeEnabled = true; private bool ropeEnabled = true;
// Inputs // Inputs
...@@ -56,14 +57,17 @@ public class PlayerController : MonoBehaviour ...@@ -56,14 +57,17 @@ public class PlayerController : MonoBehaviour
private float rayDistance; private float rayDistance;
[SerializeField] [SerializeField]
private float ropeUp, ropeDown; private float ropeUp, ropeDown;
// Use this for initialization enum PlayerState { Idle, Walk, Run, GoingUp, GoingDown, Rope}
PlayerState playerState,previousState;
void Start() void Start()
{ {
rb = gameObject.GetComponent<Rigidbody2D>(); rb = gameObject.GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>(); anim = GetComponent<Animator>();
playerState = PlayerState.Idle;
previousState = PlayerState.Idle;
} }
// Update is called once per frame
void Update() void Update()
{ {
horizontal = Input.GetAxis("Horizontal"); horizontal = Input.GetAxis("Horizontal");
...@@ -82,15 +86,6 @@ public class PlayerController : MonoBehaviour ...@@ -82,15 +86,6 @@ public class PlayerController : MonoBehaviour
if (GameManager.gameState == GameState.Ingame && MapManager.isDoorClosing != true) if (GameManager.gameState == GameState.Ingame && MapManager.isDoorClosing != true)
{ {
anim.SetBool("rope", isInRope);
anim.SetBool("run", isDashing);
anim.SetBool("ground", isGrounded);
anim.SetFloat("vspeed", rb.velocity.y);
anim.SetFloat("speed", Mathf.Abs(rb.velocity.x));
if (isGrounded || isInRope)
{
anim.SetBool("jump", false);
}
if (isGrounded) if (isGrounded)
isJumpable = true; isJumpable = true;
...@@ -114,12 +109,12 @@ public class PlayerController : MonoBehaviour ...@@ -114,12 +109,12 @@ public class PlayerController : MonoBehaviour
} }
if (IsInRope()) if (IsInRope())
{ {
if (isInRope) if (playerState == PlayerState.Rope)
{ {
if (horizontalRaw != 0f && verticalRaw == 0f) if (horizontalRaw != 0f && verticalRaw == 0f)
{ {
isInRope = false; playerState = PlayerState.Idle;
rb.gravityScale = 2f; rb.gravityScale = rbGravityScale;
StartCoroutine(RopeDelay()); StartCoroutine(RopeDelay());
} }
...@@ -128,19 +123,20 @@ public class PlayerController : MonoBehaviour ...@@ -128,19 +123,20 @@ public class PlayerController : MonoBehaviour
} }
else if (verticalRaw != 0 && ropeEnabled && horizontalRaw == 0) else if (verticalRaw != 0 && ropeEnabled && horizontalRaw == 0)
{ {
isInRope = true; playerState = PlayerState.Rope;
rb.gravityScale = 0f; rb.gravityScale = 0f;
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);
}
} }
anim.SetFloat("ropeUpDown", verticalRaw);
}
else else
{ {
isInRope = false; playerState = PlayerState.Idle;
rb.gravityScale = 2f; rb.gravityScale = rbGravityScale;
} }
if (!isInRope) if (playerState != PlayerState.Rope)
{ {
float vertical = rb.velocity.y; float vertical = rb.velocity.y;
if (jump) if (jump)
...@@ -148,20 +144,20 @@ public class PlayerController : MonoBehaviour ...@@ -148,20 +144,20 @@ public class PlayerController : MonoBehaviour
if (isGrounded) if (isGrounded)
{ {
vertical = jumpSpeed; vertical = jumpSpeed;
anim.SetBool("jump", true);
} }
else if (isJumpable) else if (isJumpable)
{ {
vertical = doubleJumpSpeed; vertical = doubleJumpSpeed;
anim.SetBool("jump", true);
isJumpable = false; isJumpable = false;
} }
} }
if (!isGrounded)
{
if (vertical > 0) playerState = PlayerState.GoingUp;
else playerState = PlayerState.GoingDown;
}
//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)
...@@ -192,6 +188,15 @@ public class PlayerController : MonoBehaviour ...@@ -192,6 +188,15 @@ public class PlayerController : MonoBehaviour
else else
rb.AddForce(horizontalRaw * accerlation * Time.smoothDeltaTime * Vector2.right); rb.AddForce(horizontalRaw * accerlation * Time.smoothDeltaTime * Vector2.right);
if (isGrounded)
{
if (horizontalRaw == 0) playerState = PlayerState.Idle;
else
{
if (isDashing) playerState = PlayerState.Run;
else playerState = PlayerState.Walk;
}
}
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))
{ {
...@@ -202,7 +207,17 @@ public class PlayerController : MonoBehaviour ...@@ -202,7 +207,17 @@ public class PlayerController : MonoBehaviour
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);
} }
if(previousState != playerState)
switch (playerState)
{
case PlayerState.Idle: anim.SetTrigger("idle"); break;
case PlayerState.Walk: anim.SetTrigger("walk"); break;
case PlayerState.Run: anim.SetTrigger("run"); break;
case PlayerState.GoingUp: anim.SetTrigger("upTrigger"); break;
case PlayerState.GoingDown: anim.SetTrigger("downTrigger"); break;
case PlayerState.Rope: anim.SetTrigger("rope"); break;
}
previousState = playerState;
} }
jump = false; jump = false;
} }
...@@ -234,7 +249,7 @@ public class PlayerController : MonoBehaviour ...@@ -234,7 +249,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); while(playerState == PlayerState.Rope) yield return new WaitForSeconds(0.1f);
element.enabled = true; element.enabled = true;
isDownPlatform = false; isDownPlatform = false;
} }
......
fileFormatVersion: 2
guid: 45bb2ce35c41f334497f5dd868082217
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: c2f9f5a4cddceda4e941d2505563f825
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 6
mipmaps:
mipMapMode: 0
enableMipMap: 0
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
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 64
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: c09e8e3bf16d57344a4567a4d491afc9
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: f99f5101ae1b7b8449e74cfe45853872
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: d8d54addde630d14aafacc31de2e47c7
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 6
mipmaps:
mipMapMode: 0
enableMipMap: 0
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
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 64
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: cfcb40e6fc5174d479d2ab3aef50c3b5
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
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