Commit 2b23d67e authored by 17김현학's avatar 17김현학

bug fix (Issue #34)

parent c68027c9
......@@ -420,8 +420,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 77}
m_SizeDelta: {x: 700, y: 100}
m_AnchoredPosition: {x: 0, y: 45.09999}
m_SizeDelta: {x: 700, y: 36.2}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &353909222
MonoBehaviour:
......@@ -1914,6 +1914,7 @@ MonoBehaviour:
levelManager: {fileID: 279236944}
background: {fileID: 1713675715}
velocityslider: {fileID: 260633610}
ui: {fileID: 394305455}
--- !u!4 &948598109
Transform:
m_ObjectHideFlags: 0
......@@ -2246,8 +2247,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 77}
m_SizeDelta: {x: 700, y: 100}
m_AnchoredPosition: {x: 0, y: 45.09999}
m_SizeDelta: {x: 700, y: 36.2}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1038287939
MonoBehaviour:
......
......@@ -20,7 +20,9 @@ public class PathRenderer : MonoBehaviour
[SerializeField]
BackgroundMovement background;
[SerializeField]
LogScaleSlider velocityslider;
LogScaleSlider velocityslider;
[SerializeField]
UIManager ui;
LineRenderer _pathRenderer;
float _originalPathColliderY;
......@@ -51,21 +53,22 @@ public class PathRenderer : MonoBehaviour
{
if (Input.GetMouseButtonDown(1) && levelManager.player.isInertial())
{
RaycastHit hit;
RaycastHit hit1;
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit))
if (Physics.Raycast(ray, out hit1))
{
ray = playercamera.ViewportPointToRay(hit.textureCoord);
if (Physics.Raycast(ray, out hit))
RaycastHit hit2;
ray = playercamera.ViewportPointToRay(hit1.textureCoord);
if (Physics.Raycast(ray, out hit2))
{
if (Input.GetKey(KeyCode.LeftShift))
{
_DrawMorePath(hit.point);
_DrawMorePath(hit2.point, hit1);
}
else
{
_DrawOnePath(hit.point);
_DrawOnePath(hit2.point, hit1);
}
}
}
......@@ -83,7 +86,7 @@ public class PathRenderer : MonoBehaviour
}
}
private void _DrawOnePath(Vector3 point)
private void _DrawOnePath(Vector3 point, RaycastHit hit)
{
_ResetPaths();
square.pathList[0] = transform.localPosition;
......@@ -94,6 +97,7 @@ public class PathRenderer : MonoBehaviour
_pathRenderer.positionCount = square.pathList.Count();
_pathRenderer.SetPositions(square.pathList.ToArray());
_InstantiatePathCollider(0);
ui.PopupLastPathUI(_pathRenderer.positionCount - 2, hit);
}
private void _ResetPaths()
......@@ -110,11 +114,11 @@ public class PathRenderer : MonoBehaviour
}
}
private void _DrawMorePath(Vector3 point)
private void _DrawMorePath(Vector3 point, RaycastHit hit)
{
if (square.pathList.Count == 0)
{
_DrawOnePath(point);
_DrawOnePath(point, hit);
}
else
{
......@@ -124,6 +128,7 @@ public class PathRenderer : MonoBehaviour
_pathRenderer.positionCount = square.pathList.Count();
_pathRenderer.SetPositions(square.pathList.ToArray());
_InstantiatePathCollider(square.pathList.Count() - 2);
ui.PopupLastPathUI(_pathRenderer.positionCount - 2, hit);
}
}
......
......@@ -107,8 +107,6 @@ public class UIManager : MonoBehaviour
}
else if (Input.GetMouseButtonDown(1))
{
_pathUI.SetActive(false);
prevSelectPathNum = -1;
sliderflag = 0;
}
......@@ -162,6 +160,7 @@ public class UIManager : MonoBehaviour
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;
......@@ -180,9 +179,9 @@ public class UIManager : MonoBehaviour
return new Vector3(v.x, v.z, 0.0f);
}
private void updatePathInfo(GameObject obj, int pathNum)
private void updatePathInfo(int pathNum)
{
pathName.text = obj.name;
pathName.text = "Path - " + pathNum;
pathVelocity.text = "Velocity: " + square.GetPathVelocity(pathNum).ToString() + "c";
velocityslider.UpdateValuebyVelocity(square.GetPathVelocity(pathNum));
}
......@@ -207,7 +206,7 @@ public class UIManager : MonoBehaviour
if (pathNum != prevSelectPathNum)
{
prevSelectPathNum = pathNum;
updatePathInfo(obj, pathNum);
updatePathInfo(pathNum);
var mouseClickPosition = getMouseClickPosition(hit1);
var v = getDestVector(getVectorFromAtoB(middlePoint, mouseClickPosition), getVectorFromAtoB(player.transform.position, hit2.point));
......@@ -233,6 +232,9 @@ public class UIManager : MonoBehaviour
{
pathRenderer.Background.Toggle = false;
StartCoroutine(pathRenderer._StartMovingPath(prevSelectPathNum));
_pathUI.SetActive(false);
prevSelectPathNum = -1;
pathRenderer.PathClear();
}
......@@ -278,4 +280,14 @@ public class UIManager : MonoBehaviour
interactText.text = value;
}
}
public void PopupLastPathUI(int pathNum, RaycastHit hit)
{
prevSelectPathNum = pathNum;
updatePathInfo(pathNum);
var mouseClickPosition = getMouseClickPosition(hit);
_pathUI.transform.position = mouseClickPosition;
Debug.Log(pathNum + "test");
_pathUI.SetActive(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