Exemple #1
0
        // Runs after all GameObjects have been created in a room. It will complete the creation of all tracks, including their calculated fields.
        private void BuildTrackCalculations()
        {
            // Loop through every track.
            foreach (var trackMatch in this.tracks)
            {
                Track track = trackMatch.Value;

                // Identify Destination Track (if applicable).
                if (track.toId != 0)
                {
                    // If unavailable, nullify this track's behavior.
                    if (!this.tracks.ContainsKey(track.toId))
                    {
                        track.toId = 0;
                        continue;
                    }

                    Track destTrack = this.tracks[track.toId];

                    // Calculate distance, rotation, and speed of the track's movement.
                    track.distance = TrigCalc.GetDistance(track.posX, track.posY, destTrack.posX, destTrack.posY);
                    track.rotation = Radians.GetRadiansBetweenCoords(track.posX, track.posY, destTrack.posX, destTrack.posY);
                    track.speed    = FInt.Create((float)(track.distance / track.duration));
                }
            }
        }
Exemple #2
0
        public void CutToPosition(int posX, int posY)
        {
            // If the Camera is at (0, 0), it may be possible to attempt a smooth follow here.
            // We use this so that when the level initially starts, it tries to follow Character.
            if (this.posX == 0 && this.posY == 0)
            {
                // Calculate the distance between the two positions.
                int dist = TrigCalc.GetDistance(this.posX, this.posY, posX, posY);

                // If the positions are less than 1800 pixels apart, do a follow movement rather than jump.
                if (dist < 1800)
                {
                    this.Follow(posX, posY);
                }
            }

            this.CenterAtPosition(posX, posY);
        }