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
c06af86d
Commit
c06af86d
authored
Feb 25, 2019
by
18김상언
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
준형이가 플레이어 컨트롤러 수정한거 여기서 푸쉬함.
이제 구석에 있는 생명석도 먹어지는 듯 하다. 아이템 먹는 알고리즘: 플레이어랑 거리상으로 가장 가까운거부터 먹어짐.
parent
1ac8693c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
5 deletions
+29
-5
PlayerController.cs
Assets/Scripts/Characters/PlayerController.cs
+29
-5
No files found.
Assets/Scripts/Characters/PlayerController.cs
View file @
c06af86d
...
...
@@ -261,14 +261,38 @@ public class PlayerController : MonoBehaviour
bool
GetItemRay
()
{
RaycastHit2D
hit
=
Physics2D
.
Raycast
(
transform
.
position
,
Vector2
.
down
,
rayDistance
,
itemLayer
);
if
(
hit
.
collider
!=
null
)
RaycastHit2D
hit
=
Physics2D
.
Raycast
(
transform
.
position
,
Vector2
.
down
,
rayDistance
,
portalLayer
);
;
RaycastHit2D
[]
hits
;
hits
=
Physics2D
.
BoxCastAll
(
transform
.
position
,
new
Vector2
(
Player
.
X
,
boxHeight
),
0
,
Vector2
.
down
,
Player
.
Y
/
2f
,
itemLayer
);
if
(
hits
.
Length
>
0
)
//if no object was found there is no minimum
{
IPlayerInteraction
temp
=
hit
.
collider
.
GetComponent
<
IPlayerInteraction
>();
float
min
=
hits
[
0
].
distance
;
//lets assume that the minimum is at the 0th place
int
minIndex
=
0
;
//store the index of the minimum because thats hoow we can find our object
for
(
int
i
=
1
;
i
<
hits
.
Length
;
++
i
)
// iterate from the 1st element to the last.(Note that we ignore the 0th element)
{
if
(
hits
[
i
].
transform
!=
gameObject
.
transform
&&
hits
[
i
].
distance
<
min
)
//if we found smaller distance and its not the player we got a new minimum
{
min
=
hits
[
i
].
distance
;
//refresh the minimum distance value
minIndex
=
i
;
//refresh the distance
}
}
IPlayerInteraction
temp
=
hits
[
minIndex
].
collider
.
GetComponent
<
IPlayerInteraction
>();
if
(
lastDropItem
!=
null
)
lastDropItem
.
HighlightSwitch
(
false
);
if
(
temp
!=
null
)
temp
.
HighlightSwitch
(
true
);
lastDropItem
=
temp
;
}
else
{
...
...
@@ -283,7 +307,7 @@ public class PlayerController : MonoBehaviour
}
}
return
hit
.
collider
!=
null
;
return
hit
.
collider
!=
null
||
hits
.
Length
>
0
;
}
bool
IsInRope
()
// Is player in rope?
{
...
...
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