Пример #1
0
        // передаем маршрут
        public virtual void StartMove(List <MapCell> route)
        {
            //  не складывает методы --  null
            //if(OnMadeAction!=null)
            //OnMadeAction();
            OnActionMade?.Invoke(true);


            if (dt != null)
            {
                dt.Stop();
            }
            _route = route;
            Utils.FieldUtils.PaintCells(_route, true);
            if (route.Count > 0)
            {
                _currentRouteIndex = 0;
                _targetPoint       = GetUnitRectanglePosition(this,
                                                              _route[0].MapRectangle.Width,
                                                              _route[0].MapRectangle.Height,
                                                              _route[0].RectangleCoords.X,
                                                              _route[0].RectangleCoords.Y);

                double left = Canvas.GetLeft(UnitRectangle);
                double top  = Canvas.GetTop(UnitRectangle);

                _interval.X = (_targetPoint.X - left) / 40;
                _interval.Y = (_targetPoint.Y - top) / 40;


                dt          = new System.Windows.Threading.DispatcherTimer();
                dt.Interval = new TimeSpan(0, 0, 0, 0, 10);
                dt.Tick    += Move;
                dt.Start();
            }
            //ThreadStart threadStart = new ThreadStart(Move);
            //Thread t = new Thread(threadStart);
            //t.Start();
        }
Пример #2
0
 public void StopMove()
 {
     Utils.FieldUtils.PaintCells(_route, false);
     dt.Stop();
     OnActionMade?.Invoke(false);
 }