/// <summary>
        /// Add a fromBuilding to the source buildings owners graph, 
        /// the source fromBuilding will be used to find the correct graph.
        /// </summary>
        /// <param name="buildingType">The type of fromBuilding to build.</param>
        /// <param name="sourceBuilding">The fromBuilding used to build this fromBuilding.</param>
        /// <param name="targetCoordinate">The tile coordinates where the fromBuilding will be built.</param>
        /// <param name="world">The world to build the fromBuilding in.</param>
        public static bool AddBuilding(Globals.BuildingTypes buildingType,
            Building sourceBuilding, Vector2 targetCoordinate, World world, Player owner)
        {
            if (sourceBuilding != null && buildingType != Globals.BuildingTypes.Base && (Math.Abs(((int)sourceBuilding.position.X) - (int)targetCoordinate.X) > MAX_BUILDING_RANGE || (Math.Abs(((int)sourceBuilding.position.Y) - (int)targetCoordinate.Y) > MAX_BUILDING_RANGE)))
            {
                logger.Debug("Building position out of range");
                throw new BuildingOutOfRangeException();
            }
            uint price = owner.unitAcc.CalculateBuildingCostInflation(buildingType);
            if (sourceBuilding != null && (uint)sourceBuilding.CountUnits() < price)
            {
                logger.Debug("Building too expensive");
                return false;
            }

            logger.Info("Building a building at position "+targetCoordinate+" of "+buildingType+".");

            lock (owner.GetGraphs())
            {
                LinkedList<Tile> controlZone = CreateControlZone(targetCoordinate, world);
                //The Base building is handled in another way due to it's nature.
                if (buildingType == Globals.BuildingTypes.Base)
                {
                    logger.Trace("Adding a Base Building and also constructing a new graph");
                    BaseBuilding baseBuilding = new BaseBuilding("Base Buidling",
                    (int)targetCoordinate.X, (int)targetCoordinate.Y, owner, controlZone);

                    world.map.GetTile((int)targetCoordinate.X, (int)targetCoordinate.Y).SetBuilding(baseBuilding);

                    owner.AddGraph(GraphController.Instance.AddBaseBuilding(baseBuilding, sourceBuilding));
                }
                else
                {
                    //The other buildings constructs in similiar ways but they are constructed
                    //as the specified type.
                    Building newBuilding = null;
                    switch (buildingType)
                    {
                        case Globals.BuildingTypes.Aggressive:
                            logger.Trace("Building a new Aggressive building");
                            newBuilding = new AggressiveBuilding("Aggresive Building",
                                (int)targetCoordinate.X, (int)targetCoordinate.Y, owner,
                                GraphController.Instance.GetGraph(sourceBuilding).baseBuilding, controlZone);
                            break;
                        case Globals.BuildingTypes.Barrier:
                            logger.Trace("Building a new Barrier building");
                            newBuilding = new BarrierBuilding("Barrier Building",
                                (int)targetCoordinate.X, (int)targetCoordinate.Y, owner,
                                GraphController.Instance.GetGraph(sourceBuilding).baseBuilding, controlZone);
                            break;
                        case Globals.BuildingTypes.Resource:
                            logger.Trace("Building a new Resource building");
                            newBuilding = new ResourceBuilding("Resource Building",
                                (int)targetCoordinate.X, (int)targetCoordinate.Y, owner,
                                GraphController.Instance.GetGraph(sourceBuilding).baseBuilding, controlZone);
                            break;
                    }

                    world.map.GetTile((int)targetCoordinate.X, (int)targetCoordinate.Y).SetBuilding(newBuilding);
                    newBuilding.Parent = sourceBuilding;
                    GraphController.Instance.AddBuilding(sourceBuilding, newBuilding);
                }
                if (sourceBuilding != null && world.map.GetTile((int)targetCoordinate.X, (int)targetCoordinate.Y).GetBuilding() != null)
                {
                    logger.Info("The building has " + sourceBuilding.CountUnits() + " and the building costs " + price);
                    owner.unitAcc.DestroyUnits(sourceBuilding.units, (int)price);
                    logger.Info("The source building only got " + sourceBuilding.CountUnits() + " units left.");
                }
                else if (world.map.GetTile((int)targetCoordinate.X, (int)targetCoordinate.Y).GetBuilding() == null)
                {
                    throw new Exception("A building was not placed on the tile even though it should have been.");
                }

                SoundsController.playSound("buildingPlacement");
            }

            // Let's update the fog of war!
            /*
            for (int i = -3; i <= 3; i++)
            {
                for (int j = -3; j <= 3; j++)
                {
                    try
                    {
                        world.map.GetTile((int)targetCoordinate.X + j, (int)targetCoordinate.Y + i).MakeVisibleTo(owner);
                    }
                    catch(IndexOutOfRangeException e)
                    {
                    }
                }
            }
             */
            return true;
        }
 /// <summary>
 /// Search all the controlZone tiles for enemy units,
 /// then set them as a Target for the AggressiveBuilding.
 /// </summary>
 /// <param name="b"></param>
 private static void AttackTargets(AggressiveBuilding b)
 {
     logger.Trace("Attacking targets around a aggressive building at x: "+b.position.X+" y: "+b.position.Y );
     foreach (Unit u in b.currentTargets)
     {
         new KamikazeUnit(b.owner, b.position, u);
     }
     logger.Trace("Killing " + b.currentTargets.Count + " units.");
     //UnitController.MarkUnitsAsDead(b.currentTargets, b.currentTargets.Count);
     b.currentTargets.Clear();
 }