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

Merge branch 'ui' into collision-model

parents 08c6c35c 748a100c
......@@ -205,10 +205,15 @@ public class PathRenderer : MonoBehaviour
int tinterval = Constants.alphatinterval;
VectorBuilder<double> V = Vector<double>.Build;
//square.PathList에서 0에서 시작해 finalPathNum까지 이동
var startPosition = levelManager.player.transform.position;
Debug.Log(startPosition + "test");
while (i <= finalPathNum)
{
Vector3 startpos = new Vector3(levelManager.player.transform.position.x, 0, levelManager.player.transform.position.z);
Vector3 dest = new Vector3(square.GetNthPath(i).x, 0f, square.GetNthPath(i).y);
Vector3 startpos = new Vector3(levelManager.player.transform.position.x, 0, levelManager.player.transform.position.z); // 경로 이동 시작할때 위치
Vector3 dest = new Vector3(square.GetNthPath(i).x, 0f, square.GetNthPath(i).y); // 시작 관성계 기준 startpos에서 목표지점까지 공간 좌표
Vector3 acceleration = dest.normalized;
var v = square.GetPathVelocity(i);
......@@ -230,8 +235,8 @@ public class PathRenderer : MonoBehaviour
if (u.magnitude > 0.0f)
{
deltav = Constants.BoostMatrix(-u) * deltav;
deltax = Constants.BoostMatrix(-u) * deltaxnaive;
deltav = Constants.BoostMatrix(-u) * deltav; // 로렌츠 행렬을 곱해서 경로 이동시 속도가 월드 관성계에서 무슨 속도인지 구함(deltav)
deltax = Constants.BoostMatrix(-u) * deltaxnaive; // 로렌츠 행렬을 곱해서 경로 이동시 위치 변화가 월드 관성계에서 얼마나 되는지 구함(deltax)
}
var tt = deltav[0] / Constants.c;
......@@ -239,7 +244,7 @@ public class PathRenderer : MonoBehaviour
Vector3 finaldeltav = new Vector3((float)(deltav[1] / tt), 0.0f, (float)(deltav[2] / tt));
Vector3 finaldeltax = new Vector3((float)deltax[1], 0.0f, (float)deltax[2]);
levelManager.player.v = finaldeltav;
levelManager.player.v = finaldeltav; // 플레이어 월드 관성계 기준 속도를 deltav로 세팅
while (true)
{
......@@ -253,28 +258,67 @@ public class PathRenderer : MonoBehaviour
}
levelManager.player.v = u;
levelManager.player.v = u; // 원래 관성계로 돌아옴
levelManager.player.transform.position = new Vector3(startpos.x + finaldeltax.x
, levelManager.player.transform.position.y
, startpos.z + finaldeltax.z);
, startpos.z + finaldeltax.z); // 위치 보정해줌(fixed update오차)
// INSERT CODE TO REMOVE PATH FROM PATH RENDERER HERE
// 여기에 방금 이동한 경로를 안보이게 해야 함
HideNthPath(i);
i++;
}
Debug.Log(levelManager.player.transform.position + "test");
shiftPath(finalPathNum + 1, levelManager.player.transform.position - startPosition);
Background.Toggle = true;
//아마 여기에 이동을 다 마친 경로들을 square.pathList랑 square.pathVelocity에서 없애주고, finalPathNum 다음 경로가 square.pathList[1]이 되게 해야할듯
// PathRenderer에 child로 되 있는 Path-n들 이름도 다 바꿔줘야 할꺼임(니가 최종 경로 가 몇번째인지 판정으로 GameObject 이름을 string으로 받아와서 하니까)
// 귀찮으면 아예 UIManager.cs에서 int pathNum = int.Parse(obj.name.Substring(13)); 이부분을 바꿔도 됨.
}
public void DeletePathsAfterNthPath(int n)
{
square.pathList.RemoveRange(n, _pathRenderer.positionCount - n);
square.pathVelocity.RemoveRange(n, _pathRenderer.positionCount - n);
for (int i = 0; i < transform.childCount; i++)
for (int i = n - 1; i < transform.childCount; i++)
{
if (i + 1 >= n) Destroy(transform.GetChild(i).gameObject);
Destroy(transform.GetChild(i).gameObject);
}
_pathRenderer.positionCount = square.pathList.Count();
}
public void HideNthPath(int n)
{
transform.GetChild(n).gameObject.GetComponent<MeshRenderer>().enabled=false;
}
public void shiftPath(int times, Vector3 deltaPosition)
{
square.pathList.RemoveRange(1, times);
square.pathVelocity.RemoveRange(1, times);
deltaPosition = ui.getXYVectorfromXZVector(deltaPosition);
Debug.Log(deltaPosition + "test");
int i;
for (i = 0; i < times; i++)
{
Destroy(transform.GetChild(i).gameObject);
}
for (i = 0; i < transform.childCount - times; i++)
{
GameObject obj = transform.GetChild(i + times).gameObject;
obj.name = "PathCollider-" + i;
obj.transform.localPosition -= deltaPosition;
square.pathList[i + 1] -= deltaPosition;
}
_pathRenderer.positionCount = square.pathList.Count();
_pathRenderer.SetPositions(square.pathList.ToArray());
}
}
......@@ -174,7 +174,7 @@ public class UIManager : MonoBehaviour
return ret;
}
private Vector3 getXYVectorfromXZVector(Vector3 v)
public Vector3 getXYVectorfromXZVector(Vector3 v)
{
return new Vector3(v.x, v.z, 0.0f);
}
......@@ -230,11 +230,10 @@ public class UIManager : MonoBehaviour
/// </summary>
public void PathStart()
{
_pathUI.SetActive(false);
pathRenderer.Background.Toggle = false;
StartCoroutine(pathRenderer._StartMovingPath(prevSelectPathNum));
_pathUI.SetActive(false);
prevSelectPathNum = -1;
pathRenderer.PathClear();
}
......@@ -287,7 +286,6 @@ public class UIManager : MonoBehaviour
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