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

bug fix (Issue #34)

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