Пример #1
0
        internal RoadStationInfo EnsureStation(TownNode townNode)
        {
            if (this.stations.ContainsKey(townNode.TownId))
            {
                return(this.stations[townNode.TownId]);
            }

            var place = RoadStationBuilder.FindPlaceForStation(townNode.Location.Tile);

            AIRoad.BuildRoadStation(place.tile, place.entryPoint, AIRoad.ROADVEHTYPE_BUS, AIStation.STATION_NEW);
            AIRoad.BuildRoad(place.tile, place.entryPoint);
            this.stations.Add(townNode.TownId, place);
            return(place);
        }
Пример #2
0
        public static RoadStationInfo FindPlaceForStation(TileIndex tile)
        {
            var xx = AIMap.GetTileX(tile);
            var yy = AIMap.GetTileY(tile);

            for (var step = 1; step < 15; step++)
            {
                for (var i = 0; i < step * 2; i++)
                {
                    var x     = xx - step;
                    var y     = yy + Helper.Alternate(i);
                    var tile2 = AIMap.GetTileIndex(x, y);
                    var test  = RoadStationBuilder.TestPlaceForStation(tile2);
                    if (test != null)
                    {
                        return(test);
                    }

                    x     = xx - Helper.Alternate(i);
                    y     = yy + step;
                    tile2 = AIMap.GetTileIndex(x, y);
                    test  = RoadStationBuilder.TestPlaceForStation(tile2);
                    if (test != null)
                    {
                        return(test);
                    }

                    x     = xx + step;
                    y     = yy + Helper.Alternate(i);
                    tile2 = AIMap.GetTileIndex(x, y);
                    test  = RoadStationBuilder.TestPlaceForStation(tile2);
                    if (test != null)
                    {
                        return(test);
                    }

                    x     = xx + Helper.Alternate(i);
                    y     = yy - step;
                    tile2 = AIMap.GetTileIndex(x, y);
                    test  = RoadStationBuilder.TestPlaceForStation(tile2);
                    if (test != null)
                    {
                        return(test);
                    }
                }
            }

            return(null);
        }
Пример #3
0
        internal RoadStationInfo EnsureDepot(TownNode townNode)
        {
            if (this.depots.ContainsKey(townNode.TownId))
            {
                return(this.depots[townNode.TownId]);
            }

            var place = RoadStationBuilder.FindPlaceForStation(townNode.Location.Tile);

            if (place != null)
            {
                AIRoad.BuildRoadDepot(place.tile, place.entryPoint);
                AIRoad.BuildRoad(place.tile, place.entryPoint);
                this.depots.Add(townNode.TownId, place);
                return(place);
            }
            else
            {
                return(null);
            }
        }