public InfluenceSourceMap ShiftInfluenceSourceMap(InfluenceSourceMap map, Coords newSource)
        {
            Int32 lengthX = map.Map.GetLength(0);
            Int32 lengthY = map.Map.GetLength(1);

            Coords delta = newSource - map.Source;

            float[,] returnMap = new float[lengthX, lengthY];

            InfluenceSourceMap returnVal = new InfluenceSourceMap((UInt16)lengthX, (UInt16)lengthY, newSource, map.EffectiveDistance);

            for (int i = 0; i < lengthX; ++i)
            {
                for (int j = 0; j < lengthY; ++j)
                {
                    Int32 shiftedX = i - delta.X;
                    Int32 shiftedY = j - delta.Y;

                    if (shiftedX >= 0 && shiftedX < lengthX && shiftedY >= 0 && shiftedY < lengthY)
                    {
                        returnMap[i, j] = map.Map[i - delta.X, j - delta.Y];
                    }
                }
            }

            returnVal.Map = returnMap;
            return(returnVal);
        }
        /*
         * /// <summary>
         * /// Performs a terrain passability check betwee two points by doing pixel validity checks at interval delta.
         * /// </summary>
         * public CollisionType RayTracerPassabilityCheckRough(Footballer client, Vector v1, Vector v2, double delta)
         * {
         *  Vector difference = v2-v1;
         *  Vector deltaV = difference;
         *  deltaV.ScaleToLength(delta);
         *
         *  Vector currentPosition = v1;
         *
         *  for (int i = 0; i < difference.Length() / deltaV.Length(); ++i)
         *  {
         *      Coords pixel = new Coords(currentPosition);
         *      currentPosition += deltaV;
         *  }
         *
         *  return CollisionType.None;
         * }
         *
         * /// <summary>
         * /// Returns the Bresenham line between p0 and p1; Borrowed the code
         * /// from some dude whose name I don't have, who in turn borrowed from Wikipedia.
         * /// </summary>
         * private List<Coords> BresenhamLine(Coords p0, Coords p1)
         * {
         *  List<Coords> returnList = new List<Coords>();
         *
         *  Boolean steep = Math.Abs(p1.Y - p0.Y) > Math.Abs(p1.X - p0.X);
         *
         *  if (steep == true)
         *  {
         *      Coords tmpPoint = new Coords(CoordsType.Tile,p0.X, p0.Y);
         *      p0 = new Coords(CoordsType.Tile,tmpPoint.Y, tmpPoint.X);
         *
         *      tmpPoint = p1;
         *      p1 = new Coords(CoordsType.Tile,tmpPoint.Y, tmpPoint.X);
         *  }
         *
         *  Int32 deltaX = Math.Abs(p1.X - p0.X);
         *  Int32 deltaY = Math.Abs(p1.Y - p0.Y);
         *  Int32 error = 0;
         *  Int32 deltaError = deltaY;
         *  Int32 yStep = 0;
         *  Int32 xStep = 0;
         *  Int32 y = p0.Y;
         *  Int32 x = p0.X;
         *
         *  if (p0.Y < p1.Y)
         *  {
         *      yStep = 1;
         *  }
         *  else
         *  {
         *      yStep = -1;
         *  }
         *
         *  if (p0.X < p1.X)
         *  {
         *      xStep = 1;
         *  }
         *  else
         *  {
         *      xStep = -1;
         *  }
         *
         *  Int32 tmpX = 0;
         *  Int32 tmpY = 0;
         *
         *  while (x != p1.X)
         *  {
         *
         *      x += xStep;
         *      error += deltaError;
         *
         *      //if the error exceeds the X delta then
         *      //move one along on the Y axis
         *      if ((2 * error) > deltaX)
         *      {
         *          y += yStep;
         *          error -= deltaX;
         *      }
         *
         *      //flip the coords if they're steep
         *      if (steep)
         *      {
         *          tmpX = y;
         *          tmpY = x;
         *      }
         *      else
         *      {
         *          tmpX = x;
         *          tmpY = y;
         *      }
         *
         *      //check the point generated is legal
         *      //and if it is add it to the list
         *      if (this.CheckInBounds(new Coords(CoordsType.Tile,tmpX, tmpY)) == true)
         *      {
         *          returnList.Add(new Coords(CoordsType.Tile,tmpX, tmpY));
         *      }
         *      else
         *      {   //a bad point has been found, so return the list thus far
         *          return returnList;
         *      }
         *
         *  }
         *
         *  return returnList;
         * }
         */
        #endregion

        #region Item / Footballer spawners

        /// <summary>
        /// Spawns the player on the 'ground' at 'startPoint'
        /// returns a reference to the Player so one can more easily take care of references.
        /// </summary>
        public Footballer SpawnFootballer(Vector2d startPoint, Vector2d defaultPlayingPosition, Team team)
        {
            Footballer newGuy = new Footballer(this, startPoint, defaultPlayingPosition, this.IssueFootballerID(), team);

            Coords             infMapPosition = new Coords((Int32)(startPoint.X / Constants.InfMapDefaultBoxSizeX), (Int32)(startPoint.Y / Constants.InfMapDefaultBoxSizeY));
            InfluenceSourceMap updater        = _infMapGenerator.ShiftInfluenceSourceMap(_defaultInfSourceMap, infMapPosition);

            newGuy.Team.TeamInfluenceMap.Add(updater);
            //_teamInfluenceMaps[(sbyte)team].Add( updater);
            newGuy.PositionAtLastInfMapUpdate = infMapPosition;

            return(newGuy);
        }
        /// <summary>
        /// The passed 'updater' is generic. It was added to the 'map' at oldsource. We want to substract it, and add it at
        /// newSource.
        /// </summary>
        public void UpdateMapViaSourceMap(InfluenceMap map, InfluenceSourceMap updater, Coords oldSource, Coords newSource)
        {
            if (oldSource == newSource)
            {
                return;
            }

            InfluenceSourceMap oldInfMap = ShiftInfluenceSourceMap(updater, oldSource);
            InfluenceSourceMap newInfMap = ShiftInfluenceSourceMap(updater, newSource);

            map.Substract(oldInfMap);
            map.Add(newInfMap);
        }
        // Constructs an xSize by ySize map. Default Tile set to TileBasicFloor.
        public Map(Int32 seed)
        {
            // creates and fills the tile array
            this._xMax = Constants.MapSizeX;
            this._yMax = Constants.MapSizeY;

            // Calculates maximal bounds in pixels.
            this._pixelMaxX = 0;
            for (Int32 i = 0; i < Constants.MapSizeX; ++i)
            {
                _pixelMaxX += Constants.TileSizesX[i];
            }
            this._pixelMaxY = (UInt32)(Constants.MapSizeY);
            for (Int32 i = 0; i < Constants.MapSizeY; ++i)
            {
                _pixelMaxY += Constants.TileSizesY[i];
            }

            // Constructs the field.
            _tiles = new Tile[Constants.MapSizeX, Constants.MapSizeY];
            for (Int32 i = 0; i < Constants.MapSizeX; i++)
            {
                for (Int32 j = 0; j < Constants.MapSizeY; j++)
                {
                    _tiles[i, j] = new Tile(this, new Coords(i, j), (SpriteTile)(i + j * Constants.MapSizeX));
                }
            }

            // initializes collider
            this._myCollider = new Collider(Constants.BoxesInX, Constants.BoxesInY, Constants.PixelsPerBoxX, Constants.PixelsPerBoxY);

            // intialize influence map generator
            this._infMapGenerator = new InfluenceMapGenerator();

            // initialize default source map
            this._defaultInfSourceMap = new InfluenceSourceMap(Constants.InfMapDefaultX, Constants.InfMapDefaultY,
                                                               new Coords(Constants.InfMapDefaultX / 2, Constants.InfMapDefaultY / 2), Constants.InfluenceMapMaxDistance);
            this._defaultInfSourceMap.Map = this.InfMapGenerator.GenerateInfluenceMap(Constants.InfMapDefaultX, Constants.InfMapDefaultY,
                                                                                      new Coords(Constants.InfMapDefaultX / 2, Constants.InfMapDefaultY / 2), StaticMathFunctions.InfluenceDecayFunctionLinear);

            //this._teamInfluenceMaps[0] = new InfluenceMap(Constants.InfMapDefaultX, Constants.InfMapDefaultY);
            //this._teamInfluenceMaps[1] = new InfluenceMap(Constants.InfMapDefaultX, Constants.InfMapDefaultY);

            // initializes the random number generator associated with this map
            this._randomator = new RandomStuff(seed);
        }