Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
curvedflats
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
6
Issues
6
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Flatland
curvedflats
Commits
7b8196ca
Commit
7b8196ca
authored
5 years ago
by
17김현학
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change fomula easily that calculate path point in Screen.
parent
9aec2d93
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
18 deletions
+21
-18
UIManager.cs
Assets/Scripts/UIManager.cs
+21
-18
No files found.
Assets/Scripts/UIManager.cs
View file @
7b8196ca
...
...
@@ -161,22 +161,6 @@ public class UIManager : MonoBehaviour
return
point
-
canvasSize
*
0.5f
+
middlePoint
;
}
private
Vector3
getDestVector
(
Vector3
ScreenVector
,
Vector3
RealVector
)
{
ScreenVector
.
z
=
0
;
RealVector
=
getXYVectorfromXZVector
(
RealVector
);
var
v
=
square
.
GetDestPoint
(
prevSelectPathNum
)
-
RealVector
;
var
k
=
ScreenVector
.
magnitude
/
RealVector
.
magnitude
;
return
k
*
v
;
}
private
Vector3
getVectorFromAtoB
(
Vector3
a
,
Vector3
b
)
{
var
ret
=
b
-
a
;
return
ret
;
}
public
Vector3
getXYVectorfromXZVector
(
Vector3
v
)
{
return
new
Vector3
(
v
.
x
,
v
.
z
,
0.0f
);
...
...
@@ -189,6 +173,16 @@ public class UIManager : MonoBehaviour
velocityslider
.
UpdateValuebyVelocity
(
square
.
GetPathVelocity
(
pathNum
));
}
private
Vector3
getInnerProduct
(
Vector3
a
,
Vector3
b
)
{
return
new
Vector3
(
a
.
x
*
b
.
x
,
a
.
y
*
b
.
y
,
a
.
z
*
b
.
z
);
}
private
Vector3
getRatio
(
Vector3
a
,
Vector3
b
)
{
return
new
Vector3
(
a
.
x
/
b
.
x
,
a
.
y
/
b
.
y
,
1.0f
);
}
private
void
TryFIndPath
()
{
RaycastHit
hit1
;
...
...
@@ -211,11 +205,20 @@ public class UIManager : MonoBehaviour
updatePathInfo
(
pathNum
);
var
mouseClickPosition
=
getMouseClickPosition
(
hit1
);
var
v
=
getDestVector
(
getVectorFromAtoB
(
middlePoint
,
mouseClickPosition
),
getVectorFromAtoB
(
player
.
transform
.
position
,
hit2
.
point
));
var
tmp
=
mouseClickPosition
-
middlePoint
;
var
tmp2
=
getXYVectorfromXZVector
(
hit2
.
point
);
var
v
=
square
.
pathList
[
pathNum
+
1
];
var
k
=
getRatio
(
tmp
,
tmp2
);
_pathUI
.
transform
.
position
=
mouseClickPosition
+
v
;
_pathUI
.
transform
.
position
=
getInnerProduct
(
v
,
k
)
+
middlePoint
;
_pathUI
.
SetActive
(
true
);
}
else
{
_pathUI
.
SetActive
(
false
);
prevSelectPathNum
=
-
1
;
sliderflag
=
0
;
}
}
else
{
...
...
This diff is collapsed.
Click to expand it.
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