Esempio 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);
 }
Esempio 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);
        }
Esempio 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;
         }
     }
 }
Esempio 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;
         }
     }
 }
Esempio 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();
 }
Esempio 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();

        }
Esempio 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;
        }
Esempio n. 8
0
 public HappeningCompletionType(string unit, string action, ScenarioEventType doThis)
     : base(unit)
 {
     this.action = action;
     this.doThis = doThis;
 }
Esempio 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);           
 }
Esempio n. 10
0
 public static void Add(ScenarioEventType happeningEvent)
 {
     happenings.Add(happeningEvent);
 }
Esempio n. 11
0
 public HappeningCompletionType(string unit, string action, ScenarioEventType doThis)
     : base(unit)
 {
     this.action = action;
     this.doThis = doThis;
 }
Esempio n. 12
0
 public static void Add(ScenarioEventType e)
 {
     incoming.Add(e);
 }
Esempio n. 13
0
 public IncomingItemType(ScenarioEventType theEvent, int theIndex)
 {
     this.theEvent = theEvent;
     this.theIndex = theIndex;
 }
Esempio n. 14
0
        public static void Add(ScenarioEventType e)
        {
            incoming.Add(e);

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