Exemplo n.º 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();
                }
            }

        }
Exemplo n.º 2
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;
            }
                            
        }