コード例 #1
0
        public static PodRacerRaceState CreateInterpolation(PodRacerRaceState a, PodRacerRaceState b, double fraction)
        {
            PodRacerRaceState interpolation;

            interpolation = a.Copy();

            Vector positionA            = a.PodRacer.Position;
            Vector positionB            = b.PodRacer.Position;
            Vector interpolatedPosition = positionA + (positionB - positionA) * fraction;

            double headingA    = a.PodRacer.Heading;
            double headingB    = b.PodRacer.Heading;
            double headingDiff = headingB - headingA;

            if (headingDiff < -180)
            {
                headingDiff += 360;
            }
            if (headingDiff > 180)
            {
                headingDiff -= 360;
            }
            double interpolatedHeading = headingA + headingDiff * fraction;

            interpolation.PodRacer.Position = interpolatedPosition;
            interpolation.PodRacer.Heading  = interpolatedHeading;

            return(interpolation);
        }
コード例 #2
0
        private void HandlePodRacerHitCheckpoint(PodRacer podRacer, CheckPoint checkPoint)
        {
            PodRacerRaceState podRacerRaceState = raceState.PodRacerRaceStates[podRacer];
            Team          team          = podRacer.Owner;
            TeamRaceState teamRaceState = raceState.TeamRaceStates[team];
            CheckPoint    nextCheckPoint;

            if (podRacerRaceState.CurrentCheckPoint == checkPoint)
            {
                podRacerRaceState.CheckPointsReached++;

                teamRaceState.Timeout = raceRules.TIMEOUT + 1;

                if (checkPoint == arena.GetStartFinish())
                {
                    podRacerRaceState.RoundsFinished++;

                    if (raceResult.WinningTeam == null)
                    {
                        if (podRacerRaceState.RoundsFinished == raceRules.RACE_LENGTH)
                        {
                            raceResult.WinningTeam     = team;
                            raceState.Finished         = true;
                            teamRaceState.FinishedRace = true;
                        }
                    }
                }

                nextCheckPoint = arena.GetNextCheckPoint(checkPoint);
                podRacerRaceState.CurrentCheckPoint = nextCheckPoint;
            }
        }
コード例 #3
0
        private void FinalizeRoundForPodRacer(PodRacer podRacer, PodRacerRaceState podRacerRaceState)
        {
            podRacer.ConvertStateToInt();

            if (podRacerRaceState.ShieldPenaltyRoundsCounter > 0)
            {
                podRacerRaceState.ShieldPenaltyRoundsCounter--;
            }
        }
コード例 #4
0
        public PodRacerRaceState Copy()
        {
            PodRacerRaceState copy;

            copy = new PodRacerRaceState(PodRacer.Copy())
            {
                CurrentCommand             = CurrentCommand.Copy(),
                ShieldPenaltyRoundsCounter = ShieldPenaltyRoundsCounter,
                HasBoosted         = HasBoosted,
                Failed             = Failed,
                CurrentCheckPoint  = CurrentCheckPoint.Copy(),
                RoundsFinished     = RoundsFinished,
                CheckPointsReached = CheckPointsReached
            };

            return(copy);
        }
コード例 #5
0
        public static RaceState CreateInterpolation(RaceState a, RaceState b, double time)
        {
            RaceState interpolation;

            interpolation = a.Copy();

            interpolation.Time = time;

            List <PodRacer> keys;

            keys = interpolation.PodRacerRaceStates.Keys.ToList();

            foreach (var podRacerRaceStateKeys in keys)
            {
                interpolation.PodRacerRaceStates[podRacerRaceStateKeys] = PodRacerRaceState.CreateInterpolation(a.PodRacerRaceStates[podRacerRaceStateKeys], b.PodRacerRaceStates[podRacerRaceStateKeys], (time - a.Time) / (b.Time - a.Time));
            }

            return(interpolation);
        }