Commit dc0f56af authored by Chae Ho Shin's avatar Chae Ho Shin

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

parents 11bd04a9 254602be
...@@ -30,15 +30,17 @@ public class FlatlandMovement : MonoBehaviour ...@@ -30,15 +30,17 @@ public class FlatlandMovement : MonoBehaviour
// 마우스로 이동할때 하용하는 변수들. // 마우스로 이동할때 하용하는 변수들.
bool isAutoMove = false; bool isAutoMove = false;
bool isPatrol = false;
Vector3 nowDest; Vector3 nowDest;
/// <summary> /// <summary>
/// 앞으로 남은 목적지들. /// 앞으로 남은 목적지들.
/// </summary> /// </summary>
List<Vector3> dests = new List<Vector3>(); Queue<Vector3> dests = new Queue<Vector3>();
/// <summary> /// <summary>
/// 앞으로 남은 목적지 속력 /// 앞으로 남은 목적지 속력
/// </summary> /// </summary>
List<float> pathVelocitys = new List<float>(); Queue<float> pathVelocitys = new Queue<float>();
protected void FixedUpdate() protected void FixedUpdate()
{ {
...@@ -110,33 +112,22 @@ public class FlatlandMovement : MonoBehaviour ...@@ -110,33 +112,22 @@ public class FlatlandMovement : MonoBehaviour
/// </summary> /// </summary>
/// <param name="path">상대좌표 x z 가 공간</param> /// <param name="path">상대좌표 x z 가 공간</param>
/// <param name="v"> 경로별 속력 0번은 0.0f </param> /// <param name="v"> 경로별 속력 0번은 0.0f </param>
public bool MoveToRetivePosition(List<Vector3> path, List<float> v) /// <param isPatrol="isPatrol"> 왔다갔다 여부 </param>
public bool MoveToRetivePosition(List<Vector3> path, List<float> v,bool isPatrol = true)
{ {
//Debug.Log("aa"); if(!SetDestsAndVelecitysAsRelPositions(path, v))
foreach(float a in v)
{
if (a <= 0.0001f)
{
return false;
}
}
if (path.Count >= 1)
{ {
dests = new List<Vector3>(); return false;
//상대좌표 -> 절대좌표
foreach(var a in path)
{
dests.Add(new Vector3(transform.position.x + a.x, 0, transform.position.z + a.z));
}
pathVelocitys = new List<float>(v);
} }
// patrol
this.isPatrol = isPatrol;
//start move //start move
NextMove(); NextMove();
return true; return true;
} }
/// <summary> /// <summary>
/// 목적지로 바로 이동합니다. /// 목적지로 바로 이동합니다.
/// </summary> /// </summary>
...@@ -161,6 +152,8 @@ public class FlatlandMovement : MonoBehaviour ...@@ -161,6 +152,8 @@ public class FlatlandMovement : MonoBehaviour
/// <returns></returns> /// <returns></returns>
public bool MoveInfinitelyToAbPosition(Vector3 dest, float v) public bool MoveInfinitelyToAbPosition(Vector3 dest, float v)
{ {
isAutoMove = false;
isPatrol = true;
return SetVelecityToAbPosition(dest,v); return SetVelecityToAbPosition(dest,v);
} }
...@@ -174,13 +167,41 @@ public class FlatlandMovement : MonoBehaviour ...@@ -174,13 +167,41 @@ public class FlatlandMovement : MonoBehaviour
return true; return true;
} }
private void NextMove() private bool SetDestsAndVelecitysAsRelPositions(List<Vector3> path, List<float> v)
{ {
//Debug.Log("aa");
foreach (float a in v)
{
if (a <= 0.0001f)
{
return false;
}
}
if (path.Count >= 1)
{
dests = new Queue<Vector3>();
//상대좌표 -> 절대좌표
foreach (var a in path)
{
dests.Enqueue(new Vector3(transform.position.x + a.x, 0, transform.position.z + a.z));
}
MoveToAbPosition(dests[0], pathVelocitys[0]); pathVelocitys = new Queue<float>(v);
}
dests.RemoveAt(0); return true;
pathVelocitys.RemoveAt(0); }
private void NextMove()
{
Debug.Log("a"+dests.Count);
var dest = dests.Dequeue();
var vel = pathVelocitys.Dequeue();
MoveToAbPosition(dest, vel);
Debug.Log("b"+dests.Count);
if (isPatrol)
{
dests.Enqueue(dest);
pathVelocitys.Enqueue(vel);
}
} }
} }
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