Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
tetra-tower
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Oenos
tetra-tower
Commits
a8be51e1
Commit
a8be51e1
authored
Jan 12, 2019
by
18손재민
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into tetris
parents
33a4595c
5e04126a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
83 deletions
+111
-83
nofriction.physicsMaterial2D
Assets/Prefabs/Characters/nofriction.physicsMaterial2D
+10
-0
nofriction.physicsMaterial2D.meta
Assets/Prefabs/Characters/nofriction.physicsMaterial2D.meta
+8
-0
PlayScene.unity
Assets/Scenes/PlayScene.unity
+3
-3
PlayerController.cs
Assets/Scripts/Characters/PlayerController.cs
+90
-80
No files found.
Assets/Prefabs/Characters/nofriction.physicsMaterial2D
0 → 100644
View file @
a8be51e1
%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
Assets/Prefabs/Characters/nofriction.physicsMaterial2D.meta
0 → 100644
View file @
a8be51e1
fileFormatVersion: 2
guid: 90e689a435f304c469db49daef28ed89
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 6200000
userData:
assetBundleName:
assetBundleVariant:
Assets/Scenes/PlayScene.unity
View file @
a8be51e1
...
...
@@ -255,11 +255,11 @@ MonoBehaviour:
m_EditorClassIdentifier
:
maxSpeed
:
5
maxDashSpeed
:
10
accerlation
:
6
00
accerlation
:
12
00
jumpSpeed
:
10
ropeSpeed
:
3
doubleJumpSpeed
:
10
dashAccerlation
:
1
000
dashAccerlation
:
2
000
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
...
...
Assets/Scripts/Characters/PlayerController.cs
View file @
a8be51e1
...
...
@@ -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
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment