예제 #1
0
    private void InitialiseCheckpointsIntoReplay()
    {
        // SUPER EXPENSIVE!! THIS SHOULD BE BAKED DURING BUILDING, NOT RAN EVERY PLAY :(
        if (replaySnapshots == null)
        {
            return;
        }

        int index = 0;
        List <Checkpoint> checkpoints    = GameObject.FindObjectsOfType <Checkpoint>().ToList();
        float             minSqrDistance = float.PositiveInfinity;

        for (int i = 0; i != replaySnapshots.Count; i++)
        {
            Recorder.Snapshot snapshot = replaySnapshots[i];
            float             currentMinSqrDistance = float.PositiveInfinity;
            Checkpoint        nearestCheckpoint     = null;
            foreach (Checkpoint checkpoint in checkpoints)
            {
                float sqrDistance = (checkpoint.spawn.transform.position - snapshot.position).sqrMagnitude;
                if (sqrDistance < currentMinSqrDistance)
                {
                    nearestCheckpoint     = checkpoint;
                    currentMinSqrDistance = sqrDistance;
                }
            }
            if (currentMinSqrDistance > minSqrDistance)
            {
                nearestCheckpoint.Index         = index;
                nearestCheckpoint.SnapshotIndex = i;
                index++;
                checkpoints.Remove(nearestCheckpoint);
                minSqrDistance = float.PositiveInfinity;
            }
            else
            {
                minSqrDistance = currentMinSqrDistance;
            }
            if (!checkpoints.Any())
            {
                break;
            }
        }
    }
예제 #2
0
파일: Playback.cs 프로젝트: yaJaba/momentum
    void moveToNextSnapshot()
    {
        currentSnapshot  = Snapshots[snapshotIndex];
        previousSnapshot = null;
        nextSnapshot     = null;
        previousVelocity = Vector3.zero;

        if (snapshotIndex > 0)
        {
            previousSnapshot = Snapshots[snapshotIndex - 1];
            previousVelocity = (currentSnapshot.position - previousSnapshot.position);
        }
        if (snapshotIndex + 1 < Snapshots.Count)
        {
            nextSnapshot = Snapshots[snapshotIndex + 1];
            nextVelocity = (nextSnapshot.position - currentSnapshot.position);
        }
        snapshotIndex++;
    }
예제 #3
0
파일: Playback.cs 프로젝트: yaJaba/momentum
 public void StopPlayback()
 {
     playback        = false;
     snapshotIndex   = 0;
     currentSnapshot = null;
 }