Пример #1
0
        public static void MakeMoat(int intFarmSize, int intMapSize, string strMoatType, bool booIncludeGuardTowers)
        {
            if (strMoatType == "Random")
            {
                int intRand = RandomHelper.Next(100);
                if (intRand >= 90)
                {
                    strMoatType = "Drop to Bedrock";
                }
                else if (intRand >= 80)
                {
                    strMoatType = "Cactus";
                }
                else if (intRand >= 50)
                {
                    strMoatType = "Lava";
                }
                else
                {
                    strMoatType = "Water";
                }
            }
            switch (strMoatType)
            {
            case "Drop to Bedrock":
                for (int a = intFarmSize - 1; a <= intFarmSize + 5; a++)
                {
                    BlockShapes.MakeHollowLayers(a, intMapSize - a, 2, 63, a, intMapSize - a, (int)BlockType.AIR, 0, -1);
                }
                break;

            case "Cactus":
                for (int a = intFarmSize - 1; a <= intFarmSize + 5; a++)
                {
                    BlockShapes.MakeHollowLayers(a, intMapSize - a, 59, 63, a, intMapSize - a, (int)BlockType.AIR, 0, -1);
                    BlockShapes.MakeHollowLayers(a, intMapSize - a, 58, 58, a, intMapSize - a, (int)BlockType.SAND, 0, -1);
                }
                for (int a = intFarmSize + 1; a <= intMapSize / 2; a += 2)
                {
                    BlockShapes.MakeBlock(a, 59, intFarmSize + 1, (int)BlockType.CACTUS, 2, 100, -1);
                    BlockShapes.MakeBlock(a, 59, intFarmSize + 3, (int)BlockType.CACTUS, 2, 100, -1);
                    BlockShapes.MakeBlock(a, 60, intFarmSize + 1, (int)BlockType.CACTUS, 2, 50, -1);
                    BlockShapes.MakeBlock(a, 60, intFarmSize + 3, (int)BlockType.CACTUS, 2, 50, -1);
                }
                for (int a = intFarmSize; a <= intMapSize / 2; a += 2)
                {
                    BlockShapes.MakeBlock(a, 59, intFarmSize, (int)BlockType.CACTUS, 2, 100, -1);
                    BlockShapes.MakeBlock(a, 59, intFarmSize + 2, (int)BlockType.CACTUS, 2, 100, -1);
                    BlockShapes.MakeBlock(a, 59, intFarmSize + 4, (int)BlockType.CACTUS, 2, 100, -1);
                    BlockShapes.MakeBlock(a, 60, intFarmSize, (int)BlockType.CACTUS, 2, 50, -1);
                    BlockShapes.MakeBlock(a, 60, intFarmSize + 2, (int)BlockType.CACTUS, 2, 50, -1);
                    BlockShapes.MakeBlock(a, 60, intFarmSize + 4, (int)BlockType.CACTUS, 2, 50, -1);
                }
                if (booIncludeGuardTowers)
                {
                    for (int a = intFarmSize + 3; a <= intFarmSize + 13; a += 2)
                    {
                        BlockShapes.MakeBlock(a, 59, intFarmSize + 3, (int)BlockType.AIR, 2, 100, -1);
                        BlockShapes.MakeBlock(a, 60, intFarmSize + 3, (int)BlockType.AIR, 2, 100, -1);
                    }
                }
                break;

            case "Lava":
                for (int a = intFarmSize - 1; a <= intFarmSize + 5; a++)
                {
                    BlockShapes.MakeHollowLayers(a, intMapSize - a, 62, 63, a, intMapSize - a, (int)BlockType.AIR, 0, -1);
                }
                for (int a = intFarmSize - 1; a <= intFarmSize + 5; a++)
                {
                    BlockShapes.MakeHollowLayers(a, intMapSize - a, 59, 61, a, intMapSize - a, (int)BlockType.LAVA, 0, -1);
                }
                break;

            case "Water":
                for (int a = intFarmSize - 1; a <= intFarmSize + 5; a++)
                {
                    BlockShapes.MakeHollowLayers(a, intMapSize - a, 59, 63, a, intMapSize - a, (int)BlockType.WATER, 0, -1);
                }
                break;
            }
        }
Пример #2
0
        private static int[,] FillArea(int[,] intArea, int intSizeX, int intSizeZ,
                                       int intStartX, int intStartZ, bool booUniqueBonus)
        {
            int[,] intDistrict = new int[intSizeX, intSizeZ];
            int[,] intFinal    = new int[intSizeX, intSizeZ];
            int        intWasted = intSizeX * intSizeZ, intAttempts = 15, intFail = 0;
            int        intBonus              = 0;
            List <int> lstBuildings          = new List <int>();
            List <int> lstAcceptedBuildings  = new List <int>();
            bool       booAreaNeedsMineshaft = false;

            do
            {
                lstBuildings.Clear();
                intBonus = 0;
                if (!_booIncludedMineshaft)
                {
                    booAreaNeedsMineshaft = true;
                }
                do
                {
                    SourceWorld.Building CurrentBuilding;
                    if (booAreaNeedsMineshaft)
                    {
                        CurrentBuilding = SourceWorld.SelectRandomBuilding(SourceWorld.BuildingTypes.MineshaftEntrance, 0);
                        // mineshaft is always the first building, so therefore it will always be possible to place it
                        booAreaNeedsMineshaft = false;
                    }
                    else
                    {
                        do
                        {
                            CurrentBuilding = SourceWorld.SelectRandomBuilding(SourceWorld.BuildingTypes.City, 0);
                        } while (!IsValidBuilding(CurrentBuilding, lstBuildings, intArea,
                                                  intStartX, intStartZ, intSizeX, intSizeZ));
                    }
                    bool booFound = false;
                    if (RandomHelper.NextDouble() > 0.5)
                    {
                        intDistrict = Utils.RotateArray(intDistrict, RandomHelper.Next(4));
                    }
                    int x, z = 0;
                    for (x = 0; x < intDistrict.GetLength(0) - CurrentBuilding.intSizeX && !booFound; x++)
                    {
                        for (z = 0; z < intDistrict.GetLength(1) - CurrentBuilding.intSizeZ && !booFound; z++)
                        {
                            booFound = Utils.IsArraySectionAllZeros2D(intDistrict, x, z, x + CurrentBuilding.intSizeX, z + CurrentBuilding.intSizeZ);
                        }
                    }
                    x--;
                    z--;
                    if (booFound)
                    {
                        for (int a = x + 1; a <= x + CurrentBuilding.intSizeX - 1; a++)
                        {
                            for (int b = z + 1; b <= z + CurrentBuilding.intSizeZ - 1; b++)
                            {
                                intDistrict[a, b] = 2;
                            }
                        }
                        if (CurrentBuilding.booUnique && booUniqueBonus)
                        {
                            // we want to include the unique buildings,
                            //   so we give a slight preference to those

                            intBonus += 15;
                        }
                        lstBuildings.Add(CurrentBuilding.intID);
                        intDistrict[x + 1, z + 1] = 100 + CurrentBuilding.intID;
                        intDistrict[x + CurrentBuilding.intSizeX - 1,
                                    z + CurrentBuilding.intSizeZ - 1] = 100 + CurrentBuilding.intID;
                        intFail = 0;
                    }
                    else
                    {
                        intFail++;
                    }
                } while (intFail < 10);

                int intCurWasted = Utils.ZerosInArray2D(intDistrict) - intBonus;
                if (intCurWasted < intWasted)
                {
                    intFinal = new int[intDistrict.GetLength(0), intDistrict.GetLength(1)];
                    Array.Copy(intDistrict, intFinal, intDistrict.Length);
                    intWasted   = intCurWasted;
                    intAttempts = 10;
                    lstAcceptedBuildings.Clear();
                    lstAcceptedBuildings.AddRange(lstBuildings);
                }
                Array.Clear(intDistrict, 0, intDistrict.Length);
                intAttempts--;
            } while (intAttempts > 0);
            if (intSizeX == intFinal.GetLength(1))
            {
                intFinal = Utils.RotateArray(intFinal, 1);
            }
            _lstAllBuildings.AddRange(lstAcceptedBuildings);
            _booIncludedMineshaft = true;
            return(intFinal);
        }
Пример #3
0
        public static void MakeGuardTowers(BlockManager bm, int intFarmLength, int intMapLength, bool booIncludeWalls,
                                           string strOutsideLights, string strTowerAddition,
                                           bool booIncludeItemsInChests, int intWallMaterial)
        {
            // remove wall
            BlockShapes.MakeSolidBox(intFarmLength + 5, intFarmLength + 11, 64, 79,
                                     intFarmLength + 5, intFarmLength + 11, BlockType.AIR, 1);
            // add tower
            BlockShapes.MakeHollowBox(intFarmLength + 4, intFarmLength + 12, 63, 80,
                                      intFarmLength + 4, intFarmLength + 12, intWallMaterial, 1, -1);
            // divide into two rooms
            BlockShapes.MakeSolidBox(intFarmLength + 4, intFarmLength + 12, 2, 72,
                                     intFarmLength + 4, intFarmLength + 12, intWallMaterial, 1);
            BlockShapes.MakeSolidBox(intFarmLength + 5, intFarmLength + 11, 64, 67,
                                     intFarmLength + 5, intFarmLength + 11, BlockType.AIR, 1);
            switch (strOutsideLights)
            {
            case "Fire":
                BlockShapes.MakeBlock(intFarmLength + 5, 76, intFarmLength + 3, BlockType.NETHERRACK, 2, 100, -1);
                BlockShapes.MakeBlock(intFarmLength + 5, 77, intFarmLength + 3, BlockType.FIRE, 2, 100, -1);
                BlockShapes.MakeBlock(intFarmLength + 11, 76, intFarmLength + 3, BlockType.NETHERRACK, 2, 100, -1);
                BlockShapes.MakeBlock(intFarmLength + 11, 77, intFarmLength + 3, BlockType.FIRE, 2, 100, -1);
                break;

            case "Torches":
                for (int y = 73; y <= 80; y += 7)
                {
                    BlockHelper.MakeTorch(intFarmLength + 6, y, intFarmLength + 3, intWallMaterial, 2);
                    BlockHelper.MakeTorch(intFarmLength + 10, y, intFarmLength + 3, intWallMaterial, 2);
                }
                break;

            case "None":
                break;

            default:
                Debug.Fail("Invalid switch result");
                break;
            }
            // add torches
            BlockHelper.MakeTorch(intFarmLength + 6, 79, intFarmLength + 13, intWallMaterial, 2);
            BlockHelper.MakeTorch(intFarmLength + 10, 79, intFarmLength + 13, intWallMaterial, 2);
            // add torches inside
            BlockHelper.MakeTorch(intFarmLength + 6, 77, intFarmLength + 11, intWallMaterial, 2);
            BlockHelper.MakeTorch(intFarmLength + 10, 77, intFarmLength + 11, intWallMaterial, 2);
            BlockHelper.MakeTorch(intFarmLength + 5, 77, intFarmLength + 6, intWallMaterial, 2);
            BlockHelper.MakeTorch(intFarmLength + 5, 77, intFarmLength + 10, intWallMaterial, 2);
            // add openings to the walls
            BlockShapes.MakeBlock(intFarmLength + 7, 73, intFarmLength + 12, BlockType.AIR, 2, 100, -1);
            BlockShapes.MakeBlock(intFarmLength + 9, 73, intFarmLength + 12, BlockType.AIR, 2, 100, -1);
            BlockShapes.MakeBlock(intFarmLength + 7, 74, intFarmLength + 12, BlockType.AIR, 2, 100, -1);
            BlockShapes.MakeBlock(intFarmLength + 9, 74, intFarmLength + 12, BlockType.AIR, 2, 100, -1);
            // add blocks on top of the towers
            BlockShapes.MakeHollowLayers(intFarmLength + 4, intFarmLength + 12, 81, 81,
                                         intFarmLength + 4, intFarmLength + 12, intWallMaterial, 1, -1);
            // alternating top blocks
            for (int x = intFarmLength + 4; x <= intFarmLength + 12; x += 2)
            {
                for (int z = intFarmLength + 4; z <= intFarmLength + 12; z += 2)
                {
                    if (x == intFarmLength + 4 || x == intFarmLength + 12 || z == intFarmLength + 4 || z == intFarmLength + 12)
                    {
                        BlockShapes.MakeBlock(x, 82, z, intWallMaterial, 1, 100, -1);
                    }
                }
            }
            // add central columns
            BlockShapes.MakeSolidBox(intFarmLength + 8, intFarmLength + 8, 73, 82,
                                     intFarmLength + 8, intFarmLength + 8, intWallMaterial, 1);
            BlockHelper.MakeLadder(intFarmLength + 7, 73, 82, intFarmLength + 8, 2, intWallMaterial);
            BlockHelper.MakeLadder(intFarmLength + 9, 73, 82, intFarmLength + 8, 2, intWallMaterial);
            // add torches on the roof
            BlockShapes.MakeBlock(intFarmLength + 6, 81, intFarmLength + 6, BlockType.TORCH, 1, 100, -1);
            BlockShapes.MakeBlock(intFarmLength + 6, 81, intFarmLength + 10, BlockType.TORCH, 2, 100, -1);
            BlockShapes.MakeBlock(intFarmLength + 10, 81, intFarmLength + 10, BlockType.TORCH, 1, 100, -1);
            // add cobwebs
            BlockShapes.MakeBlock(intFarmLength + 5, 79, intFarmLength + 5, BlockType.COBWEB, 1, 30, -1);
            BlockShapes.MakeBlock(intFarmLength + 5, 79, intFarmLength + 11, BlockType.COBWEB, 1, 30, -1);
            BlockShapes.MakeBlock(intFarmLength + 11, 79, intFarmLength + 5, BlockType.COBWEB, 1, 30, -1);
            BlockShapes.MakeBlock(intFarmLength + 11, 79, intFarmLength + 11, BlockType.COBWEB, 1, 30, -1);
            // add chests
            MakeGuardChest(bm, intFarmLength + 11, 73, intFarmLength + 11, booIncludeItemsInChests);
            MakeGuardChest(bm, intMapLength - (intFarmLength + 11), 73, intFarmLength + 11, booIncludeItemsInChests);
            MakeGuardChest(bm, intFarmLength + 11, 73, intMapLength - (intFarmLength + 11), booIncludeItemsInChests);
            MakeGuardChest(bm, intMapLength - (intFarmLength + 11), 73, intMapLength - (intFarmLength + 11),
                           booIncludeItemsInChests);
            // add archery slots
            BlockShapes.MakeSolidBox(intFarmLength + 4, intFarmLength + 4, 74, 77,
                                     intFarmLength + 8, intFarmLength + 8, BlockType.AIR, 2);
            BlockShapes.MakeSolidBox(intFarmLength + 4, intFarmLength + 4, 76, 76,
                                     intFarmLength + 7, intFarmLength + 9, BlockType.AIR, 2);
            if (!booIncludeWalls)
            {
                BlockHelper.MakeLadder(intFarmLength + 13, 64, 72, intFarmLength + 8, 2, intWallMaterial);
            }
            // include beds
            BlockHelper.MakeBed(intFarmLength + 5, intFarmLength + 6, 64, intFarmLength + 8, intFarmLength + 8, 2);
            BlockHelper.MakeBed(intFarmLength + 5, intFarmLength + 6, 64, intFarmLength + 10, intFarmLength + 10, 2);
            BlockHelper.MakeBed(intFarmLength + 11, intFarmLength + 10, 64, intFarmLength + 8, intFarmLength + 8, 2);
            // make columns to orientate torches
            BlockShapes.MakeSolidBox(intFarmLength + 5, intFarmLength + 5, 64, 73, intFarmLength + 5, intFarmLength + 5,
                                     BlockType.WOOD, 2);
            BlockShapes.MakeSolidBox(intFarmLength + 11, intFarmLength + 11, 64, 71, intFarmLength + 5, intFarmLength + 5,
                                     BlockType.WOOD, 2);
            BlockShapes.MakeSolidBox(intFarmLength + 5, intFarmLength + 5, 64, 71, intFarmLength + 11, intFarmLength + 11,
                                     BlockType.WOOD, 2);
            BlockShapes.MakeSolidBox(intFarmLength + 11, intFarmLength + 11, 64, 71, intFarmLength + 11, intFarmLength + 11,
                                     BlockType.WOOD, 2);
            // add ladders
            BlockHelper.MakeLadder(intFarmLength + 5, 64, 73, intFarmLength + 6, 2, BlockType.WOOD);
            // make torches
            BlockHelper.MakeTorch(intFarmLength + 10, 66, intFarmLength + 5, BlockType.WOOD, 2);
            BlockHelper.MakeTorch(intFarmLength + 6, 66, intFarmLength + 11, BlockType.WOOD, 2);
            BlockHelper.MakeTorch(intFarmLength + 10, 66, intFarmLength + 11, BlockType.WOOD, 2);
            // make columns for real
            BlockShapes.MakeSolidBox(intFarmLength + 5, intFarmLength + 5, 64, 73, intFarmLength + 5, intFarmLength + 5,
                                     intWallMaterial, 2);
            BlockShapes.MakeSolidBox(intFarmLength + 11, intFarmLength + 11, 64, 71, intFarmLength + 5, intFarmLength + 5,
                                     intWallMaterial, 2);
            BlockShapes.MakeSolidBox(intFarmLength + 5, intFarmLength + 5, 64, 71, intFarmLength + 11, intFarmLength + 11,
                                     intWallMaterial, 2);
            BlockShapes.MakeSolidBox(intFarmLength + 11, intFarmLength + 11, 64, 71, intFarmLength + 11, intFarmLength + 11,
                                     intWallMaterial, 2);
            // make cobwebs
            BlockShapes.MakeBlock(intFarmLength + 11, 67, intFarmLength + 8, BlockType.COBWEB, 2, 75, -1);
            // make doors from the city to the guard tower
            BlockShapes.MakeBlock(intFarmLength + 11, 65, intFarmLength + 11, BlockType.GOLD_BLOCK, 1, 100, -1);
            BlockShapes.MakeBlock(intFarmLength + 11, 64, intFarmLength + 11, BlockType.GOLD_BLOCK, 1, 100, -1);
            BlockHelper.MakeDoor(intFarmLength + 11, 64, intFarmLength + 12, BlockType.GOLD_BLOCK, true, 2);
            BlockShapes.MakeBlock(intFarmLength + 11, 65, intFarmLength + 11, BlockType.AIR, 1, 100, -1);
            BlockShapes.MakeBlock(intFarmLength + 11, 64, intFarmLength + 11, BlockType.AIR, 1, 100, -1);
            BlockShapes.MakeBlock(intFarmLength + 11, 64, intFarmLength + 11, BlockType.STONE_PLATE, 1, 100, -1);
            BlockShapes.MakeBlock(intFarmLength + 11, 64, intFarmLength + 13, BlockType.STONE_PLATE, 2, 100, -1);
            //BlockShapes.MakeBlock(intFarmLength + 13, 64, intFarmLength + 11, BlockType.STONE_PLATE, 1, 100, -1);
            // add guard tower sign
            BlockHelper.MakeSign(intFarmLength + 12, 65, intFarmLength + 13, "~Guard Tower~~", intWallMaterial, 1);
            BlockHelper.MakeSign(intFarmLength + 8, 74, intFarmLength + 13, "~Guard Tower~~", intWallMaterial, 2);
            // make beacon
            switch (strTowerAddition)
            {
            case "Fire beacon":
                BlockShapes.MakeSolidBox(intFarmLength + 8, intFarmLength + 8, 83, 84,
                                         intFarmLength + 8, intFarmLength + 8, intWallMaterial, 1);
                BlockShapes.MakeSolidBox(intFarmLength + 6, intFarmLength + 10, 85, 85,
                                         intFarmLength + 6, intFarmLength + 10, intWallMaterial, 1);
                BlockShapes.MakeSolidBox(intFarmLength + 6, intFarmLength + 10, 86, 86,
                                         intFarmLength + 6, intFarmLength + 10, BlockType.NETHERRACK, 1);
                BlockShapes.MakeSolidBox(intFarmLength + 6, intFarmLength + 10, 87, 87,
                                         intFarmLength + 6, intFarmLength + 10, BlockType.FIRE, 1);
                break;

            case "Flag":
                BlockShapes.MakeSolidBox(intFarmLength + 4, intFarmLength + 4, 83, 91,
                                         intFarmLength + 12, intFarmLength + 12, BlockType.FENCE, 2);
                BlockShapes.MakeBlock(intFarmLength + 4, 84, intFarmLength + 13, BlockType.FENCE, 2, 100, 0);
                BlockShapes.MakeBlock(intFarmLength + 4, 91, intFarmLength + 13, BlockType.FENCE, 2, 100, 0);
                int[] intColours = Utils.ShuffleArray(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 });
                switch (RandomHelper.Next(7))
                {
                case 0:         //2vert
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 85, 90,
                                                     intFarmLength + 13, intFarmLength + 17, BlockType.WOOL, 2, intColours[0]);
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 85, 90,
                                                     intFarmLength + 18, intFarmLength + 22, BlockType.WOOL, 2, intColours[1]);
                    break;

                case 1:         //3vert
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 85, 90,
                                                     intFarmLength + 13, intFarmLength + 15, BlockType.WOOL, 2, intColours[0]);
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 85, 90,
                                                     intFarmLength + 16, intFarmLength + 18, BlockType.WOOL, 2, intColours[1]);
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 85, 90,
                                                     intFarmLength + 19, intFarmLength + 21, BlockType.WOOL, 2, intColours[2]);
                    break;

                case 2:         //4vert
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 85, 90,
                                                     intFarmLength + 13, intFarmLength + 14, BlockType.WOOL, 2, intColours[0]);
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 85, 90,
                                                     intFarmLength + 15, intFarmLength + 16, BlockType.WOOL, 2, intColours[1]);
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 85, 90,
                                                     intFarmLength + 17, intFarmLength + 18, BlockType.WOOL, 2, intColours[2]);
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 85, 90,
                                                     intFarmLength + 19, intFarmLength + 20, BlockType.WOOL, 2, intColours[3]);
                    break;

                case 3:         //2horiz
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 85, 87,
                                                     intFarmLength + 13, intFarmLength + 22, BlockType.WOOL, 2, intColours[0]);
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 88, 90,
                                                     intFarmLength + 13, intFarmLength + 22, BlockType.WOOL, 2, intColours[1]);
                    break;

                case 4:         //3horiz
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 85, 86,
                                                     intFarmLength + 13, intFarmLength + 22, BlockType.WOOL, 2, intColours[0]);
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 87, 88,
                                                     intFarmLength + 13, intFarmLength + 22, BlockType.WOOL, 2, intColours[1]);
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 89, 90,
                                                     intFarmLength + 13, intFarmLength + 22, BlockType.WOOL, 2, intColours[2]);
                    break;

                case 5:         //quarters
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 85, 87,
                                                     intFarmLength + 13, intFarmLength + 17, BlockType.WOOL, 2, intColours[0]);
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 85, 87,
                                                     intFarmLength + 18, intFarmLength + 22, BlockType.WOOL, 2, intColours[1]);
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 88, 90,
                                                     intFarmLength + 13, intFarmLength + 17, BlockType.WOOL, 2, intColours[2]);
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 88, 90,
                                                     intFarmLength + 18, intFarmLength + 22, BlockType.WOOL, 2, intColours[3]);
                    break;

                case 6:         //cross
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 85, 90,
                                                     intFarmLength + 13, intFarmLength + 22, BlockType.WOOL, 2, intColours[0]);
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 87, 88,
                                                     intFarmLength + 13, intFarmLength + 22, BlockType.WOOL, 2, intColours[1]);
                    BlockShapes.MakeSolidBoxWithData(intFarmLength + 4, intFarmLength + 4, 85, 90,
                                                     intFarmLength + 17, intFarmLength + 18, BlockType.WOOL, 2, intColours[1]);
                    break;

                default:
                    Debug.Fail("Invalid switch result");
                    break;
                }
                break;
            }
        }
Пример #4
0
        private static string RandomSign()
        {
            string strSignText = "*~*~*~*";

            int intRand;

            do
            {
                intRand = RandomHelper.Next(intAmountOfSignTypes);
            } while (intRand >= 5 && _booSignUsed[intRand]);
            _booSignUsed[intRand] = true;

            do
            {
                switch (intRand)
                {
                case 0:
                case 1: strSignText = RandomHelper.RandomString("I will", "I can", "Will", "Can") + " " +
                                      RandomHelper.RandomString("trade", "swap", "sell") +
                                      " " + RandomHelper.RandomString("gold", "iron", "dirt",
                                                                      "glass", "flowers", "cake") +
                                      " for " + RandomHelper.RandomString("obsidian", "wood", "sand",
                                                                          "coal", "stone", "cookies") +
                                      "~- " + RandomHelper.RandomString("See", "Talk to") + " " +
                                      RandomHelper.RandomLetterUpper() + "." + RandomHelper.RandomLetterUpper() + ".";
                    break;

                case 2: strSignText = RandomHelper.RandomString("Church", "Order") + " of the Holy " +
                                      RandomHelper.RandomFileLine(Path.Combine("Resources", "ChurchNoun.txt")) +
                                      " are meeting this " + RandomHelper.RandomDay();
                    break;

                case 3: strSignText = RandomHelper.RandomString("Mrs", "Miss") + " " +
                                      RandomHelper.RandomFileLine(Path.Combine("Resources", "Adjectives.txt")) +
                                      " has lost her " +
                                      RandomHelper.RandomString("cat", "dog", "glasses", "marbles") +
                                      RandomHelper.RandomString(". Reward offered", ". Please help");
                    break;

                case 4: strSignText = RandomHelper.RandomString("Armour", "Property", "House", "Weapons", "Gold",
                                                                "Bodyguard", "Pet wolf", "Books", "Tools") +
                                      " for sale~- " + RandomHelper.RandomString("See", "Talk to") + " " +
                                      RandomHelper.RandomLetterUpper() + "." + RandomHelper.RandomLetterUpper() + ".";
                    break;

                case 5: strSignText = "Lost pet creeper. Last seen near the mini crater";
                    break;

                case 6: strSignText = "Israphel~~Wanted dead~or alive";
                    break;

                case 7: strSignText = "Lost Jaffa Cakes. Please return to Honeydew";
                    break;

                case 8: strSignText = "Read note " + RandomHelper.Next(500, 999);
                    break;

                case 9: strSignText = "Buy one get one free on gravestones!";
                    break;

                case 10: strSignText = "Archery practice this " + RandomHelper.RandomDay() + " afternoon";
                    break;

                case 11: strSignText = "Seen a crime? Tell the nearest city guard";
                    break;

                case 12: strSignText = "New city law: No minors can be miners";
                    break;

                case 13: strSignText = "Council meeting this " + RandomHelper.RandomDay();
                    break;

                default:
                    Debug.Fail("Invalid switch result");
                    break;
                }
            } while (!Utils.IsValidSign(strSignText));
            return(strSignText);
        }
Пример #5
0
        private static int[,] FillArea(int[,] intArea, int intSizeX, int intSizeZ, int intStartX, int intStartZ)
        {
            int[,] intDistrict = new int[intSizeX, intSizeZ];
            int[,] intFinal    = new int[intSizeX, intSizeZ];
            int        intWasted = intSizeX * intSizeZ, intAttempts = 15, intFail = 0;
            List <int> lstBuildings = new List <int>();

            do
            {
                lstBuildings.Clear();
                do
                {
                    SourceWorld.Building CurrentBuilding;
                    do
                    {
                        CurrentBuilding = SourceWorld.SelectRandomBuilding();
                    } while (!IsValidBuilding(CurrentBuilding, lstBuildings, intArea, intStartX, intStartZ, intSizeX, intSizeZ));
                    bool booFound = false;
                    if (RandomHelper.NextDouble() > 0.5)
                    {
                        intDistrict = RotateArray(intDistrict, RandomHelper.Next(4));
                    }
                    int x, z = 0;
                    for (x = 0; x < intDistrict.GetLength(0) - CurrentBuilding.intSize && !booFound; x++)
                    {
                        for (z = 0; z < intDistrict.GetLength(1) - CurrentBuilding.intSize && !booFound; z++)
                        {
                            booFound = IsFree(intDistrict, x, z, x + CurrentBuilding.intSize, z + CurrentBuilding.intSize);
                        }
                    }
                    x--;
                    z--;
                    if (booFound)
                    {
                        for (int a = x + 1; a <= x + CurrentBuilding.intSize - 1; a++)
                        {
                            for (int b = z + 1; b <= z + CurrentBuilding.intSize - 1; b++)
                            {
                                intDistrict[a, b] = 2;
                            }
                        }
                        lstBuildings.Add(CurrentBuilding.intID);
                        intDistrict[x + 1, z + 1] = 100 + CurrentBuilding.intID;
                        intDistrict[x + CurrentBuilding.intSize - 1, z + CurrentBuilding.intSize - 1] = 100 + CurrentBuilding.intID;
                        intFail = 0;
                    }
                    else
                    {
                        intFail++;
                    }
                } while (intFail < 10);

                int intCurWasted = SquaresWasted(intDistrict);
                if (intCurWasted < intWasted)
                {
                    intFinal = new int[intDistrict.GetLength(0), intDistrict.GetLength(1)];
                    Array.Copy(intDistrict, intFinal, intDistrict.Length);
                    intWasted   = intCurWasted;
                    intAttempts = 10;
                }
                Array.Clear(intDistrict, 0, intDistrict.Length);
                intAttempts--;
            } while (intAttempts > 0);
            if (intSizeX == intFinal.GetLength(1))
            {
                intFinal = RotateArray(intFinal, 1);
            }
            return(intFinal);
        }
Пример #6
0
        private static void SplitArea(BlockManager bm, int[,] intArea, int x1, int z1, int x2, int z2)
        {
            for (int x = x1; x <= x2; x++)
            {
                for (int y = z1; y <= z2; y++)
                {
                    if (x == x1 || x == x2 || y == z1 || y == z2)
                    {
                        if (intArea[x, y] < 500)
                        {
                            intArea[x, y] = 1;
                        }
                    }
                }
            }
            bool booPossibleToSplit = true;
            bool booSplitByX        = false;

            if (Math.Abs(x1 - x2) > 50 && Math.Abs(z1 - z2) > 50)
            {
                booSplitByX = RandomHelper.NextDouble() > 0.5;
            }
            else if (Math.Abs(x1 - x2) > 50)
            {
                booSplitByX = true;
            }
            else if (Math.Abs(z1 - z2) <= 50)
            {
                booPossibleToSplit = false;
            }
            if (booPossibleToSplit)
            {
                if (booSplitByX)
                {
                    int intSplitPoint = RandomHelper.Next(x1 + 20, x2 - 20);
                    SplitArea(bm, intArea, x1, z1, intSplitPoint, z2);
                    SplitArea(bm, intArea, intSplitPoint, z1, x2, z2);
                    intStreet++;
                    MakeStreetSign(bm, intSplitPoint - 1, z1 + 1, intSplitPoint - 1, z2 - 1);
                }
                else
                {
                    int intSplitPoint = RandomHelper.Next(z1 + 20, z2 - 20);
                    SplitArea(bm, intArea, x1, z1, x2, intSplitPoint);
                    SplitArea(bm, intArea, x1, intSplitPoint, x2, z2);
                    intStreet++;
                    MakeStreetSign(bm, x1 + 1, intSplitPoint - 1, x2 - 1, intSplitPoint - 1);
                }
            }
            else
            {
                int[,] intDistrict = FillArea(intArea, (x2 - x1), (z2 - z1), x1, z1);
                for (int x = 0; x < intDistrict.GetUpperBound(0) - 1; x++)
                {
                    for (int y = 0; y < intDistrict.GetUpperBound(1) - 1; y++)
                    {
                        intArea[x1 + x + 1, z1 + y + 1] = intDistrict[x + 1, y + 1];
                    }
                }
            }
        }
Пример #7
0
 public static string RandomItemFromArray(string[] strStrings)
 {
     return(strStrings[RandomHelper.Next(strStrings.Length)]);
 }
Пример #8
0
 public static int RandomItemFromArray(int[] intNumbers)
 {
     return(intNumbers[RandomHelper.Next(intNumbers.Length)]);
 }
Пример #9
0
 public static char RandomLetterLower()
 {
     return((char)((short)'a' + RandomHelper.Next(26)));
 }
Пример #10
0
 public static int RandomNumber(params int[] intNumbers)
 {
     return(intNumbers[RandomHelper.Next(intNumbers.Length)]);
 }
Пример #11
0
 public static string RandomString(params string[] strStrings)
 {
     return(strStrings[RandomHelper.Next(strStrings.Length)]);
 }
Пример #12
0
 public static string[] ShuffleArray(string[] strArray)
 {
     return(strArray.OrderBy(a => RandomHelper.Next()).ToArray());
 }
Пример #13
0
 public static int[] ShuffleArray(int[] intArray)
 {
     return(intArray.OrderBy(a => RandomHelper.Next()).ToArray());
 }