Пример #1
0
        public bool ProcessTurn(int playerX, int playerY)
        {
            _map.SetWalkable(Position.X, Position.Y, true);
            _map.SetVisible(Position.X, Position.Y, true);

            _fovMap.CalculateFoV(Position.X, Position.Y, SightRadius);

            if (_fovMap.IsVisible(playerX, playerY))
            {
                _fovMap.ComputePath(Position.X, Position.Y, playerX, playerY);
            }

            int wantX;
            int wantY;

            if (!_fovMap.PathAvailable())
            {
                do
                {
                    wantX = Position.X;
                    wantY = Position.Y;
                    RHelper.MoveInDirection(ref wantY, ref wantX, RHelper.GetRandomDirection());
                } while (!_fovMap.IsWalkable(wantX, wantY));
            }
            else
            {
                wantX = _position.X;
                wantY = _position.Y;
                _fovMap.WalkPath(ref wantX, ref wantY);
            }

            _position.X = wantX;
            _position.Y = wantY;

            var onPlayer = playerX == _position.X && playerY == _position.Y;

            _map.SetWalkable(_position.X, _position.Y, onPlayer);
            _map.SetVisible(_position.X, _position.Y, onPlayer);

            return(onPlayer);
        }
Пример #2
0
 private void RecaclulateFoV()
 {
     _fovMap.CalculateFoV(_position.X, _position.Y,
                          (int)(_map[_position.Y, _position.X].Is(RCell.Dark) ? _viewRadius / 2d : _viewRadius));
 }