Exemplo n.º 1
0
 public static void Add(int time, ScenarioEventType newEvent)
 {
     if (!queue.ContainsKey(time))
     {
         queue.Add(time, new TimeNodeClass(time));
     }
     queue[time].AddEvent(newEvent);
 }
Exemplo n.º 2
0
        public void DropEvent(int index)
        {
            ScenarioEventType e = theseEvents[(int)index];

            theseUnits[e.UnitID] -= 1;
            if (theseUnits[e.UnitID] <= 0)
            {
                theseUnits.Remove(e.UnitID);
            }
            theseEvents.RemoveAt((int)index);
        }
Exemplo n.º 3
0
 public void AddEvent(ScenarioEventType e)
 {
     theseEvents.Add(e);
     if (e is ScenarioEventType)
     {
         if (!(theseUnits.ContainsKey(e.UnitID)))
         {
             theseUnits.Add(e.UnitID, 1);
         }
         else
         {
             theseUnits[e.UnitID] += 1;
         }
     }
 }
Exemplo n.º 4
0
 public void AddEvent(ScenarioEventType e)
 {
     theseEvents.Add(e);
     if (e is ScenarioEventType)
     {
         if (!(theseUnits.ContainsKey(e.UnitID)))
         {
             theseUnits.Add(e.UnitID, 1);
         }
         else
         {
             theseUnits[e.UnitID] += 1;
         }
     }
 }
Exemplo n.º 5
0
 public void GetParameters(ScenarioEventType Event)
 {
     // enter pointing to a <ParameterSetting> or there are no parameters
     if (reader.Name != "ParameterSetting")
     {
         return;
     }
     reader.Read();// points to first  <Parameter>
     while ("Parameter" == reader.Name)
     {
         ParameterSettingType nextSetting = GetParameterSetting();
         Event.Add(nextSetting);
     }
     // and move past the </ParameterSettings>
     reader.ReadEndElement();
 }
Exemplo n.º 6
0
        public void GetParameters(ScenarioEventType Event)
        {
            // enter pointing to a <ParameterSetting> or there are no parameters
            if (reader.Name !="ParameterSetting")
            {    
                return;
             }
            reader.Read();// points to first  <Parameter> 
            while ("Parameter" == reader.Name)
            {
                ParameterSettingType nextSetting = GetParameterSetting();
                Event.Add(nextSetting);
            }
            // and move past the </ParameterSettings>
            reader.ReadEndElement();

        }
Exemplo n.º 7
0
        public static void NextTick()
        {
            while (readParse.sink.ShouldIWait())
            {
                Thread.Sleep(100);
            }
/* 1. Process the incoming list of events from below */
            // Which units are currently on the incoming list
            List <string> unitList = IncomingList.AffectedUnits();

            for (int i = 0; i < unitList.Count; i++)
            {
                List <IncomingItemType> eventList = IncomingList.Retrieve(unitList[i]);


                /* do things with these events */
                for (int j = 0; j < eventList.Count; j++)
                {
                    ScenarioEventType thisItem = eventList[j].TheEvent;
                    if (thisItem.GetType() == typeof(MoveComplete_Event))
                    {
                        Console.WriteLine("Unit {0} MoveComplete discovered at t={1}", thisItem.UnitID, timer);
                        // scan happenings list for matches
                        for (int h = HappeningList.Happenings.Count - 1; 0 <= h; h--)
                        {
                            ScenarioEventType incident = HappeningList.Happenings[h];
                            if (incident.UnitID == thisItem.UnitID)
                            {
                                ScenarioEventType newEvent = ((HappeningCompletionType)incident).DoThis;
                                newEvent.Timer = timer;
                                TimerQueueClass.Add(timer, newEvent);
                                HappeningList.Happenings.RemoveAt(h);
                            }
                        }    // all happenings affected by this Move_complete have been queued
                    }
                    else
                    {
                        Console.WriteLine("Unknown incoming list item {0}", thisItem.GetType());
                    }
                }

                Console.WriteLine("Unit {0} has {1} elements", unitList[i], eventList.Count);
                /* and then take them off the incoming list */
                List <int> indexList = new List <int>();
                for (int j = 0; j < eventList.Count; j++)
                {
                    indexList.Add(eventList[j].TheIndex);
                }
                IncomingList.RemoveUnit(indexList);
            }
/* 2. Send the tick */
            EventCommunicator.SendEvent(new TickEventType(timer));
/* 3. Pull the events for this tick off the queue and handle them */
            List <ScenarioEventType> events = TimerQueueClass.RetrieveEvents(timer);

            if (events != null)
            {
                for (int v = 0; v < events.Count; v++)
                {
                    EventCommunicator.SendEvent(events[v]);
                    //Console.WriteLine("Timer {0} unit {1} type {2}", timer, events[v].UnitID, events[v].GetType().FullName);
                }
            }


/* Very Last Thing                   */
            timer += 1;
        }
Exemplo n.º 8
0
 public HappeningCompletionType(string unit, string action, ScenarioEventType doThis)
     : base(unit)
 {
     this.action = action;
     this.doThis = doThis;
 }
Exemplo n.º 9
0
 public static void Add(int time, ScenarioEventType newEvent)
 {
     if (!queue.ContainsKey(time))
     {
         queue.Add(time, new TimeNodeClass(time));
     }
      queue[time].AddEvent(newEvent);           
 }
Exemplo n.º 10
0
 public static void Add(ScenarioEventType happeningEvent)
 {
     happenings.Add(happeningEvent);
 }
Exemplo n.º 11
0
 public HappeningCompletionType(string unit, string action, ScenarioEventType doThis)
     : base(unit)
 {
     this.action = action;
     this.doThis = doThis;
 }
Exemplo n.º 12
0
 public static void Add(ScenarioEventType e)
 {
     incoming.Add(e);
 }
Exemplo n.º 13
0
 public IncomingItemType(ScenarioEventType theEvent, int theIndex)
 {
     this.theEvent = theEvent;
     this.theIndex = theIndex;
 }
Exemplo n.º 14
0
        public static void Add(ScenarioEventType e)
        {
            incoming.Add(e);

        }
Exemplo n.º 15
0
 public IncomingItemType(ScenarioEventType theEvent, int theIndex)
 {
     this.theEvent = theEvent;
     this.theIndex = theIndex;
 }
Exemplo n.º 16
0
 public static void Add(ScenarioEventType happeningEvent)
 {
     happenings.Add(happeningEvent);
 }