Example #1
0
 public void PreMove(Car self, World world, Game game, Move move)
 {
     if (!IsActivated && self.GetSpeed() < 0.75f
         && (this.IsFaceObstacle(self, world, game)
             || (self.EnginePower >= 0.5f && world.Tick > 190 && world.Tick > this.lastUsedTick + 60)))
     {
         IsActivated = true;
         this.step1 = true;
     }
 }
Example #2
0
        public void PostMove(Car self, World world, Game game, Move move)
        {
            if (!BackMovingModule.IsActivated)
            {
                float speed = self.GetSpeed();
                float angleDerivation = (float)Math.Abs(this.desiredAngle);
                SetCorrectAngles(self, move);
                if (self.RemainingNitroTicks > 0 && this.distance <= 2400)
                {
                    move.IsBrake = true;
                }

                else if (this.distance <= 1200)
                {
                    if (speed <= 10)
                    {
                        move.EnginePower = 0.5;
                    }
                    else if (speed <= 24 || self.EnginePower < 0.15)
                    {
                        move.EnginePower = -0.5;
                    }
                    else
                    {
                        move.IsBrake = true;
                    }
                }
                else
                {
                    if (angleDerivation <= 0.1f)
                    {
                        move.EnginePower = 1.0;
                        if (this.distance > 4000 && world.Tick > 180)
                        {
                            move.IsUseNitro = true;
                        }
                    }
                    else if (angleDerivation <= 0.5f)
                    {
                        move.EnginePower = 1.0;
                    }
                    else
                    {
                        if (speed <= 12)
                        {
                            move.EnginePower = 1.0;
                        }
                        else if (speed <= 22)
                        {
                            move.EnginePower = -0.15;
                        }
                        else
                        {
                            move.IsBrake = true;
                        }
                    }
                }

                if (self.EnginePower < 0.15)
                {
                    move.EnginePower = 0.25;
                }
            }
        }
Example #3
0
 private void CalculateEnemiesInFront(Car self, Game game)
 {
     foreach (var car in this.enemiesCars)
     {
         if (car.Type == CarType.Buggy)
         {
             if (!car.IsFinishedTrack && car.Durability > 0.0)
             {
                 var currentEnemyPosition = new PointF((float)car.X, (float)car.Y);
                 var nextEnemyPosition = new PointF(
                     (float)car.X + (float)car.SpeedX,
                     (float)car.Y + (float)car.SpeedY);
                 var futureEnemyPosition = new PointF(
                     (float)car.X + PredictionCount * (float)car.SpeedX,
                     (float)car.Y + PredictionCount * (float)car.SpeedY);
                 var currentWasherPosition = new PointF((float)self.X, (float)self.Y);
                 var nextWasherPosition =
                     new PointF(
                         (float)self.X + (float)self.SpeedX / self.GetSpeed() * (float)game.WasherInitialSpeed,
                         (float)self.Y + (float)self.SpeedY / self.GetSpeed() * (float)game.WasherInitialSpeed);
                 var futureWasherPosition =
                     new PointF(
                         (float)self.X
                         + PredictionCount * (float)self.SpeedX / self.GetSpeed()
                         * (float)game.WasherInitialSpeed,
                         (float)self.Y
                         + PredictionCount * (float)self.SpeedY / self.GetSpeed()
                         * (float)game.WasherInitialSpeed);
                 PointF? intersectsPoint = MathHelper.PointOfIntersection(
                     currentWasherPosition,
                     futureWasherPosition,
                     currentEnemyPosition,
                     futureEnemyPosition);
                 if (intersectsPoint.HasValue
                     && MathHelper.Distance(intersectsPoint.Value, currentWasherPosition)
                     / (float)game.WasherInitialSpeed <= PredictionCount
                     && MathHelper.Distance(currentWasherPosition, currentEnemyPosition)
                     > MathHelper.Distance(nextWasherPosition, nextEnemyPosition)
                     && Math.Abs(
                         MathHelper.Distance(intersectsPoint.Value, currentWasherPosition)
                         / (float)game.WasherInitialSpeed
                         - MathHelper.Distance(intersectsPoint.Value, currentEnemyPosition) / car.GetSpeed())
                     < WasherPredictionError)
                 {
                     this.enemyInFront = true;
                     break;
                 }
             }
         }
     }
 }