public virtual void cleanup()
        {
            robot = null;

            // Remove the file system and the manager
            robotFileSystemManager.cleanup();
            robotFileSystemManager = null;
        }
        public virtual void cleanup()
        {
            robot = null;

            // Remove the file system and the manager
            robotFileSystemManager.cleanup();
            robotFileSystemManager = null;
        }
示例#3
0
        /// <summary>
        /// Cleans up the event queue.
        /// </summary>
        /// <remarks>
        /// This method should be called when the event queue is no longer needed,
        /// i.e. before it must be garbage collected.
        /// </remarks>
        public void Cleanup()
        {
            // Remove all events
            Reset();

            // Remove all references to robots
            robot      = null;
            robotProxy = null;
        }
示例#4
0
        internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
        {
            IBasicEvents listener = robot.GetBasicEventListener();

            if (listener != null)
            {
                listener.OnRobotDeath(this);
            }
        }
示例#5
0
        internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
        {
            IBasicEvents listener = robot.GetBasicEventListener();

            if (listener != null)
            {
                listener.OnStatus(this);
            }
        }
示例#6
0
 internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
 {
     if (robot != null)
     {
         var listener = robot.GetBasicEventListener() as IBasicEvents2;
         if (listener != null)
         {
             listener.OnBattleEnded(this);
         }
     }
 }
示例#7
0
 internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
 {
     if (robot != null)
     {
         var listener = robot.GetBasicEventListener() as IBasicEvents2;
         if (listener != null)
         {
             listener.OnBattleEnded(this);
         }
     }
 }
示例#8
0
        internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
        {
            if (statics.IsPaintRobot())
            {
                IPaintEvents listener = ((IPaintRobot) robot).GetPaintEventListener();

                if (listener != null)
                {
                    listener.OnPaint(graphics);
                }
            }
        }
示例#9
0
        internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
        {
            if (statics.IsTeamRobot())
            {
                ITeamEvents listener = ((ITeamRobot) robot).GetTeamEventListener();

                if (listener != null)
                {
                    listener.OnMessageReceived(this);
                }
            }
        }
示例#10
0
        internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
        {
            if (statics.IsTeamRobot())
            {
                ITeamEvents listener = ((ITeamRobot)robot).GetTeamEventListener();

                if (listener != null)
                {
                    listener.OnMessageReceived(this);
                }
            }
        }
        internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
        {
            if (statics.IsInteractiveRobot())
            {
                IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener();

                if (listener != null)
                {
                    listener.OnMouseWheelMoved(this);
                }
            }
        }
示例#12
0
        internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
        {
            if (statics.IsAdvancedRobot())
            {
                IAdvancedEvents listener = ((IAdvancedRobot)robot).GetAdvancedEventListener();

                if (listener != null)
                {
                    listener.OnSkippedTurn(this);
                }
            }
        }
示例#13
0
        internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
        {
            if (statics.IsInteractiveRobot())
            {
                IInteractiveEvents listener = ((IInteractiveRobot)robot).GetInteractiveEventListener();

                if (listener != null)
                {
                    listener.OnKeyTyped(this);
                }
            }
        }
示例#14
0
        internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
        {
            if (statics.IsPaintRobot())
            {
                IPaintEvents listener = ((IPaintRobot)robot).GetPaintEventListener();

                if (listener != null)
                {
                    listener.OnPaint(graphics);
                }
            }
        }
示例#15
0
        internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
        {
            if (statics.IsAdvancedRobot())
            {
                IAdvancedEvents listener = ((IAdvancedRobot) robot).GetAdvancedEventListener();

                if (listener != null)
                {
                    listener.OnSkippedTurn(this);
                }
            }
        }
示例#16
0
        internal override sealed void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
        {
            if (robot != null)
            {
                IBasicEvents3 listener = robot.GetBasicEventListener() as IBasicEvents3;


                if (listener != null)
                {
                    listener.OnRoundEnded(this);
                }
            }
        }
        internal override sealed void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
        {
            if (robot != null)
            {
                IBasicEvents3 listener = robot.GetBasicEventListener() as IBasicEvents3;


                if (listener != null)
                {
                    listener.OnRoundEnded(this);
                }
            }
        }
示例#18
0
        private bool loadRobotRound()
        {
            robot = null;
            try
            {
                object instance = Activator.CreateInstance(robotType);
                robot = instance as IBasicRobot;
                if (robot == null)
                {
                    println("SYSTEM: Skipping robot: " + statics.getName());
                    return(false);
                }
                robot.SetOut(output);
                robot.SetPeer((IBasicRobotPeer)this);
                Console.SetOut(output);
                Console.SetError(output);
                eventManager.SetRobot(robot);
            }

            catch (MissingMethodException e)
            {
                punishSecurityViolation(statics.getName() + " " + e.Message);
                return(false);
            }
            catch (SecurityException e)
            {
                punishSecurityViolation(statics.getName() + " " + e.Message);
                return(false);
            }
            catch (Exception e)
            {
                if (e.InnerException is SecurityException)
                {
                }
                println("SYSTEM: An error occurred during initialization of " + statics.getName());
                println("SYSTEM: " + e);
                println(e);
                robot = null;
                LoggerN.logMessage(e);
                return(false);
            }
            return(true);
        }
示例#19
0
 public void setRobot(IBasicRobot r)
 {
     robot = r;
 }
示例#20
0
        /// <summary>
        /// Cleans up the event queue.
        /// </summary>
        /// <remarks>
        /// This method should be called when the event queue is no longer needed,
        /// i.e. before it must be garbage collected.
        /// </remarks>
        public void Cleanup()
        {
            // Remove all events
            Reset();

            // Remove all references to robots
            robot = null;
            robotProxy = null;
        }
        private bool loadRobotRound()
        {
            robot = null;
            try
            {
                object instance = Activator.CreateInstance(robotType);
                robot = instance as IBasicRobot;
                if (robot == null)
                {
                    println("SYSTEM: Skipping robot: " + statics.getName());
                    return false;
                }
                robot.SetOut(output);
                robot.SetPeer((IBasicRobotPeer) this);
                Console.SetOut(output);
                Console.SetError(output);
                eventManager.SetRobot(robot);
            }

            catch (MissingMethodException e)
            {
                punishSecurityViolation(statics.getName() + " " + e.Message);
                return false;
            }
            catch (SecurityException e)
            {
                punishSecurityViolation(statics.getName() + " " + e.Message);
                return false;
            }
            catch (Exception e)
            {
                if (e.InnerException is SecurityException)
                {
                    
                }
                println("SYSTEM: An error occurred during initialization of " + statics.getName());
                println("SYSTEM: " + e);
                println(e);
                robot = null;
                LoggerN.logMessage(e);
                return false;
            }
            return true;
        }
示例#22
0
 /// <summary>
 /// Sets the robot that will receive events dispatched from the event queue.
 /// </summary>
 /// <param name="robot">is the robot that will receive event dispatched from the event queue.</param>
 public void SetRobot(IBasicRobot robot)
 {
     this.robot = robot;
 }
示例#23
0
 /// <summary>
 /// Sets the robot that will receive events dispatched from the event queue.
 /// </summary>
 /// <param name="robot">is the robot that will receive event dispatched from the event queue.</param>
 public void SetRobot(IBasicRobot robot)
 {
     this.robot = robot;
 }
 public static void Dispatch(Event evnt, IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
 {
     eventHelper.Dispatch(evnt, robot, statics, graphics);
 }
示例#25
0
 /// <summary>
 /// Dispatch this event for a robot, it's statistics, and graphics context.
 /// </summary>
 /// <param name="robot">the robot to dispatch to.</param>
 /// <param name="statics">the robot to statistics to.</param>
 /// <param name="graphics">the robot to graphics to.</param>
 // This method must be invisible on Robot API
 internal virtual void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
 {
 }
示例#26
0
 public static void Dispatch(Event evnt, IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics)
 {
     eventHelper.Dispatch(evnt, robot, statics, graphics);
 }