Пример #1
0
        private static void MakeChestItems(BlockManager bm, int x, int y, int z, int[] intResourceChances, string[] strResourceNames)
        {
            string strResource = strResourceNames[RandomHelper.RandomWeightedNumber(intResourceChances)];
            string strAmount;

            _dictResourceAmounts.TryGetValue(strResource.ToLower(), out strAmount);
            strAmount = strAmount ?? "1,1";
            int intAmount = RandomHelper.Next(Convert.ToInt32(strAmount.Split(',')[0]),
                                              Convert.ToInt32(strAmount.Split(',')[1]) + 1);
            string strBlockID;

            _dictResourceIDs.TryGetValue(strResource.ToLower(), out strBlockID);
            TileEntityChest tec     = new TileEntityChest();
            int             intSlot = 0;

            do
            {
                if (intAmount > MINECRAFT_ITEM_STACK_AMOUNT)
                {
                    tec.Items[intSlot++] = BlockHelper.MakeItem(Convert.ToInt32(strBlockID),
                                                                MINECRAFT_ITEM_STACK_AMOUNT);
                }
                else
                {
                    tec.Items[intSlot++] = BlockHelper.MakeItem(Convert.ToInt32(strBlockID), intAmount);
                }
                intAmount -= MINECRAFT_ITEM_STACK_AMOUNT;
            } while (intAmount > 0);

            bm.SetTileEntity(x, y, z, tec);
        }
Пример #2
0
        public static Building SelectRandomBuilding(BuildingTypes btNeeded, int intDepth)
        {
            int intFail = 0;

            string[] strFrequencyList = { "very common", "common", "average", "rare", "very rare" };
            int      intFrequency     = RandomHelper.RandomWeightedNumber(new int[] { 9, 8, 7, 6, 5 });
            int      intBuilding      = 0;
            bool     booValid;

            do
            {
                if (++intFail >= 100)
                {
                    intFrequency = RandomHelper.RandomWeightedNumber(new int[] { 9, 8, 7, 6, 5 });
                    intFail      = 0;
                }
                intBuilding = RandomHelper.Next(_AllBuildings.GetLength(0));
                booValid    = _AllBuildings[intBuilding].btThis == btNeeded;
                if (booValid)
                {
                    if (btNeeded == BuildingTypes.MineshaftSection)
                    {
                        booValid = _AllBuildings[intBuilding].strFrequencyMineshaft[intDepth] == strFrequencyList[intFrequency];
                    }
                    else
                    {
                        booValid = _AllBuildings[intBuilding].strFrequency == strFrequencyList[intFrequency];
                    }
                }
            } while (!booValid);
            return(_AllBuildings[intBuilding]);
        }
Пример #3
0
        public static Building SelectRandomBuilding()
        {
            string[] strFrequencyList = { "very common", "common", "average", "rare", "very rare" };
            int      intFrequency     = RandomHelper.RandomWeightedNumber(new int[] { 12, 9, 6, 3, 1 });
            int      intBuilding      = 0;

            do
            {
                intBuilding = rand.Next(AllBuildings.GetLength(0));
            } while (AllBuildings[intBuilding].strFrequency != strFrequencyList[intFrequency]);
            return(AllBuildings[intBuilding]);
        }
Пример #4
0
        private static void MakeChestItems(BlockManager bm, int x, int y, int z)
        {
            string strResource = strResourceNames[RandomHelper.RandomWeightedNumber(intResourceChances)];
            string strAmount;

            dictResourceAmounts.TryGetValue(strResource.ToLower(), out strAmount);
            strAmount = strAmount ?? "1,1";
            int intAmount = RandomHelper.Next(Convert.ToInt32(strAmount.Split(',')[0]),
                                              Convert.ToInt32(strAmount.Split(',')[1]) + 1);
            string strBlockID;

            dictResourceIDs.TryGetValue(strResource.ToLower(), out strBlockID);
            TileEntityChest tec = new TileEntityChest();

            tec.Items[0] = BlockHelper.MakeItem(Convert.ToInt32(strBlockID), intAmount);
            bm.SetTileEntity(x, y, z, tec);
        }
Пример #5
0
        private static int[, ,] MakeUndergroundTerrain(int SizeX, int SizeY, int SizeZ)
        {
            int[, ,] intArea = new int[(SizeX / 8) + 1, (SizeY / 8) + 1, (SizeZ / 8) + 1];
            int[] intGroundBlockIDs = new int[] { BlockType.STONE, BlockType.DIRT, BlockType.SAND,
                                                  BlockType.GRAVEL };
            int[] intGroundBlockChances = new int[] { 3, 2, 1, 1 };
            for (int x = 0; x < intArea.GetLength(0); x++)
            {
                for (int y = 0; y < intArea.GetLength(1); y++)
                {
                    for (int z = 0; z < intArea.GetLength(2); z++)
                    {
                        intArea[x, y, z] = intGroundBlockIDs[RandomHelper.RandomWeightedNumber(intGroundBlockChances)];
                    }
                }
            }

            double dblSmudgeArrayChance = 0.6;

            intArea = Utils.SmudgeArray3D(Utils.EnlargeThreeDimensionalArray(intArea, 2, 2, 2), dblSmudgeArrayChance);
            intArea = Utils.SmudgeArray3D(Utils.EnlargeThreeDimensionalArray(intArea, 2, 2, 2), dblSmudgeArrayChance);
            intArea = AddResources(intArea, SizeX, SizeY, SizeZ);
            intArea = Utils.SmudgeArray3D(Utils.EnlargeThreeDimensionalArray(intArea, 2, 2, 2), dblSmudgeArrayChance);

            for (int x = 0; x < intArea.GetLength(0); x++)
            {
                for (int y = 0; y < intArea.GetLength(1); y++)
                {
                    for (int z = 0; z < intArea.GetLength(2); z++)
                    {
                        if (intArea[x, y, z] == BlockType.SAND && RandomHelper.NextDouble() < 0.2)
                        {
                            intArea[x, y, z] = BlockType.SANDSTONE;
                        }
                    }
                }
            }

            return(intArea);
        }
Пример #6
0
        private static int[, ,] MakeUndergroundTerrain(int SizeY, frmMace frmLogForm)
        {
            int[, ,] intArea = new int[(City.MapLength / 8) + 1, (SizeY / 8) + 1, (City.MapLength / 8) + 1];
            int[] intGroundBlockIDs = new int[] { BlockInfo.Stone.ID, BlockInfo.Dirt.ID, BlockInfo.Sand.ID,
                                                  BlockInfo.Gravel.ID };
            int[] intGroundBlockChances = new int[] { 3, 2, 1, 1 };
            for (int x = 0; x < intArea.GetLength(0); x++)
            {
                for (int y = 0; y < intArea.GetLength(1); y++)
                {
                    for (int z = 0; z < intArea.GetLength(2); z++)
                    {
                        intArea[x, y, z] = intGroundBlockIDs[RandomHelper.RandomWeightedNumber(intGroundBlockChances)];
                    }
                }
            }

            double dblSmudgeArrayChance = 0.6;

            intArea = Utils.SmudgeArray3D(Utils.EnlargeThreeDimensionalArray(intArea, 2, 2, 2), dblSmudgeArrayChance);
            intArea = Utils.SmudgeArray3D(Utils.EnlargeThreeDimensionalArray(intArea, 2, 2, 2), dblSmudgeArrayChance);
            intArea = AddResources(intArea, SizeY, frmLogForm);
            intArea = Utils.SmudgeArray3D(Utils.EnlargeThreeDimensionalArray(intArea, 2, 2, 2), dblSmudgeArrayChance);

            for (int x = 0; x < intArea.GetLength(0); x++)
            {
                for (int y = 0; y < intArea.GetLength(1); y++)
                {
                    for (int z = 0; z < intArea.GetLength(2); z++)
                    {
                        if (intArea[x, y, z] == BlockInfo.Sand.ID && RandomHelper.NextDouble() < 0.2)
                        {
                            intArea[x, y, z] = BlockInfo.Sandstone.ID;
                        }
                    }
                }
            }

            return(intArea);
        }