Exemple #1
0
        private void UpdateScene(ReiterateEvent evt, bool simulate_motion)
        {
            lock (_scene)
            {
                MoveEvent move = evt.CurrentEvent();
                string unit_name = move.Name;

                Vector3 current = GetCurrentPosition(unit_name);
                if ((current != Vector3.Empty) && UnitMaxSpeeds.ContainsKey(unit_name))
                {
                    _scene.SelectPawn(unit_name);
                    if (simulate_motion)
                    {
                        // Move object and put into motion.
                        _scene.MoveSelected(current.X, current.Y);
                        if ((current.X != move.X) && (current.Y != move.Y))
                        {
                            _scene.MoveSelected(move.X, move.Y, (float)(EventSpeed(move) * (1000 / (float)SimSpeed)), new ThreadStart(evt.StartNextEvent));
                        }
                    }
                    else
                    {
                        _scene.MoveSelected(current.X, current.Y);
                    }
                    _scene.ClearPawnSelection();
                }
            }

        }
Exemple #2
0
 public void AddEvent(AbstractPreviewEvent scenario_event, ReiterateEvent reiterate)
 {
     if (scenario_event is MoveEvent)
     {
         reiterate.AddEvent((MoveEvent)scenario_event);
     }
 }
Exemple #3
0
        private void Reiterate(ReiterateEvent evt, int step_offset, bool SimMotion)
        {
            if (evt != ReiterateEvent.Empty)
            {
                MoveEvent current_move = evt.CurrentEvent();
                string unit_name = current_move.Name;
                int move_duration =  (int)(GetMoveDuration(current_move));
                if (step_offset <= move_duration)
                {
                    // We're in the middle of this move.
                    AGT_LinearMotion mc = CreateMotionCalculator(current_move);
                    SetCurrentPosition(unit_name,  mc,  step_offset);
                    UpdateScene(evt, SimMotion);

                }
                else if (step_offset > move_duration)
                {
                    // This move has already occurred, just advance to the next move
                    SetCurrentPosition(unit_name, current_move.X, current_move.Y, current_move.Z);
                    UpdateScene(evt, false);
                    evt.MoveToNextEvent();
                    Reiterate(evt, step_offset - move_duration, SimMotion);

                }
                return;
            }
                            
        }
 private void Xml_ReadReiterate(XPathNavigator navigator)
 {
     if (navigator != null)
     {
         ReiterateEvent reiterate = new ReiterateEvent();
         reiterate.Name = "Reiterate";
         reiterate.Parent = _sim;
         XPathNavigator time_node = navigator.SelectSingleNode(ReiterateEventTime_XPath);
         try
         {
             reiterate.Time = (int)Convert.ToDecimal(time_node.GetAttribute("value", time_node.NamespaceURI));
             Xml_ReadMoveEvent(navigator.Select(MoveEvent_XPath), reiterate);
             _sim.AddEvent(reiterate);
         }
         catch (Exception)
         {
             reiterate.Time = 0;
         }
     }
 }