示例#1
0
        public void InitializeMap(ZoneDeplacement zone)
        {
            _tMax._width  = _tMax._width / _ecart._x;
            _tMax._height = _tMax._height / _ecart._y;

            this._map = new bool[_tMax._width, _tMax._height];

            for (int y = 0; y < _tMax._height; y++)
            {
                for (int x = 0; x < _tMax._width; x++)
                {
                    if (zone.Contains(new Vector2(x * _ecart._x + _mapPosStart, y * _ecart._y)))
                    {
                        _map[x, y] = true;
                    }
                    else
                    {
                        _map[x, y] = false;
                    }
                }
            }

            //Position final sur l'écran ( x32 ) -posStart pour x
            int startX = (int)(_trajet.GetFirstPosition().X - _mapPosStart);
            int startY = (int)(_trajet.GetFirstPosition().Y);

            int endX = (int)(_trajet.GetLastPosition().X - _mapPosStart);
            int endY = (int)(_trajet.GetLastPosition().Y);

            _endLocation   = new System.Drawing.Point(endX / _ecart._x, endY / _ecart._y);
            _startLocation = new System.Drawing.Point(startX / _ecart._x, startY / _ecart._y);

            _searchParameters = new SearchParameters(_startLocation, _endLocation, _map);
        }
示例#2
0
        public bool Place(MouseState souris, KeyboardState state, GameTime gameTime)
        {
            this._time += (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (_time > 0.16f)
            {
                if ((souris.LeftButton == ButtonState.Pressed || state.IsKeyDown(Keys.Space)))
                {
                    if (_zone.Contains(_position))
                    {
                        _unit._position = _position;
                        _unit._placer   = true;
                        return(true);
                    }
                    return(true);
                }
            }
            return(false);
        }