Esempio n. 1
0
 /// <summary>
 /// Constructs a new EntityView
 /// </summary>
 /// <param name="model">The entity that view is meant to show</param>
 /// <param name="position">The position of the entity</param>
 /// <param name="tman">The ThreadSafeEventManager that is controlled the XmasView</param>
 public EntityView(XmasEntity model, XmasPosition position, ThreadSafeEventManager tman)
 {
     this.model = model;
     this.Position = position;
     eventqueue = model.ConstructEventQueue();
     tman.AddEventQueue(eventqueue);
 }
Esempio n. 2
0
 public ConsoleViewFactory(ThreadSafeEventManager evtman)
 {
     this.evtman = evtman;
     AddTypeLink<Ghost, ConsoleGhostView>();
     AddTypeLink<Wall, ConsoleWallView>();
     AddTypeLink<Player, ConsolePlayerView>();
     AddTypeLink<ImpassableWall, ConsoleImpassableWallView>();
     AddTypeLink<GrabberAgent, ConsoleGrabberView>();
     AddTypeLink<Package, ConsolePackageView>();
     AddTypeLink<DropZone, ConsoleDropZoneView>();
 }
Esempio n. 3
0
 public ConsoleView(XmasModel model, Point drawPos, ConsoleWorldView viewWorld, ConsoleViewFactory entityFactory, ThreadSafeEventManager evtmanager)
     : base(evtmanager)
 {
     this.viewWorld = viewWorld;
     this.entityFactory = entityFactory;
     this.drawPos = drawPos;
     eventqueue = model.EventManager.ConstructEventQueue();
     evtmanager.AddEventQueue(eventqueue);
     eventqueue.Register(new Trigger<EntityAddedEvent>(Model_EntityAdded));
     eventqueue.Register(new Trigger<EntityRemovedEvent>(model_EntityRemoved));
 }
Esempio n. 4
0
        public LoggerEntityView(XmasEntity model
                               , XmasPosition position
		                       , ThreadSafeEventManager evtman 
		                       , Logger logstream
		)
            : base(model, position, evtman)
        {
            this.logstream = logstream;
            eventqueue.Register (new Trigger<UnitMovePostEvent> (entity_UnitMovePostEvent));
            eventqueue.Register (new Trigger<UnitMovePreEvent> (entity_UnitMovePreEvent));
            eventqueue.Register (new Trigger<PackageGrabbedEvent> (entity_PackageGrabbedEvent));
        }
Esempio n. 5
0
        public ConsoleLoggerView( XmasModel model
		                         , LoggerViewFactory entityFactory
		                         , ThreadSafeEventManager evtman
		                         , Logger log
		                         )
            : base(evtman)
        {
            this.entityFactory = entityFactory;
            this.log = log;

            evtqueue = model.EventManager.ConstructEventQueue();
            ThreadSafeEventManager.AddEventQueue(evtqueue);

            evtqueue.Register (new Trigger<EntityAddedEvent> (model_EntityAdded));
            evtqueue.Register (new Trigger<ActionFailedEvent> (engine_ActionFailed));
            evtqueue.Register(new Trigger<EisAgentDisconnectedEvent>(controller_AgentDisconnected));
            evtqueue.Register(new Trigger<EntityRemovedEvent>(model_EntityRemoved));
            evtqueue.Register(new Trigger<EisAgentTimingEvent>(entity_TimerElapsedEvent));
        }
Esempio n. 6
0
        private static void Main(string[] args)
        {
            ConsoleFactory factory = new ConsoleFactory();

            //Model contruction
            XmasModel model = factory.ConstructModel(new TestWorld1());

            //View construction
            ThreadSafeEventManager evtman1 = new ThreadSafeEventManager();
            ConsoleView view1 = new ConsoleView(model,new Point(0,0), new ConsoleWorldView((TileWorld)model.World,xe => xe is GrabberAgent), new ConsoleViewFactory(evtman1), evtman1);

            ThreadSafeEventManager evtman2 = new ThreadSafeEventManager();
            ConsoleView view2 = new ConsoleView(model, new Point(0,24), new ConsoleWorldView((TileWorld)model.World), new ConsoleViewFactory(evtman2), evtman2);

            StreamWriter sw = File.CreateText("error.log");

            List<XmasView> views = new List<XmasView>();
            var loggerevtman = new ThreadSafeEventManager();
            var logger = new Logger(sw, DebugLevel.Timing);
            views.Add(new ConsoleLoggerView(model,new LoggerViewFactory(loggerevtman,logger),loggerevtman,logger));
            views.Add(view1);
            views.Add(view2);

            //Controller construction
            var listener = new TcpListener(IPAddress.Parse("127.0.0.1"), 44444);
            var eisConverter = new ConsoleEisConversionTool();
            var iilParser = new ConsoleIilActionParser();
            var eisserver = new EISAgentServer(listener, eisConverter, iilParser);

            var humancontroller = new HumanInterfaceManager(new KeyboardSettings());

            List<XmasController> controllers = new List<XmasController>();

            controllers.Add(eisserver);
            controllers.Add(humancontroller);

            var engine = new XmasEngineManager(factory);

            engine.StartEngine(model,views,controllers);
        }
Esempio n. 7
0
 /// <summary>
 /// constructs a XmasView
 /// </summary>
 /// <param name="evtmanager">The ThreadSafe EventManager meant to be used by this view</param>
 public XmasView(ThreadSafeEventManager evtmanager)
 {
     this.evtmanager = evtmanager;
 }
Esempio n. 8
0
 public ConsolePlayerView(XmasEntity model, XmasPosition position, ThreadSafeEventManager evtman)
     : base(model, position, evtman)
 {
 }
 public ConsoleImpassableWallView(XmasEntity model, XmasPosition position, ThreadSafeEventManager evtman)
     : base(model, position, evtman)
 {
 }
Esempio n. 10
0
 public LoggerViewFactory(ThreadSafeEventManager evtman, Logger logstream)
 {
     this.evtman = evtman;
     this.logstream = logstream;
 }
Esempio n. 11
0
 public ConsoleEntityView(XmasEntity model, XmasPosition position, ThreadSafeEventManager evtman)
     : base(model, position, evtman)
 {
     eventqueue.Register(new Trigger<UnitMovePostEvent>(entityView_UnitMovePostEvent));
 }
Esempio n. 12
0
 public ConsoleGrabberView(XmasEntity model, XmasPosition position, ThreadSafeEventManager evtman)
     : base(model, position, evtman)
 {
     this.EventQueue.Register(new Trigger<PackageGrabbedEvent>(_ => haspackage = true));
     this.eventqueue.Register(new Trigger<PackageReleasedEvent>(_ => haspackage = false));
 }