コード例 #1
0
        public override void execute(Move move)
        {
            TileDir dirMove = path[offset].DirOut;
            TileDir dirEnd  = path[1 + offset].DirOut;

            MovingCalculator calculator = new MovingCalculator();

            calculator.setupEnvironment(car, game, world);
            calculator.setupMapInfo(dirMove, path[0].Pos, path[1 + offset].Pos);
            calculator.setupDefaultAction(GetWayEnd(path[1 + offset].Pos, TileDir.Zero));

            Vector endDir = new Vector(dirEnd.X, dirEnd.Y);

            calculator.setupAngleReach(endDir);
            calculator.setupPassageLine(GetWayEnd(path[1 + offset].Pos, dirEnd), new Vector(dirMove.X, dirMove.Y), 0.5);
            calculator.setupAdditionalPoints(this.additionalPoints);

            Move needMove = calculator.calculateTurn(endDir);

            if (needMove.IsBrake)
            {
                move.IsBrake = true;
            }
            //move.EnginePower = needMove.EnginePower;
            //move.WheelTurn = needMove.WheelTurn;
        }
コード例 #2
0
        public override void execute(Move move)
        {
            TileDir dirMove = path[offset].DirOut;
            TileDir dirEnd  = path[1 + offset].DirOut;
            TilePos endTile = path[1 + offset].Pos;

            MovingCalculator calculator = new MovingCalculator();

            calculator.setupEnvironment(car, game, world);
            calculator.setupMapInfo(dirMove, path[0].Pos, path[1 + offset].Pos);

            calculator.setupDefaultAction(GetWayEnd(path[1 + offset].Pos, dirEnd.Negative() + dirMove.Negative() * 2));

            Vector endDir = new Vector(dirEnd.X - dirMove.X, dirEnd.Y - dirMove.Y).Normalize();

            calculator.setupAngleReach(endDir);
            calculator.setupPassageLine(GetWayEnd(endTile, dirEnd, 1.0), new Vector(dirEnd.X + dirMove.X, dirEnd.Y + dirMove.Y).Normalize(), 0.75);

            if (0 != offset)
            {
                calculator.setupAdditionalPoints(additionalPoints);
            }

            Dictionary <TilePos, TileDir[]> selfMap = new Dictionary <TilePos, TileDir[]>();

            for (int i = 0; i <= offset; i++)
            {
                if (path[i].DirIn == path[i].DirOut)
                {
                    selfMap.Add(path[i].Pos, new TileDir[2] {
                        dirMove.PerpendicularLeft(), dirMove.PerpendicularRight()
                    });
                }
                else
                {
                    selfMap.Add(path[i].Pos, new TileDir[3] {
                        path[i].DirIn, path[i].DirOut.Negative(), path[i].DirIn.Negative() + path[i].DirOut
                    });
                }
            }
            selfMap.Add(endTile, new TileDir[2] {
                dirEnd.Negative(), dirEnd + dirMove.Negative()
            });

            calculator.setupSelfMapCrash(selfMap);

            Move needMove = calculator.calculateTurn(endDir);

            move.IsBrake     = needMove.IsBrake;
            move.EnginePower = needMove.EnginePower;
            move.WheelTurn   = needMove.WheelTurn;
        }
コード例 #3
0
        public override void execute(Move move)
        {
            TileDir dirMove = path[offset].DirOut;
            TileDir dirEnd  = path[1 + offset].DirOut;

            MovingCalculator calculator = new MovingCalculator();

            calculator.setupEnvironment(car, game, world);
            calculator.setupMapInfo(dirMove, path[0].Pos, path[1 + offset].Pos);

            Vector center = GetWayEnd(path[1 + offset].Pos, TileDir.Zero);
            Vector endPos = center + new Vector(dirEnd.X - dirMove.X, dirEnd.Y - dirMove.Y) * game.TrackTileSize * 0.25;

            calculator.setupDefaultAction(endPos);

            Vector endDir = new Vector(dirEnd.X + dirMove.X, dirEnd.Y + dirMove.Y).Normalize();

            calculator.setupAngleReach(endDir);
            calculator.setupPassageLine(endPos, new Vector(dirMove.X - dirEnd.X, dirMove.Y - dirEnd.Y).Normalize(), 0.6);

            Dictionary <TilePos, TileDir[]> selfMap = new Dictionary <TilePos, TileDir[]>();

            for (int i = 0; i <= offset + 1; i++)
            {
                if (path[i].DirIn == path[i].DirOut)
                {
                    selfMap.Add(path[i].Pos, new TileDir[2] {
                        path[i].DirIn.PerpendicularLeft(), path[i].DirIn.PerpendicularRight()
                    });
                }
                else
                {
                    selfMap.Add(path[i].Pos, new TileDir[3] {
                        path[i].DirIn, path[i].DirOut.Negative(), path[i].DirIn.Negative() + path[i].DirOut
                    });
                }
            }

            calculator.setupSelfMapCrash(selfMap);
            calculator.setupAdditionalPoints(this.additionalPoints);

            Move needMove = calculator.calculateTurn(endDir);

            move.IsBrake     = needMove.IsBrake;
            move.EnginePower = needMove.EnginePower;
            move.WheelTurn   = needMove.WheelTurn;
        }
コード例 #4
0
        public override void execute(Move move)
        {
            TileDir dirMove = path[0].DirOut;
            TileDir dirEnd  = path[2].DirOut;

            MovingCalculator calculator = new MovingCalculator();

            calculator.setupEnvironment(car, game, world);
            calculator.setupMapInfo(dirMove, path[0].Pos, path[2].Pos);
            calculator.setupDefaultAction(GetWayEnd(path[2].Pos, dirEnd.Negative()));

            Vector endDir = new Vector(dirEnd.X + dirMove.X, dirEnd.Y + dirMove.Y).Normalize();

            calculator.setupAngleReach(endDir);
            calculator.setupPassageLine(GetWayEnd(path[2].Pos, TileDir.Zero), new Vector(dirMove.X, dirMove.Y), 0.5);

            Dictionary <TilePos, TileDir[]> selfMap = new Dictionary <TilePos, TileDir[]>();

            for (int i = 0; i < 2; i++)
            {
                selfMap.Add(path[i].Pos, new TileDir[2] {
                    dirMove.PerpendicularLeft(), dirMove.PerpendicularRight()
                });
            }
            selfMap.Add(path[2].Pos, new TileDir[2] {
                dirEnd + dirMove.Negative(), dirEnd
            });

            calculator.setupSelfMapCrash(selfMap);
            calculator.setupAdditionalPoints(this.additionalPoints);

            Move needMove = calculator.calculateTurn(endDir);

            move.IsBrake     = needMove.IsBrake;
            move.EnginePower = needMove.EnginePower;
            move.WheelTurn   = needMove.WheelTurn;
        }