Beispiel #1
0
        internal bool BuildRoad(IRoad activeRoad)
        {
            if (activeRoad == null)
                return false;

            if (activeRoad.Build() != null)
            {
                freeRoadPlaces.Remove(activeRoad);

                foreach (ITown town in activeRoad.GetITown())
                {
                    if (town.GetIOwner() != mapController.GetPlayerMe() && town.GetIOwner() != null)
                        continue;

                    for (byte loop1 = 0; loop1 < 3; loop1++)
                    {
                        IRoad road = town.GetIRoad(loop1);

                        if (road != null)
                        {
                            RoadBuildError tempError = road.CanBuildRoad();
                            if (tempError == RoadBuildError.OK ||
                                tempError == RoadBuildError.NoSources)
                            {
                                if (!freeRoadPlaces.Contains(road))
                                {
                                    freeRoadPlaces.Add(road);
                                }
                            }
                        }
                    }

                    if (town.IsPossibleToBuildTown())
                    {
                        freeTownPlaces.Remove(town);
                        freeTownPlaces.Add(town);
                    }
                }
                return true;
            }
            else
            {
                freeRoadPlaces.Remove(activeRoad);
                throw new Exception("Buidling road. " + mapController.GetLastError());
                //return false;
            }
        }