Exemplo n.º 1
0
        public void WhenOnHitByBulletIsCalled()
        {
            var b = RandomHelper.RandomBullet();
            var e = new HitByBulletEvent(RandomHelper.RandomBearing(), b);

            _brain.OnHitByBullet(e);
        }
Exemplo n.º 2
0
        /// <summary>
        /// zdarzenie jak zostanę trafiony
        /// </summary>
        /// <param name="evnt"></param>
        public override void OnHitByBullet(HitByBulletEvent e)
        {
            if (!_ACTION_START)
            {
                _ACTION_START = true;
                SetTankForCorner(e.Heading + 180);
            }

            CustomLog("TRAFILI MNIE. bearing: " + e.Bearing.ToString("F2") + " heading: " + e.Heading.ToString("F2")
                      + " bearing radian: " + e.BearingRadians.ToString("F2") + " heading radian: " + e.HeadingRadians.ToString("F2"));


            //ustaw broń do strzelania
            //TurnRadarRight(360);
            SetGunForHit(e.Heading + 180);
            Fire(1);

            if (_ESCAPE_FROM_BULLET_AHEAD_OR_BACK == 0)
            {
                Back(200);
                _ESCAPE_FROM_BULLET_AHEAD_OR_BACK = 1;
            }
            else
            {
                Ahead(200);
                _ESCAPE_FROM_BULLET_AHEAD_OR_BACK = 0;
            }

            _IS_TARGET = false;
            Scan();
        }
Exemplo n.º 3
0
        public override void onHitByBullet(HitByBulletEvent @event)
        {
            // maybe we should be going right instead?
            var _turnLeft  = 90 - @event.getBearing();
            var _turnRight = -(90 + @event.getBearing());

            Console.WriteLine("onHitByBullet.bearing: " + @event.getBearing());
            Console.WriteLine("onHitByBullet._turnLeft: " + _turnLeft);
            Console.WriteLine("onHitByBullet._turnRight: " + _turnRight);

            if (_turnLeft < _turnRight)
            {
                this.turnLeft(_turnLeft);
            }
            else
            {
                this.turnLeft(_turnRight);
            }

            this.ahead(40);

            if (_turnLeft < _turnRight)
            {
                this.turnRight(15);
            }
            else
            {
                this.turnLeft(15);
            }
            this.ahead(40);
        }
Exemplo n.º 4
0
        public override void OnHitByBullet(HitByBulletEvent e)
        {
            // If the _enemyWaves collection is empty, we must have missed the
            // detection of this wave somehow.

            BulletWave hitWave = null;

            foreach (var ew in enemyBullets)
            {
                if (Math.Abs(ew.GetTraveledDistance(Time) - Helper.GetDistance(X, Y, ew.StartX, ew.StartY)) <= _radius &&
                    Math.Abs(Helper.GetBulletVelocity(e.Bullet.Power) - ew.Velocity) < 0.001)
                {
                    hitWave = ew;
                    break;
                }
            }

            if (hitWave != null)
            {
                LogHit(hitWave, e.Bullet.X, e.Bullet.Y);
                enemyBullets.Remove(hitWave);
            }

            if (medKitLocked)
            {
                SetBackAsFront(HeadingRadians + Math.PI, rnd.Next(50, 100));
            }
        }
Exemplo n.º 5
0
        public override void OnHitByBullet(HitByBulletEvent evnt)
        {
            if (!robots.ContainsKey(evnt.Name))
            {
                return;
            }

            var enemy = robots[evnt.Name];

            enemy.Hits++;

            if (enemy.Distance > DISTANCE_THRESHOLD && enemy.Time < 500)
            {
                return;
            }

            if (LastBulletHit == null &&
                CurrentPhase == RoboPhase.MeetAndGreet)
            {
                LastBulletHit   = evnt;
                CurrentPhase    = RoboPhase.KillItWithFire;
                TargetEnemyName = evnt.Name;
            }
            else if (LastBulletHit?.Name == evnt.Name)
            {
                LastBulletHit = evnt;
            }

            base.OnHitByBullet(evnt);
        }
Exemplo n.º 6
0
 public override void OnHitByBullet(HitByBulletEvent evnt)
 {
     for (int i = 0; i < behaviors.Count; ++i)
     {
         var behavior = behaviors[i];
         behavior.OnHitByBullet(evnt);
     }
 }
Exemplo n.º 7
0
Arquivo: Meele.cs Projeto: ltduy/hihuc
 public override void OnHitByBullet(HitByBulletEvent e)
 {
     BulletForces.Add(new ForcedPoint(this.MyBot.Position.X, this.MyBot.Position.Y, 5000)
     {
         Color      = Color.Red,
         AffectTurn = 30
     });
 }
Exemplo n.º 8
0
        /// <summary>
        ///   onHitByBullet:  Turn perpendicular to the bullet, and move a bit.
        /// </summary>
        public override void OnHitByBullet(HitByBulletEvent e)
        {
            TurnRight(Utils.NormalRelativeAngleDegrees(90 - (Heading - e.Heading)));

            Ahead(dist);
            dist *= -1;
            Scan();
        }
Exemplo n.º 9
0
 public double?RegisterHitByBullet(HitByBulletEvent evnt)
 {
     if (_queue.Count > 0)
     {
         return(_queue.Peek().GetGuessFactor(evnt));
     }
     return(null);
 }
Exemplo n.º 10
0
        public double?GetGuessFactor(HitByBulletEvent hitByBulletEvent)
        {
            // todo

            double gf = new Angle(hitByBulletEvent.Heading - _initialEnemyDirect.Heading.Degrees).Degrees180 / (2.0 * _maxEscapeAngle);

            return(gf);
        }
Exemplo n.º 11
0
        private void ProcessEvents()
        {
            m_bMoveComplete = false;
            m_bTurnComplete = false;
            if (m_pEvents.Count > 0)
            {
                if (m_pEvents[0] is HitWallEvent)
                {
                    HitWallEvent pEvent = (HitWallEvent)m_pEvents[0];
                    m_pEvents.Clear();
                    OnHitWall(pEvent);
                    m_bMoveComplete = true;
                    return;
                }

                if (m_pEvents[0] is HitRobotEvent)
                {
                    HitRobotEvent pEvent = (HitRobotEvent)m_pEvents[0];
                    m_pEvents.Clear();
                    OnHitRobot(pEvent);
                    m_bMoveComplete = true;
                    return;
                }

                if (m_pEvents[0] is ScannedRobotEvent)
                {
                    ScannedRobotEvent pEvent = (ScannedRobotEvent)m_pEvents[0];
                    m_pEvents.Clear();
                    OnScannedRobot(pEvent);
                    return;
                }

                if (m_pEvents[0] is BulletMissedEvent)
                {
                    BulletMissedEvent pEvent = (BulletMissedEvent)m_pEvents[0];
                    m_pEvents.Clear();
                    OnBulletMissed(pEvent);
                    return;
                }

                if (m_pEvents[0] is BulletHitEvent)
                {
                    BulletHitEvent pEvent = (BulletHitEvent)m_pEvents[0];
                    m_pEvents.Clear();
                    OnBulletHit(pEvent);
                    return;
                }

                if (m_pEvents[0] is HitByBulletEvent)
                {
                    HitByBulletEvent pEvent = (HitByBulletEvent)m_pEvents[0];
                    m_pEvents.Clear();
                    OnHitByBullet(pEvent);
                    return;
                }
            }
        }
Exemplo n.º 12
0
        public override void OnHitByBullet(HitByBulletEvent e)
        {
            double absoluteBearing = Heading + e.Bearing;
            double bearingFromGun  = Utils.NormalRelativeAngleDegrees(absoluteBearing - GunHeading);

            TurnGunRight(bearingFromGun);
            EsquivaTiros();
            WaitFor(new GunTurnCompleteCondition(this));
        }
Exemplo n.º 13
0
 // Robot event handler, when the robot gets hit by a bullet
 public override void OnHitByBullet(HitByBulletEvent e)
 {
     BodyColor = Color.Red;
     //double bearing = e.Bearing;
     //if (Energy < energyLimit)
     //{
     //    TurnRight(-bearing);
     //}
 }
Exemplo n.º 14
0
        public void OnHitByBullet(HitByBulletEvent evnt)
        {
            IEnemy enemy = SafeGetEnemy(evnt.Name);

            if (enemy != null)
            {
                enemy.RegisterHitByBullet(evnt);
            }
        }
Exemplo n.º 15
0
        public override void OnHitByBullet(HitByBulletEvent evento)
        {
            Console.WriteLine($"{Name} foi alvejado por {evento.Name} com {evento.Power} de dano!!");

            //Movimentação de defesa ao receber um tiro
            Back(100);

            TurnLeft(45);

            Scan();
        }
Exemplo n.º 16
0
 public void RegisterHitByBullet(HitByBulletEvent evnt)
 {
     if (Waves != null)
     {
         double?gf = Waves.RegisterHitByBullet(evnt);
         if (_enemyGuessFactorStats != null && gf != null)
         {
             _enemyGuessFactorStats.Update(gf.Value);
         }
     }
 }
Exemplo n.º 17
0
        //void OnHitWall(HitWallEvent evnt)
        //{
        //    direction *= -1;
        //}
        public void OnHitByBullet(HitByBulletEvent e)
        {
            sucessiveShoots++;
            timeAct = Time;

            TurnRight(Utils.NormalRelativeAngleDegrees(90 - (Heading - e.Heading))); // sempre correr em 90 graus ao inimigo
            Ahead(distanceToMoveWhenShooted);
            distanceToMoveWhenShooted *= -1;                                         //talvez seja melhor sem isso.
            Scan();
            //continua aqui
        }
Exemplo n.º 18
0
 public override void OnHitByBullet(HitByBulletEvent evnt)
 {
     base.OnHitByBullet(evnt);
     //etTurnRadarRight(360);
     incomingHitss++;
     if (incomingHitss > 0 && !blackBoard.DirectHit || Time % 100 == 0)
     {
         // currentBehaviour = moveBehaviour;
         blackBoard.DirectHit = true;
         incomingHitss        = 0;
     }
 }
Exemplo n.º 19
0
        public override void OnHitByBullet(HitByBulletEvent evnt)
        {
            base.OnHitByBullet(evnt);
            double num = evnt.Bearing;

            base.TurnLeft(num);
            for (int i = 0; i > 2; i++)
            {
                base.Fire(1.0);
            }
            base.TurnGunRight(num);
        }
Exemplo n.º 20
0
        } // onscannedrobot

        public override void OnHitByBullet(HitByBulletEvent e)
        {
            armaDisparo += 1;
            if (tipoTiro == 1)
            {
                armaFrenteAcerto += 1;
                armaFrenteDisparo += 1;
            }
            else if (tipoTiro == 2)
            {
                armaDiretoDisparo += 1;
                armaDiretoAcerto += 1;
            }
        } //onhitbybullet
Exemplo n.º 21
0
        /// <summary>
        ///   We were hit!  Turn perpendicular to the bullet,
        ///   so our seesaw might avoid a future shot.
        ///   In addition, draw orange circles where we were hit.
        /// </summary>
        public override void OnHitByBullet(HitByBulletEvent e)
        {
            // demonstrate feature of debugging properties on RobotDialog
            DebugProperty["lastHitBy"] = e.Name + " with power of bullet " + e.Power + " at time " + Time;

            // show how to remove debugging property
            DebugProperty["lastScannedRobot"] = null;

            // gebugging by painting to battle view
            IGraphics g = Graphics;

            g.DrawEllipse(Pens.Orange, (int)(X - 55), (int)(Y - 55), 110, 110);
            g.DrawEllipse(Pens.Orange, (int)(X - 56), (int)(Y - 56), 112, 112);
            g.DrawEllipse(Pens.Orange, (int)(X - 59), (int)(Y - 59), 118, 118);
            g.DrawEllipse(Pens.Orange, (int)(X - 60), (int)(Y - 60), 120, 120);

            TurnLeft(90 - e.Bearing);
        }
Exemplo n.º 22
0
        public override void OnRobotDeath(RobotDeathEvent evnt)
        {
            Console.WriteLine("Died: " + evnt.Name);
            if (TargetEnemyName == evnt.Name || LastBulletHit?.Name == evnt.Name)
            {
                if (robots.ContainsKey(evnt.Name))
                {
                    robots.Remove(evnt.Name);
                }

                LastBulletHit   = null;
                TargetEnemyName = null;

                CurrentPhase = RoboPhase.WallRush;
            }

            base.OnRobotDeath(evnt);
        }
Exemplo n.º 23
0
		public override void onHitByBullet(HitByBulletEvent @event)
		{
			// maybe we should be going right instead?
			var _turnLeft = 90 - @event.getBearing();
			var _turnRight = -(90 + @event.getBearing());

			Console.WriteLine("onHitByBullet.bearing: " + @event.getBearing());
			Console.WriteLine("onHitByBullet._turnLeft: " + _turnLeft);
			Console.WriteLine("onHitByBullet._turnRight: " + _turnRight);

			if (_turnLeft < _turnRight)
				this.turnLeft(_turnLeft);
			else
				this.turnLeft(_turnRight);

			this.ahead(40);

			if (_turnLeft < _turnRight)
				this.turnRight(15);
			else
				this.turnLeft(15);
			this.ahead(40);
		}
Exemplo n.º 24
0
 public override void OnHitByBullet(HitByBulletEvent evnt)
 {
     base.OnHitByBullet(evnt);
 }
Exemplo n.º 25
0
 public virtual void OnHitByBullet(HitByBulletEvent e)
 {
 }
Exemplo n.º 26
0
 // O que fazer quando você for atingido por uma munição
 public override void OnHitByBullet(HitByBulletEvent evnt)
 {
     SetBack(30);
     SetAhead(20);
     Execute();
 }
Exemplo n.º 27
0
 public void OnHitByBullet(HitByBulletEvent evnt)
 {
     // TODO BUG: evnt.Name is returning actual name rather than just a number!
     //Out.WriteLine(string.Format("Hit by: {0}", evnt.Name));
     _context.OnHitByBullet(evnt);
 }
Exemplo n.º 28
0
 public void OnHitByBullet(HitByBulletEvent evnt)
 {
     count(evnt);
 }
Exemplo n.º 29
0
		public override void onHitByBullet(HitByBulletEvent @event)
		{
			GotTarget = false;

			turnLeft(90 - @event.getBearing());
		}
Exemplo n.º 30
0
 public override void OnHitByBullet(HitByBulletEvent evnt)
 {
     SetTurnRight(60);
     SetAhead(150);
     Execute();
 }
Exemplo n.º 31
0
 /// <summary>
 ///   We were hit!  Turn perpendicular to the bullet,
 ///   so our seesaw might avoid a future shot.
 /// </summary>
 public override void OnHitByBullet(HitByBulletEvent e)
 {
     TurnLeft(90 - e.Bearing);
 }
Exemplo n.º 32
0
 public override void OnHitByBullet(HitByBulletEvent e)
 {
     // Turn to confuse the other robot
     TurnRate = 5;
 }