示例#1
0
        private void LevelTick(object state)
        {
            if (m > 0)
            {
                //if (_tick%random.Next(1, 4) == 0)
                Level  level  = Context.LevelManager.Levels.First();
                Random random = level.Random;

                PlayerLocation point1 = level.SpawnPoint;
                PlayerLocation point2 = level.SpawnPoint;
                point2.X += 10;
                PlayerLocation point3 = level.SpawnPoint;
                point3.X -= 10;

                if (Math.Abs(m - 3) < 0.1)
                {
                    McpeSetTime timeDay = McpeSetTime.CreateObject();
                    timeDay.time    = 0;
                    timeDay.started = 1;
                    level.RelayBroadcast(timeDay, true);

                    ThreadPool.QueueUserWorkItem(delegate(object o)
                    {
                        Thread.Sleep(100);

                        McpeSetTime timeReset = McpeSetTime.CreateObject();
                        timeReset.time        = (int)level.CurrentWorldTime;
                        timeReset.started     = (byte)(level.IsWorldTimeStarted ? 1 : 0);
                        level.RelayBroadcast(timeDay, true);

                        Thread.Sleep(200);

                        {
                            var mcpeExplode     = McpeExplode.CreateObject();
                            mcpeExplode.x       = point1.X;
                            mcpeExplode.y       = point1.Y;
                            mcpeExplode.z       = point1.Z;
                            mcpeExplode.radius  = 100;
                            mcpeExplode.records = new Records();
                            level.RelayBroadcast(mcpeExplode, true);
                        }

                        Thread.Sleep(250);
                        {
                            var mcpeExplode     = McpeExplode.CreateObject();
                            mcpeExplode.x       = point2.X;
                            mcpeExplode.y       = point2.Y;
                            mcpeExplode.z       = point2.Z;
                            mcpeExplode.radius  = 100;
                            mcpeExplode.records = new Records();
                            level.RelayBroadcast(mcpeExplode, true);
                        }
                        Thread.Sleep(250);
                        {
                            var mcpeExplode     = McpeExplode.CreateObject();
                            mcpeExplode.x       = point3.X;
                            mcpeExplode.y       = point3.Y;
                            mcpeExplode.z       = point3.Z;
                            mcpeExplode.radius  = 100;
                            mcpeExplode.records = new Records();
                            level.RelayBroadcast(mcpeExplode, true);
                        }
                    });
                }

                if (m < 0.4 || m > 3)
                {
                    for (int i = 0; i < 15 + (30 * m); i++)
                    {
                        GenerateParticles(random, level, point1, m < 0.6 ? 0 : 20, new Vector3(m * (m / 2), m + 10, m * (m / 2)), m);
                        GenerateParticles(random, level, point2, m < 0.4 ? 0 : 12, new Vector3(m, m + 6, m), m);
                        GenerateParticles(random, level, point3, m < 0.2 ? 0 : 9, new Vector3(m / 2, m / 2 + 6, m / 2), m);
                    }
                }
            }
            m += 0.1;
            if (m > 3.8)
            {
                m = -5;
            }
        }
示例#2
0
        private bool SecondaryExplosion()
        {
            //Vector3 source = new Vector3(_centerCoordinates.X, _centerCoordinates.Y, _centerCoordinates.Z).Floor();
            //var yield = (1/_size)*100;
            //var explosionSize = _size*2;
            //var minX = Math.Floor(_centerCoordinates.X - explosionSize - 1);
            //var maxX = Math.Floor(_centerCoordinates.X + explosionSize + 1);
            //var minY = Math.Floor(_centerCoordinates.Y - explosionSize - 1);
            //var maxY = Math.Floor(_centerCoordinates.Y + explosionSize + 1);
            //var minZ = Math.Floor(_centerCoordinates.Z - explosionSize - 1);
            //var maxZ = Math.Floor(_centerCoordinates.Z + explosionSize + 1);
            //var explosionBB = new BoundingBox(new Vector3(minX, minY, minZ), new Vector3(maxX, maxY, maxZ));

            var records = new Records();

            foreach (Block block in _afectedBlocks.Values)
            {
                records.Add(block.Coordinates - _centerCoordinates);
            }

            new Task(() =>
            {
                var mcpeExplode      = McpeExplode.CreateObject();
                mcpeExplode.position = _centerCoordinates;
                mcpeExplode.radius   = (int)(_size * 32);
                mcpeExplode.records  = records;
                _world.RelayBroadcast(mcpeExplode);
            }).Start();

            foreach (Block block in _afectedBlocks.Values)
            {
                Block block1 = block;
                _world.SetAir(block1.Coordinates);
                //new Task(() => _world.SetBlock(new Air {Coordinates = block1.Coordinates})).Start();
                //new Task(() => block1.BreakBlock(_world)).Start();
                if (block is Tnt)
                {
                    new Task(() => SpawnTNT(block1.Coordinates, _world)).Start();
                }
            }

            // Set stuff on fire
            if (Fire)
            {
                Random random = new Random();
                foreach (BlockCoordinates coord in _afectedBlocks.Keys)
                {
                    var block = _world.GetBlock(coord.X, coord.Y, coord.Z);
                    if (block is Air)
                    {
                        var blockDown = _world.GetBlock(coord.X, coord.Y - 1, coord.Z);
                        if (!(blockDown is Air) && random.Next(3) == 0)
                        {
                            _world.SetBlock(new Fire {
                                Coordinates = block.Coordinates
                            });
                        }
                    }
                }
            }

            return(true);
        }
示例#3
0
 public override void HandleMcpeExplode(McpeExplode message)
 {
 }
示例#4
0
 public abstract void HandleMcpeExplode(McpeExplode message);
示例#5
0
 public override void HandleMcpeExplode(McpeExplode message)
 {
     UnhandledPackage(message);
 }