Example #1
0
 protected virtual void OnHitRobot(HitRobotEvent e)
 {
 }
Example #2
0
 public override void OnHitRobot(HitRobotEvent e)
 {
     UpdateMoveFactor();
     base.OnHitRobot(e);
 }
Example #3
0
        internal void ProcessMovement()
        {
            // update robot position
            PointD tOldPosition = m_tPosition;

            m_tPosition += m_tMovement;
            m_tMovement  = PointD.Empty;

            // check if we have hit a wall
            bool bHitWall = false;

            if (m_tPosition.X - Size.Width / 2.0 < 0)
            {
                m_tPosition.X = Size.Width / 2.0;
                bHitWall      = true;
            }
            else if (m_tPosition.X + Size.Width / 2.0 > m_pBattle.BattleFieldSize.Width)
            {
                m_tPosition.X = m_pBattle.BattleFieldSize.Width - Size.Width / 2.0;
                bHitWall      = true;
            }
            if (m_tPosition.Y - Size.Height / 2.0 < 0)
            {
                m_tPosition.Y = Size.Height / 2.0;
                bHitWall      = true;
            }
            else if (m_tPosition.Y + Size.Height / 2.0 > m_pBattle.BattleFieldSize.Height)
            {
                m_tPosition.Y = m_pBattle.BattleFieldSize.Height - Size.Height / 2.0;
                bHitWall      = true;
            }
            if (bHitWall)
            {
                m_pEvents.Add(new HitWallEvent());
                m_dEnergy -= 3.0;
            }

            // rotate robot
            m_nHeading += m_nRotation;
            if (m_nHeading < 0)
            {
                m_nHeading = 360 + m_nHeading;
            }
            if (m_nHeading > 359)
            {
                m_nHeading -= 360;
            }
            m_nRotation = 0;

            PointF tEndPoint = new PointF((float)(Position.X + Math.Sin(HeadingRadians) * BattleFieldSize.Width),
                                          (float)(Position.Y + Math.Cos(HeadingRadians) * BattleFieldSize.Width));

            // check if we can see another robot
            for (int i = 0; i < m_pBattle.Robots.Length; i++)
            {
                Robot pRobot = m_pBattle.Robots[i];

                // make sure we're not testing against ourselves
                if (pRobot != this)
                {
                    GraphicsPath pPath = new GraphicsPath();
                    pPath.AddLine(Position, tEndPoint);
                    pPath.CloseFigure();
                    pPath.Widen(new Pen(Color.Black, 1));
                    Region pRegion = new Region(pPath);
                    pRegion.Intersect(pRobot.Bounds);
                    if (!pRegion.IsEmpty(m_pGraphics))
                    {
                        // we can see this robot
                        PointD            tDistance = pRobot.Position - Position;
                        double            dDistance = Math.Sqrt(tDistance.X * tDistance.X + tDistance.Y * tDistance.Y);
                        ScannedRobotEvent pEvent    = new ScannedRobotEvent(
                            pRobot.Name, pRobot.Energy, pRobot.Heading - Heading,
                            dDistance, pRobot.Heading, pRobot.Velocity);
                        m_pEvents.Add(pEvent);
                    }
                }
            }

            // check if we have collided with another robot
            for (int i = 0; i < m_pBattle.Robots.Length; i++)
            {
                Robot pRobot = m_pBattle.Robots[i];

                // make sure we're not testing against ourselves
                if (pRobot != this)
                {
                    if (pRobot.Bounds.IntersectsWith(Bounds))
                    {
                        // send message to ourselves
                        bool          bAtFault = true;
                        HitRobotEvent pEvent   = new HitRobotEvent(pRobot.Name,
                                                                   Math.Abs(pRobot.Heading - Heading),
                                                                   pRobot.Energy, bAtFault);
                        m_pEvents.Add(pEvent);
                        m_tPosition = tOldPosition;
                        m_dEnergy  -= 3.0;
                    }
                }
            }
        }
Example #4
0
 public void OnHitRobot(HitRobotEvent evnt)
 {
     count(evnt);
 }
Example #5
0
 public override void OnHitRobot(HitRobotEvent evnt)
 {
 }
Example #6
0
 public override void OnHitRobot(HitRobotEvent e)
 {
     _hitRobotEvents.Add(e);
 }
Example #7
0
 public override void OnHitRobot(HitRobotEvent evnt)
 {
     fsm.current.getOnHitRobot(evnt);
 }
 public override void OnHitRobot(HitRobotEvent e)
 {
     reverseDirection();
 }
Example #9
0
 public override void OnHitRobot(HitRobotEvent evnt)
 {
     base.OnHitRobot(evnt);
     this.TurnLeft(evnt.Bearing);
     this.Fire(3);
 }
Example #10
0
 //Quando acertar robo
 public override void OnHitRobot(HitRobotEvent e)
 {
     SetBack(15);
     Fire(3);
 }