Exemple #1
0
        public void StepThroughEvent(AbstractPreviewEvent scenario_event, int step_to, bool SimMotion)
        {

            if (scenario_event is RevealEvent)
            {
                RevealEvent evt = (RevealEvent)scenario_event;

                if (evt != RevealEvent.Empty)
                {
                    _scene.AddMapObject(evt.Name, evt.Icon, evt.X, evt.Y, evt.Z, System.Drawing.Color.FromName(evt.ColorName));
                    SetCurrentPosition(evt.Name, evt.X, evt.Y, evt.Z);
                    UpdateScene(evt);
                }
                return;
            }


            if (scenario_event is MoveEvent)
            {
                MoveEvent evt = (MoveEvent)scenario_event;
                AGT_LinearMotion motion_calculator = CreateMotionCalculator(evt);
                int move_duration = (int)GetMoveDuration(evt);
                if (motion_calculator != null)
                {
                    
                    if (step_to <= (evt.Time + move_duration))
                    {
                        // Interpolate position because we're in the middle of a move.
                        SetCurrentPosition(evt.Name, motion_calculator, step_to);                        
                    }
                    else
                    {
                        // We're not in the middle of this move, so just advance to the destination.
                        SetCurrentPosition(evt.Name, evt.X, evt.Y, evt.Z);
                    }
                    UpdateScene(evt, SimMotion);                    
             }
                return;
            }


            if (scenario_event is ReiterateEvent)
            {
                ReiterateEvent evt = (ReiterateEvent)scenario_event;
                evt.ResetIndex();
                Reiterate(evt, step_to, SimMotion);
            }
        }
Exemple #2
0
        public void ExecuteEvent(AbstractPreviewEvent scenario_event)
        {
            if (scenario_event is RevealEvent)
            {
                RevealEvent evt = (RevealEvent)scenario_event;
                lock (_scene)
                {
                    if (!_reveal_positions.ContainsKey(evt.Name))
                    {
                        _reveal_positions.Add(evt.Name, new Vector3(evt.X, evt.Y, evt.Z));
                    }
                    _scene.AddMapObject(evt.Name, evt.Icon, evt.X, evt.Y, evt.Z, System.Drawing.Color.FromName(evt.ColorName));
                }
                return;
            }

            if (scenario_event is MoveEvent)
            {
                if (!_unit_list.Contains(scenario_event.Name))
                {
                    _unit_list.Add(scenario_event.Name);
                }
                MoveEvent evt = (MoveEvent)scenario_event;
                DoMove(evt, null);
                return;
            }

            if (scenario_event is ReiterateEvent)
            {
                ReiterateEvent evt = (ReiterateEvent)scenario_event;
                evt.ResetIndex();
                MoveEvent move = evt.CurrentEvent();

                DoMove(move, new System.Threading.ThreadStart(evt.StartNextEvent));
                _scene.ClearPawnSelection();

                return;
            }

        }
Exemple #3
0
 public void AddEvent(AbstractPreviewEvent scenario_event)
 {
     if (!_scenario.ContainsKey(scenario_event.Time))
     {
         _scenario.Add(scenario_event.Time, new List<AbstractPreviewEvent>());
     }
     _scenario[scenario_event.Time].Add(scenario_event);
 }
Exemple #4
0
 public void AddEvent(AbstractPreviewEvent scenario_event, ReiterateEvent reiterate)
 {
     if (scenario_event is MoveEvent)
     {
         reiterate.AddEvent((MoveEvent)scenario_event);
     }
 }
        private void Xml_ReadMoveEvent(XPathNodeIterator iterator, AbstractPreviewEvent abstract_event)
        {
            int last_move_timetick = -1;

            if (iterator != null)
            {
                foreach (XPathNavigator move_node in iterator)
                {
                    MoveEvent move_event = new MoveEvent();

                    move_event.MoveDuration = -1;

                    move_event.ID = move_node.GetAttribute("ID", move_node.NamespaceURI);
                    move_event.Name = GetUnitName(Convert.ToInt32(move_event.ID));

                    XPathNavigator time_node = move_node.SelectSingleNode(MoveEventTime_XPath);
                    try
                    {
                        move_event.Time = (int)Convert.ToDecimal(time_node.GetAttribute("value", time_node.NamespaceURI));
                    }
                    catch (Exception)
                    {
                        move_event.Time = 0;
                    }


                    XPathNavigator throttle_node = move_node.SelectSingleNode(MoveEventThrottle_XPath);
                    try
                    {
                        move_event.Throttle = (float)(Convert.ToDecimal(throttle_node.GetAttribute("value", throttle_node.NamespaceURI)));
                    }
                    catch (Exception)
                    {
                        move_event.Throttle = 100f;
                    }

                    XPathNavigator x_node = move_node.SelectSingleNode(MoveEventDestX_XPath);
                    try
                    {
                        move_event.X = (float)(Convert.ToDouble(x_node.GetAttribute("value", x_node.NamespaceURI)));
                        move_event.X = UTM_Mapping.HorizontalMetersToPixels(move_event.X);
                    }
                    catch (Exception)
                    {
                        move_event.X = 0f;
                    }

                    XPathNavigator y_node = move_node.SelectSingleNode(MoveEventDestY_XPath);
                    try
                    {
                        move_event.Y = (float)(Convert.ToDouble(y_node.GetAttribute("value", y_node.NamespaceURI)));
                        move_event.Y = UTM_Mapping.VerticalMetersToPixels(move_event.Y);
                    }
                    catch (Exception)
                    {
                        move_event.Y = 0f;
                    }

                    move_event.Z = 0f;

                    if (last_move_timetick >= 0)
                    {
                        MoveEvent mv = _sim.FindMoveEvent(last_move_timetick, move_event.Name);
                        if (mv != MoveEvent.Empty)
                        {
                            mv.MoveDuration = move_event.Time - mv.Time;
                        }
                    }

                    if (abstract_event == null)
                    {
                        _sim.AddEvent(move_event);
                    }
                    else
                    {
                        if (abstract_event is ReiterateEvent)
                        {
                            _sim.AddEvent(move_event, (ReiterateEvent)abstract_event);
                        }
                    }
                    last_move_timetick = move_event.Time;
                }
            }
        }