예제 #1
0
        /// <summary>
        ///     For debugging of flight-path and rotation.
        /// </summary>
        private void BroadcastMoveAndMotion()
        {
            if (new Random().Next(5) == 0)
            {
                McpeSetEntityMotion motions = McpeSetEntityMotion.CreateObject();
                motions.runtimeEntityId = EntityId;
                motions.velocity        = Velocity;
                Level.RelayBroadcast(motions);
            }

            if (LastSentPosition != null)
            {
                McpeMoveEntityDelta move = McpeMoveEntityDelta.CreateObject();
                move.runtimeEntityId  = EntityId;
                move.prevSentPosition = LastSentPosition;
                move.currentPosition  = (PlayerLocation)KnownPosition.Clone();
                move.isOnGround       = IsWalker && IsOnGround;
                if (move.SetFlags())
                {
                    Level.RelayBroadcast(move);
                }
            }

            LastSentPosition = (PlayerLocation)KnownPosition.Clone();              // Used for delta

            if (Shooter != null && IsCritical)
            {
                var particle = new CriticalParticle(Level);
                particle.Position = KnownPosition.ToVector3();
                particle.Spawn(new[] { Shooter });
            }
        }
예제 #2
0
        /// <summary>
        /// For debugging of flight-path and rotation.
        /// </summary>
        private void BroadcastMoveAndMotion()
        {
            if (new Random().Next(5) == 0)
            {
                McpeSetEntityMotion motions = McpeSetEntityMotion.CreateObject();
                motions.runtimeEntityId = EntityId;
                motions.velocity        = Velocity;
                //new Task(() => Level.RelayBroadcast(motions)).Start();
                Level.RelayBroadcast(motions);
            }

            McpeMoveEntity moveEntity = McpeMoveEntity.CreateObject();

            moveEntity.runtimeEntityId = EntityId;
            moveEntity.position        = KnownPosition;
            Level.RelayBroadcast(moveEntity);

            if (Shooter != null && IsCritical)
            {
                var p = Shooter as Player;

                if (p != null)
                {
                    var particle = new CriticalParticle(Level);
                    particle.Position = KnownPosition.ToVector3();
                    particle.Spawn(new[] { p });
                }
            }
        }
예제 #3
0
        private void OnTicking(object sender, PlayerEventArgs e)
        {
            var player = e.Player;
            var level  = player.Level;

            if (e.Level.TickTime % 2 == 0)
            {
                player.AddPopup(new Popup()
                {
                    Id          = 10,
                    MessageType = MessageType.Tip,
                    Message     = GetCompass(player.KnownPosition.HeadYaw),
                    Duration    = 20 * 5,
                });
            }


            if (player.IsGliding)
            {
                if (player.CurrentSpeed > 30)
                {
                    var particle = new CriticalParticle(level);
                    particle.Position = player.KnownPosition.ToVector3();
                    particle.Spawn();
                }

                if (level.TickTime % 10 == 0)
                {
                    player.AddPopup(new Popup()
                    {
                        Id          = 10,
                        MessageType = MessageType.Tip,
                        Message     = $"Speed: {player.CurrentSpeed:F2}m/s",
                        Duration    = 20 * 5,
                    });
                }
            }
        }