Aurora.Modules.CityBuilder.CityMap.ClaimPlot C# (CSharp) Метод

ClaimPlot() публичный Метод

This method will lay claim to a plot of land in the city map. Find the associated plot in the internal plot list and claim it, if the plot is not found then add it to the list.
public ClaimPlot ( BuildingPlot plot ) : bool
plot BuildingPlot
Результат bool
        public bool ClaimPlot(BuildingPlot plot)
        {
            if (plot.Equals(null))
                return (false);

            if (isPlotClaimed(plot))
                return (false);

            //  Search the list.
            if (cityPlots.Count > 0)
            {
                foreach (BuildingPlot p in cityPlots)
                {
                    if (p.Equals(plot))
                    {
                        if (p.PlotClaimType == PlotClaimType.CLAIM_NONE)
                            p.PlotClaimType = PlotClaimType.CLAIM_PARK;
                        return (true);
                    }
                }
            }

            //  If we are here then the plot has not been found so add it as new plot.
            cityPlots.Add(plot);

            return (true);
        }

Usage Example

Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="x1"></param>
        /// <param name="?"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        private void doRoad(int x1, int y1, int width, int depth)
        {
            int lanes;
            int divider;
            int sidewalk;

            if (width > depth)
            {
                lanes = depth;
            }
            else
            {
                lanes = width;
            }
            if (lanes < 4)
            {
                return;
            }
            bool odd = false;
            int  i   = (lanes % 2);

            if (i > 0)
            {
                odd = true;
            }
            if (odd)//lanes % 2)
            {
                lanes--;
                divider = 1;
            }
            else
            {
                divider = 0;
            }
            sidewalk  = 2;// MAX(2, (lanes - 10));
            lanes    -= sidewalk;
            sidewalk /= 2;
            lanes    /= 2;
            cityMap.ClaimPlot(cityMap.MakePlot(x1, y1, width, depth, PlotClaimType.CLAIM_NONE));
            if (width > depth)
            {
                cityMap.ClaimPlot(cityMap.MakePlot(x1, y1 + sidewalk, width, lanes, PlotClaimType.CLAIM_TRANSPORT));
                cityMap.ClaimPlot(cityMap.MakePlot(x1, y1 + sidewalk + lanes + divider, width, lanes, PlotClaimType.CLAIM_TRANSPORT));
            }
            else
            {
                cityMap.ClaimPlot(cityMap.MakePlot(x1 + sidewalk, y1, lanes, depth, PlotClaimType.CLAIM_TRANSPORT));
                cityMap.ClaimPlot(cityMap.MakePlot(x1 + sidewalk + lanes + divider, y1, lanes, depth, PlotClaimType.CLAIM_TRANSPORT));
            }
        }