Пример #1
0
        private double CalculateScoreForPodRacer(PodRacer podRacer)
        {
            double score = 0;

            int checkPointsCount = race.Arena.CheckPoints.Count;

            PodRacerRaceState podRacerRaceState = race.RaceState.PodRacerRaceStates[podRacer];

            score += podRacerRaceState.CheckPointsReached * 10000;

            Vector vectorToCurrentCheckPoint = podRacer.Position - podRacerRaceState.CurrentCheckPoint.Position;

            score += 10000 - Math.Min(vectorToCurrentCheckPoint.Length, 10000);

            if (podRacerRaceState.RoundsFinished == 3)
            {
                score += (checkPointsCount * 3 * 100 - race.RaceState.Round) * 10000;
            }

            return(score);
        }
Пример #2
0
        protected void PaintPodRacer(Graphics g, PodRacer podRacer)
        {
            Pen p = new Pen(podRacer.Owner.Color, 1);

            AdjustableArrowCap bigArrow = new AdjustableArrowCap(5, 5);

            p.CustomEndCap = bigArrow;

            DrawCircle(podRacer.Position, podRacer.Size, g, p);

            if (podRacer.Velocity.LengthSquared > 0)
            {
                p.Color = Color.Blue;
                //DrawVector(podRacer.Position, podRacer.Velocity.CreateNormalizedVector() * 1600, p);
                DrawVector(podRacer.Position, podRacer.Velocity * 4, p);
            }

            p.Color = Color.Red;
            DrawVector(podRacer.Position, podRacer.Orientation * 1200, p);

            p.Color = Color.Black;
            DrawString(podRacer.Position, podRacer.Number.ToString());
        }
Пример #3
0
        protected void PaintDestination(Graphics g, PodRacer podRacer, Vector destination)
        {
            Pen p = new Pen(Color.Green, 1);

            DrawVector(podRacer.Position, destination - podRacer.Position, p);
        }
Пример #4
0
        protected void InitGame()
        {
            game = new Game(GameRules.Instance);

            List <Vector> checkPointPositions = new List <Vector>()
            {
                /* 16000x9000 */
                new Vector(3000, 3000),
                new Vector(10000, 1000),
                new Vector(10000 - 1201, 1000),
                new Vector(10000, 6000),
                new Vector(5000, 6000),
            };

            //List<Vector> checkPointPositions = new List<Vector>()
            //{
            //    /* 16000x9000 */
            //    new Vector(1000, 5000),
            //    new Vector(4000, 8000),
            //    new Vector(8000, 8000),
            //    new Vector(11000, 5000),
            //    new Vector(5000, 1000),
            //};

            int checkPointIndex = 0;

            foreach (var checkPointPosition in checkPointPositions)
            {
                game.CreateCheckPoint(checkPointIndex, checkPointPosition);
                checkPointIndex++;
            }

            List <Team> players = new List <Team>();

            teamA = game.CreateTeam("A", Color.Red);
            players.Add(teamA);
            //teamB = game.CreateTeam("B", Color.Green);
            //players.Add(teamB);

            PodRacer podRacerA = null;
            //PodRacer podRacerB = null;
            List <PodRacer> podRacersForPlayer;

            podRacersForPlayer = new List <PodRacer>();
            podRacerA          = game.CreatePodRacer(
                teamA,
                0,
                new PilotC(bestNn),
                new Vector(
                    5000,
                    1000
                    ),
                90
                );
            //podRacerB = game.CreatePodRacer(
            //    teamA,
            //    1,
            //    new PilotC(),
            //    new Vector(
            //        5000,
            //        9000
            //    ),
            //        270
            //        );

            podRacersForPlayer.Add(podRacerA);
            //podRacersForPlayer.Add(podRacerB);
            podRacers.Add(teamA, podRacersForPlayer);

            //podRacersForPlayer = new List<PodRacer>();
            //podRacerA = game.CreatePodRacer(
            //    teamB,
            //    2,
            //    new PilotB(),
            //    new Vector(
            //        9000,
            //        5000
            //    ),
            //        180
            //        );
            //podRacerB = game.CreatePodRacer(
            //    teamB,
            //    3,
            //    new PilotC(),
            //    new Vector(
            //        1000,
            //        5000
            //    ),
            //        0
            //        );

            //podRacersForPlayer.Add(podRacerA);
            //podRacersForPlayer.Add(podRacerB);
            //podRacers.Add(teamB, podRacersForPlayer);

            race = game.CreateRace(0);

            //Dictionary<Team, TeamRaceState> teamGameStates = race.RaceState.TeamGameStates;

            //Dictionary<PodRacer, PodRacerRaceState> podRacerGameStates = race.RaceState.PodRacerRaceStates;

            //podRacerGameStates[podRacers[teamA][0]].CurrentCommand = new PodRacerCommand() { Thrust = 100, Destination = podRacerGameStates[podRacers[teamA][0]].CurrentCheckPoint.Position };
            //podRacerGameStates[podRacers[teamA][1]].CurrentCommand = new PodRacerCommand() { Thrust = 100, Destination = podRacerGameStates[podRacers[teamA][1]].CurrentCheckPoint.Position };
            //podRacerGameStates[podRacers[teamB][0]].CurrentCommand = new PodRacerCommand() { Thrust = 100, Destination = podRacerGameStates[podRacers[teamB][0]].CurrentCheckPoint.Position };
            //podRacerGameStates[podRacers[teamB][1]].CurrentCommand = new PodRacerCommand() { Thrust = 100, Destination = podRacerGameStates[podRacers[teamB][1]].CurrentCheckPoint.Position };
        }