コード例 #1
0
ファイル: Decorators.cs プロジェクト: namezis/DragonSpire
        public override void Decorate(Chunk C, int X, byte Y, int Z)
        {
            //TODO: Create a better Ore Decorator
            int  _X = X;
            byte _Y = Y;
            int  _Z = Z;

            for (int I = 0; I <= R.Next(VeinSize); I++)
            {
                if (R.NextDouble() > 0.5)
                {
                    if (!I.Equals(0))
                    {
                        double Random = R.NextDouble();
                        if (0.0 <= Random && Random <= 0.3 && _X - X < 2)
                        {
                            _X += 1;
                        }
                        else if (0.4 <= Random && Random <= 0.6 && _Y - Y < 2)
                        {
                            _Y += 1;
                        }
                        else if (0.7 <= Random && Random <= 1.0 && _Z - Z < 2)
                        {
                            _Z += 1;
                        }
                    }

                    if (C.GetBlock(new BlockLocation(_X, _Y, _Z, C.World)).Equals(MaterialManager.GetBlock(1)))
                    {
                        C.SetBlock(new BlockLocation(_X, _Y, _Z, C.World), MaterialManager.GetMaterial(ID), 0);
                    }
                }
            }
        }
コード例 #2
0
ファイル: Decorators.cs プロジェクト: namezis/DragonSpire
        public override void Decorate(Chunk C, int X, byte Y, int Z)
        {
            for (int I = 0; I < 10; I++)
            {
                int  _X = X + R.Next(8) - R.Next(8);
                byte _Y = (byte)(Y + R.Next(4) - R.Next(4));
                int  _Z = Z + R.Next(8) - R.Next(8);
                byte H  = (byte)new Random().Next(3);

                if (ID.Equals(81) && C.GetBlock(new BlockLocation(_X, (byte)(_Y - 1), _Z, C.World)).Equals(MaterialManager.GetBlock(12)))
                {
                    //Cactus
                    WorldGeneratorUtils.GenerateTower(ID, 0, C, _X, _Y, _Z, H);
                }
            }
        }
コード例 #3
0
ファイル: Decorators.cs プロジェクト: namezis/DragonSpire
        public override void Decorate(Chunk C, int X, byte Y, int Z)
        {
            for (int I = 0; I < 64; I++)
            {
                int  _X = X + R.Next(8) - R.Next(8);
                byte _Y = (byte)(Y + R.Next(4) - R.Next(4));
                int  _Z = Z + R.Next(8) - R.Next(8);

                if (C.GetBlock(new BlockLocation(_X, (byte)(_Y - 1), _Z, C.World)).Equals(MaterialManager.GetBlock(2)) && C.GetBlock(new BlockLocation(_X, _Y, _Z, C.World)).Equals(MaterialManager.GetBlock(0)))
                {
                    C.SetBlock(new BlockLocation(_X, _Y, _Z, C.World), MaterialManager.GetMaterial(ID), Meta);
                }
            }
        }
コード例 #4
0
 public static void GenerateSphere(short ID, byte Meta, Chunk C, int X, byte Y, int Z, byte Radius)
 {
     for (int j = Convert.ToInt16(-Radius); j <= Radius; j = (short)(j + 1))
     {
         if ((X + j) < 0 || (X + j) > 16)
         {
             continue;
         }
         for (int k = Convert.ToInt16(-Radius); k <= Radius; k = (short)(k + 1))
         {
             if ((Y + k) < 0 || (Y + k) > 255)
             {
                 continue;
             }
             for (int m = Convert.ToInt16(-Radius); m <= Radius; m = (short)(m + 1))
             {
                 if ((Z + m) < 0 || (Z + m) > 15)
                 {
                     continue;
                 }
                 int maXValue = (short)Math.Sqrt((double)(((j * j) + (k * k)) + (m * m)));
                 if ((maXValue < (Radius + 1)))
                 {
                     try
                     {
                         int X2 = X + j;
                         int Y2 = Y + k;
                         int Z2 = Z + m;
                         if (X2 <= 15 && Y2 <= 255 && Z2 <= 15)
                         {
                             if (!C.GetBlock(new BlockLocation(X + j, (byte)(Y + k), Z + m, C.World)).Equals(MaterialManager.GetBlock(7)) && !C.GetBlock(new BlockLocation(X + j, (byte)(Y + k), Z + m, C.World)).Equals(MaterialManager.GetBlock(17)))
                             {
                                 C.SetBlock(new BlockLocation(X + j, (byte)(Y + k), Z + m, C.World), MaterialManager.GetMaterial(ID), 0);
                             }
                         }
                     }
                     catch { }
                 }
             }
         }
     }
 }