Exemplo n.º 1
0
        public void WaitForEvents()
        {
            //Receives a move done event from the simcore
            string objID     = null;
            string eventType = null;
            List <SimulationEvent> incomingEvents = new List <SimulationEvent>();

            while (true)
            {
                incomingEvents = server.GetEvents();

                if (incomingEvents.Count == 0)
                {//do nothing
                }
                else
                {
                    foreach (SimulationEvent e in incomingEvents)
                    {
                        eventType = e.eventType;
                        switch (eventType)
                        {
                        case "MoveDone":
                            objID = ((StringValue)e["ObjectID"]).value;     //see line 222 of MotionSim.cs for reference
                            MoveComplete_Event returnEvent = new MoveComplete_Event(objID.ToString());

                            IncomingList.Add(returnEvent);

                            break;

                        case "MoveObjectRequest":
                            //Figure out from Dennis how to let him know this happened

                            break;

                        case "AttackObjectRequest":
                            //Figure out from Dennis how to let him know this happened

                            break;

                        default:
                            //Should throw an error?  Will getEvents receive events I'm not subscribed to?
                            break;
                        }
                    }
                    incomingEvents = null;
                }
                Thread.Sleep(100);
            }
        }
Exemplo n.º 2
0
        public void WaitForEvents()
        { 
            //Receives a move done event from the simcore
            string objID = null;
            string eventType = null;
            List<SimulationEvent> incomingEvents = new List<SimulationEvent>();
            while (true)
            {
                 incomingEvents = server.GetEvents();

                if (incomingEvents.Count == 0)
                {//do nothing 
                }
                else
                {
                    foreach (SimulationEvent e in incomingEvents)
                    {
                        eventType = e.eventType;
                        switch (eventType)
                        { 
                            case "MoveDone":
                                objID = ((StringValue)e["ObjectID"]).value; //see line 222 of MotionSim.cs for reference
                                MoveComplete_Event returnEvent = new MoveComplete_Event(objID.ToString());

                                IncomingList.Add(returnEvent);

                                break;
                            case "MoveObjectRequest":
                                //Figure out from Dennis how to let him know this happened

                                break;
                            case "AttackObjectRequest":
                                //Figure out from Dennis how to let him know this happened

                                break;
                            default:
                                //Should throw an error?  Will getEvents receive events I'm not subscribed to?
                                break;
                        }
                        
                    }
                    incomingEvents = null;
                }
                Thread.Sleep(100);
            }
        }