Esempio n. 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);
        }
Esempio n. 2
0
 public bool CanSee(int x, int y)
 {
     return(_fovMap.IsVisible(x, y));
 }