コード例 #1
0
        public void SpawnWither(Player player, int numberOfBats = 100, BlockPos spawnPos = null)
        {
            var coordinates = player.KnownPosition;

            if (spawnPos != null)
            {
                if (spawnPos.XRelative)
                {
                    coordinates.X += spawnPos.X;
                }
                else
                {
                    coordinates.X = spawnPos.X;
                }

                if (spawnPos.YRelative)
                {
                    coordinates.Y += spawnPos.Y;
                }
                else
                {
                    coordinates.Y = spawnPos.Y;
                }

                if (spawnPos.ZRelative)
                {
                    coordinates.Z += spawnPos.Z;
                }
                else
                {
                    coordinates.Z = spawnPos.Z;
                }
            }

            //int limit = (int) Math.Sqrt(numberOfBats);
            //for (int x = 0; x < limit; x++)
            //{
            //	for (int z = 0; z < limit; z++)
            //	{
            //		var wither = new Wither(player.Level);
            //		wither.NoAi = false;
            //		wither.KnownPosition = coordinates + new Vector3(x*2, 0, z*2);
            //		wither.SpawnEntity();
            //	}
            //}

            double radius = numberOfBats;

            do
            {
                for (int angle = 0; angle < 360; angle = (int)(angle + (360 / radius)))
                {
                    double rad = VectorHelpers.ToRadians(angle);

                    double x = radius * Math.Cos(rad);
                    double z = radius * Math.Sin(rad);

                    var wither = new Wither(player.Level);
                    wither.NoAi              = false;
                    wither.KnownPosition     = coordinates + new Vector3((float)x, 0, (float)z);
                    wither.KnownPosition.Yaw = angle + 90;
                    wither.SpawnEntity();
                    Thread.Sleep(50);
                }
                radius -= 4;
            } while (radius > 7);
        }