Ejemplo n.º 1
0
        public LightCheckpoint NextCheckpoint(LightCheckpoint currentCheckpoint)
        {
            int index = IndexOfCheckpoint(currentCheckpoint);

            if (index == -1)
            {
                return(interpolatedCheckpoints [0]);
            }
            else if (index < interpolatedCheckpoints.Count - 1)
            {
                return(interpolatedCheckpoints [index + 1]);
            }

            // This should never happen!
            return(EndCheckpoint);
        }
Ejemplo n.º 2
0
        public int IndexOfCheckpoint(LightCheckpoint checkpoint)
        {
            if (interpolatedCheckpoints == null)
            {
                return(0);
            }

            for (int i = 0; i < interpolatedCheckpoints.Count; ++i)
            {
                if (interpolatedCheckpoints [i] == checkpoint)
                {
                    return(i);
                }
            }
            return(-1);
        }
Ejemplo n.º 3
0
        static void AddCheckpoints(List <LightCheckpoint> newCheckpoints, LightCheckpoint checkpoint, Vector3 p1, int steps)
        {
            var xDiff = 0f;
            var yDiff = 0f;

            for (var step = 1; step < steps; step++)
            {
                var currentLerp = 1f / steps * step;
                var pos         = Vector3.Lerp(p1, checkpoint.Position, currentLerp);

                xDiff += Random.Range((xDiff >= 0f ? -.1f : -.075f), (xDiff <= 0f ? .1f : .075f));
                yDiff += Random.Range((yDiff >= 0f ? -.1f : -.075f), (yDiff <= 0f ? .1f : .075f));
                pos   += new Vector3(xDiff, Random.Range(-.05f, .05f), yDiff);
                newCheckpoints.Add(new LightCheckpoint(pos));
            }
            newCheckpoints.Add(checkpoint);
        }