Ejemplo n.º 1
0
        public override void ActionFire(Enemy e)
        {
            Random randonGen = new Random();

            MyRobot.BodyColor = Color.FromArgb(randonGen.Next(255), randonGen.Next(255),
                                               randonGen.Next(255));
            MyRobot.BulletColor = Color.FromArgb(randonGen.Next(255), randonGen.Next(255),
                                                 randonGen.Next(255));
            MyRobot.GunColor = Color.FromArgb(randonGen.Next(255), randonGen.Next(255),
                                              randonGen.Next(255));
            MyRobot.RadarColor = Color.FromArgb(randonGen.Next(255), randonGen.Next(255),
                                                randonGen.Next(255));
            MyRobot.ScanColor = Color.FromArgb(randonGen.Next(255), randonGen.Next(255),
                                               randonGen.Next(255));

            MyRobot.IsAdjustGunForRobotTurn = true;

            if (NearTarget == null || (NearTarget.name != e.name && NearTarget.distance > e.distance) ||
                (NearTarget.name == e.name))
            {
                this.NearTarget = e;
            }
            else
            {
                return;
            }

            double absBearing = Utils.ToRadians(NearTarget.bearing) + MyRobot.HeadingRadians;

            double radarTurn = absBearing - MyRobot.RadarHeadingRadians;

            MyRobot.MaxVelocity = Rules.MAX_VELOCITY;

            MyRobot.SetTurnGunRightRadians(Utils.NormalRelativeAngle(absBearing - MyRobot.GunHeadingRadians));

            Shots++;
            DoFire(NearTarget);

            //MyRobot.SetTurnRadarRightRadians(Utils.NormalRelativeAngle(radarTurn)*2);
            if (MyRobot.Others == 1)
            {
                MyRobot.SetTurnRadarRightRadians(Utils.NormalRelativeAngle(radarTurn) * 2); // make the radar lock on
            }
            else
            {
                MyRobot.SetTurnRadarRight(double.PositiveInfinity);
            }
        }