Commit 11bd04a9 authored by Chae Ho Shin's avatar Chae Ho Shin

Merge remote-tracking branch 'origin/model-ui-integration-work' into model-ui-integration-work

# Conflicts:
#	Assets/Scripts/UIManager.cs
parents 27c0b9cc 64a65eca
...@@ -7,6 +7,7 @@ public class DoubleClick : MonoBehaviour ...@@ -7,6 +7,7 @@ public class DoubleClick : MonoBehaviour
private bool click = true; //클릭 여부 private bool click = true; //클릭 여부
[SerializeField]
private float clickWaitTime = 0.5f; //클릭 대기시간 private float clickWaitTime = 0.5f; //클릭 대기시간
private float clickTime; private float clickTime;
......
...@@ -829,7 +829,7 @@ GameObject: ...@@ -829,7 +829,7 @@ GameObject:
- component: {fileID: 502908128} - component: {fileID: 502908128}
m_Layer: 5 m_Layer: 5
m_Name: DoubleClickPanel m_Name: DoubleClickPanel
m_TagString: Untagged m_TagString: panel
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
......
...@@ -142,32 +142,42 @@ public class FlatlandMovement : MonoBehaviour ...@@ -142,32 +142,42 @@ public class FlatlandMovement : MonoBehaviour
/// </summary> /// </summary>
/// <param name="path">목적지 x z 가 공간</param> /// <param name="path">목적지 x z 가 공간</param>
/// <param name="v">속력 0<v<1</param> /// <param name="v">속력 0<v<1</param>
public bool MoveTo(Vector3 dest, float v) public bool MoveToAbPosition(Vector3 dest, float v)
{ {
dest.y = 0; bool result = SetVelecityToAbPosition(dest, v);
Debug.Log("bb"); if (!result)
Debug.Log(dest);
if (v < 0.0001f)
{ {
//v가 0일때.
return false; return false;
} }
nowDest = dest;
isAutoMove = true;
return true;
}
/// <summary>
/// 절대좌표 방향으로 무한히 날아갑니다
/// </summary>
/// <param name="dest"></param>
/// <param name="v"></param>
/// <returns></returns>
public bool MoveInfinitelyToAbPosition(Vector3 dest, float v)
{
return SetVelecityToAbPosition(dest,v);
}
public bool SetVelecityToAbPosition(Vector3 dest, float v)
{
dest.y = 0;
//속도와 목적지 설정. //속도와 목적지 설정.
Vector3 tmp = dest-transform.position; Vector3 tmp = dest - transform.position;
Debug.Log("move vector: " + tmp);
tmp.y = 0; tmp.y = 0;
this.v = tmp.normalized * v * (float)Constants.c; this.v = tmp.normalized * v * (float)Constants.c;
Debug.Log("v : "+ this.v);
this.nowDest = dest;
isAutoMove = true;
return true; return true;
} }
private void NextMove() private void NextMove()
{ {
MoveTo(dests[0], pathVelocitys[0]); MoveToAbPosition(dests[0], pathVelocitys[0]);
dests.RemoveAt(0); dests.RemoveAt(0);
pathVelocitys.RemoveAt(0); pathVelocitys.RemoveAt(0);
......
...@@ -68,22 +68,29 @@ public class UIManager : MonoBehaviour ...@@ -68,22 +68,29 @@ public class UIManager : MonoBehaviour
ped.position = Input.mousePosition; ped.position = Input.mousePosition;
List<RaycastResult> results = new List<RaycastResult>(); List<RaycastResult> results = new List<RaycastResult>();
gr.Raycast(ped, results); gr.Raycast(ped, results);
if (results.Count != 0)
{
GameObject obj = results[0].gameObject;
if(obj.tag == "VelocitySlider") bool isIgnored = true;
//ui 클릭시.
foreach (RaycastResult re in results)
{
GameObject obj = re.gameObject;
//panel만 있는지 검사.
isIgnored &= (obj.tag == "ignored");
//Debug.Log(obj);
//슬라이더일때
if (obj.tag == "VelocitySlider")
{ {
sliderflag = 1; sliderflag = 1;
if (_pathUI.activeSelf == true && prevSelectPathNum != -1) if (_pathUI.activeSelf == true && prevSelectPathNum != -1)
{ {
square.pathVelocity[prevSelectPathNum + 1] = velocityslider.GetLogScaleValue(); square.pathVelocity[prevSelectPathNum + 1] = velocityslider.GetLogScaleValue();
pathVelocity.text = "Velocity: " + square.GetPathVelocity(prevSelectPathNum).ToString() + "c"; pathVelocity.text = "Velocity: " + square.GetPathVelocity(prevSelectPathNum).ToString() + "c";
break;
} }
} }
} }
else if (isIgnored)
{ {
RaycastHit hit1; RaycastHit hit1;
RaycastHit hit2; RaycastHit hit2;
...@@ -121,6 +128,8 @@ public class UIManager : MonoBehaviour ...@@ -121,6 +128,8 @@ public class UIManager : MonoBehaviour
} }
} }
} }
//클릭된 ui가 패널만 있을때.
TryFIndPath();
} }
} }
else if(sliderflag == 1 && Input.GetMouseButton(0)) else if(sliderflag == 1 && Input.GetMouseButton(0))
...@@ -202,6 +211,52 @@ public class UIManager : MonoBehaviour ...@@ -202,6 +211,52 @@ public class UIManager : MonoBehaviour
velocityslider.UpdateValuebyVelocity(square.GetPathVelocity(pathNum)); velocityslider.UpdateValuebyVelocity(square.GetPathVelocity(pathNum));
} }
private void TryFIndPath()
{
RaycastHit hit1;
RaycastHit hit2;
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit1))
{
ray = playercamera.ViewportPointToRay(hit1.textureCoord);
if (Physics.Raycast(ray, out hit2))
{
var obj = hit2.collider.gameObject;
Debug.Log(obj.tag);
if (obj.tag == "path")
{
int pathNum = int.Parse(obj.name.Substring(13));
if (pathNum != prevSelectPathNum)
{
updatePathInfo(obj, pathNum);
var mouseClickPosition = getMouseClickPosition(hit1);
var v = getDestVector(mouseClickPosition - middlePoint, new Vector3(hit2.point.x, hit2.point.z, 0.0f), pathNum);
_pathUI.transform.position = mouseClickPosition + v;
_pathUI.SetActive(true);
prevSelectPathNum = pathNum;
}
else
{
_pathUI.SetActive(false);
prevSelectPathNum = -1;
sliderflag = 0;
}
}
else
{
_pathUI.SetActive(false);
prevSelectPathNum = -1;
sliderflag = 0;
}
}
}
}
/// <summary> /// <summary>
/// 현재 지정된 path를 시작합니다. /// 현재 지정된 path를 시작합니다.
/// </summary> /// </summary>
...@@ -227,7 +282,8 @@ public class UIManager : MonoBehaviour ...@@ -227,7 +282,8 @@ public class UIManager : MonoBehaviour
ray = playercamera.ViewportPointToRay(hit.textureCoord); ray = playercamera.ViewportPointToRay(hit.textureCoord);
if (Physics.Raycast(ray, out hit)) if (Physics.Raycast(ray, out hit))
{ {
levelManager.player.MoveTo(hit.point, velocityslider.GetLogScaleValue()); levelManager.player.MoveInfinitelyToAbPosition(hit.point, velocityslider.GetLogScaleValue());
//levelManager.player.MoveToAbPosition(hit.point, velocityslider.GetLogScaleValue());
//Debug.Log(velocityslider.GetLogScaleValue() * (float)Constants.c); //Debug.Log(velocityslider.GetLogScaleValue() * (float)Constants.c);
//Debug.Log(hit.point); //Debug.Log(hit.point);
} }
......
...@@ -7,6 +7,8 @@ TagManager: ...@@ -7,6 +7,8 @@ TagManager:
- path - path
- pathui - pathui
- VelocitySlider - VelocitySlider
- doubleclick
- panel
layers: layers:
- Default - Default
- TransparentFX - TransparentFX
......
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