Example #1
0
        private int NeedToFillAt(
            IntRect area,
            int i, int j)
        {
            bool[,] subAreaBool = new bool[3, 3];
            int[,] subAreaInt   = new int[3, 3];

            int maxValue = int.MinValue;
            int minValue = int.MaxValue;

            for (int y = -1; y < 2; y++)
            {
                for (int x = -1; x < 2; x++)
                {
                    int altitude = (int)this.GetPowerAt(new Vector2f(area.Left + j + x, area.Top + i + y));

                    maxValue = Math.Max(maxValue, altitude);

                    minValue = Math.Min(minValue, altitude);

                    subAreaInt[y + 1, x + 1] = altitude;
                }
            }

            bool needToFill = false;

            if (subAreaInt[1, 1] != maxValue)
            {
                for (int y = 0; y < 3; y++)
                {
                    for (int x = 0; x < 3; x++)
                    {
                        if (subAreaInt[y, x] != maxValue)
                        {
                            subAreaBool[y, x] = false;
                        }
                        else
                        {
                            subAreaBool[y, x] = true;
                        }
                    }
                }

                needToFill = ALandLayerGenerator.NeedToFill(ref subAreaBool);
            }

            if (needToFill)
            {
                return(maxValue);
            }
            return(subAreaInt[1, 1]);
        }
Example #2
0
        public void AddGenerator(int generatorPriority, ALandLayerGenerator generator)
        {
            this.generatorsSortedList.Add(generatorPriority, generator);

            this.generatorsDictionary.Add(generator.Name, generator);
        }