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

Double Click complete, trajectory movement WIP

parent ea61a883
......@@ -191,21 +191,36 @@ public class FlatlandMovement : MonoBehaviour
var deltav = V.DenseOfArray(tmp);
if (startv.magnitude > 0.0f)
{
deltav = Constants.BoostMatrix(startv) * deltav;
deltav.Normalize(2);
deltav = deltav * atmp;
var deltavsize = Mathf.Sqrt((float)(deltav[1] * deltav[1] + deltav[2] * deltav[2]));
deltav = atmp / deltavsize * deltav;
deltav[0] = Constants.Gamma(atmp) * Constants.c;
deltav[1] *= Constants.Gamma(atmp);
deltav[2] *= Constants.Gamma(atmp);
deltav = Constants.BoostMatrix(-startv) * deltav;
}
else
{
var deltavsize = Mathf.Sqrt((float)(deltav[1] * deltav[1] + deltav[2] * deltav[2]));
deltav = atmp / deltavsize * deltav;
deltav[0] = Constants.Gamma(atmp) * Constants.c;
deltav[1] *= Constants.Gamma(atmp);
deltav[2] *= Constants.Gamma(atmp);
}
var tt = deltav[0] / Constants.c;
Vector3 finaldeltav = new Vector3((float)(deltav[1] / tt), 0.0f, (float)(deltav[2] / tt));
levelManager.player.v = finaldeltav;*/
levelManager.player.v = finaldeltav;
}
......
......@@ -200,16 +200,21 @@ public class PathRenderer : MonoBehaviour
while (i <= finalPathNum)
{
Vector3 acceleration = new Vector3(square.GetNthPath(i).x,0f, square.GetNthPath(i).y);
Vector3 acceleration = new Vector3(square.GetNthPath(i).x, 0f, square.GetNthPath(i).y);
acceleration.Normalize();
var offsetstartpos = Background.transform.position;
var startpos = levelManager.player.transform.position;
acceleration = acceleration.normalized;
var deltat = Time.fixedDeltaTime * tinterval;
var v = square.GetPathVelocity(i) * Constants.c;
var v = square.GetPathVelocity(i);
acceleration = (float)((Constants.c / deltat) * MathNet.Numerics.Trig.Asinh(v * Constants.Gamma(v * Constants.c))) * acceleration;
// acceleration required to accelerate to v in deltat seconds: see https://en.wikiversity.org/wiki/Theory_of_relativity/Rindler_coordinates
acceleration = (float)(v * Constants.Gamma(v) / deltat) * acceleration;
var startv = levelManager.player.v;
levelManager.player.alpha = acceleration;
......@@ -217,13 +222,33 @@ public class PathRenderer : MonoBehaviour
{
yield return new WaitForFixedUpdate();
}
levelManager.player.alpha = new Vector3(0, 0, 0);
var offsetnewpos = Background.transform.position;
var newpos = levelManager.player.transform.position;
var posdiff = newpos - startpos;
var offset = offsetnewpos - offsetstartpos;
posdiff = posdiff - offset;
while(true)
{
var tmp = (square.GetDestPoint(i) + Background.transform.position - levelManager.player.transform.position);
if ((posdiff - tmp).magnitude < 0.01f)
break;
yield return new WaitForFixedUpdate();
}
acceleration = -acceleration;
for (var j = 0; j < 1000; ++j)
levelManager.player.alpha = acceleration;
for (var j = 0; j < tinterval; ++j)
{
yield return new WaitForFixedUpdate();
}
levelManager.player.alpha = new Vector3(0, 0, 0);
Background.Toggle = true;
......@@ -231,6 +256,9 @@ public class PathRenderer : MonoBehaviour
i++;
}
}
public void DeletePathsAfterNthPath(int n)
{
square.pathList.RemoveRange(n, _pathRenderer.positionCount - n);
......
......@@ -226,26 +226,6 @@ public class UIManager : MonoBehaviour
StartCoroutine(pathRenderer._StartMovingPath(prevSelectPathNum));
}
bool result;
var positions = pathRenderer.PathPositionsXZ;
var velocitys = pathRenderer.PathVelocitys;
if (positions.Count <= 1 || velocitys.Count <= 1)
{
return;
}
// remove dummy
positions.RemoveAt(0);
velocitys.RemoveAt(0);
result = levelManager.player.MoveToRetivePosition(positions, velocitys);
if (result)
{
pathRenderer.PathClear();
}
}
public void PathCancel()
{
......
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