private void updateFrameStack()
    {
        GameObject[] ghostTimeBodies = GameObject.FindGameObjectsWithTag("GhostTimeBody");

        List <SinglePoint> pointsList = new List <SinglePoint>();

        foreach (GameObject ghostbody in ghostTimeBodies)
        {
            if (ghostbody.activeSelf)
            {
                int instanceID = ghostbody.GetInstanceID();

                // Check if ghostBody already has a corresponding visible timebody
                if (!visibleTimeBodies.ContainsKey(instanceID))
                {
                    // Create visible time body from ghostbody
                    Transform newBody = createVisibleTimeBody(ghostbody).transform;

                    // Track new timebody in visibleTimeBodies
                    visibleTimeBodies[instanceID] = newBody;
                }

                // Record the position state of the ghostbody
                SinglePoint point = new SinglePoint(ghostbody.transform.position, ghostbody.transform.rotation, instanceID);
                pointsList.Add(point);
            }
        }

        if (pointsList.Count > 0)
        {
            FrameState frameState = new FrameState(pointsList);
            frameStateStack.Add(frameState);
        }
    }
Example #2
0
 public static SinglePoint[] SubArray(this SinglePoint[] points, int start, int length)
 {
     SinglePoint[] p = new SinglePoint[length];
     Array.Copy(points, start, p, 0, length);
     return(p);
 }