Example #1
0
        protected void GetComputedLandType(
            IntRect area,
            ref int[,] subAreaInt,
            int maxValue,
            out LandTransition landtransition)
        {
            bool[,] subAreaBool = new bool[3, 3];

            landtransition = LandTransition.NONE;

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

                landtransition = ALandLayerGenerator.GetLandTransitionFrom(ref subAreaBool);
            }
        }
        private void GetComputedLandType(
            ALandLayerGenerator altitudeLandLayerGenerator,
            IntRect area,
            int i, int j,
            out LandType landType,
            out LandType secondType,
            out LandTransition landtransition)
        {
            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 power = altitudeLandLayerGenerator.GetComputedPowerAt(j + x, i + y);

                    int currentValue = (int)this.GetLandTypeFromPower(power);

                    maxValue = Math.Max(maxValue, currentValue);

                    minValue = Math.Min(minValue, currentValue);

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

            landType       = (LandType)subAreaInt[1, 1];
            landtransition = LandTransition.NONE;
            secondType     = landType;

            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;
                        }
                    }
                }

                landtransition = ALandLayerGenerator.GetLandTransitionFrom(ref subAreaBool);

                if (landtransition != LandTransition.NONE)
                {
                    secondType = (LandType)maxValue;
                }
            }
        }
Example #3
0
        public static void GetComputedLandType(
            ALandLayerGenerator generator,
            IntRect area,
            int i, int j,
            out int mountainType,
            out int secondType,
            out LandTransition landtransition,
            out LandTransition secondLandtransition)
        {
            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 currentValue = generator.GetComputedPowerAt(j + x, i + y);

                    maxValue = Math.Max(maxValue, currentValue);

                    minValue = Math.Min(minValue, currentValue);

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

            mountainType         = subAreaInt[1, 1];
            landtransition       = LandTransition.NONE;
            secondLandtransition = LandTransition.NONE;
            secondType           = mountainType;

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

                            if (subAreaInt[y, x] != -1)
                            {
                                primaryType = subAreaInt[y, x];
                            }
                        }
                        else
                        {
                            subAreaBool[y, x] = true;
                        }
                    }
                }

                secondLandtransition = ALandLayerGenerator.GetLandTransitionFrom(ref subAreaBool);

                if (secondLandtransition != LandTransition.NONE)
                {
                    secondType = maxValue;
                }

                if (subAreaInt[1, 1] == -1 && primaryType != -1)
                {
                    mountainType = primaryType;

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

                    landtransition = ALandLayerGenerator.GetLandTransitionFrom(ref subAreaBool);
                }
            }
        }