Example #1
0
        static void PlayerMoved(object sender, PlayerMovedEventArgs e)
        {
            Player p = e.Player;

            if (p.World != world || !p.IsPlayingCTF)
            {
                return;
            }

            foreach (Player other in world.Players)
            {
                if (!other.IsPlayingCTF)
                {
                    continue;
                }
                if (p.Team != other.Team && p.Bounds.Intersects(other.Bounds))
                {
                    if (p.Team.TaggingBounds.Intersects(other.Bounds))
                    {
                        Kill(p, other, " &Stagged ");
                    }
                    else if (other.Team.TaggingBounds.Intersects(p.Bounds))
                    {
                        Kill(other, p, " &Stagged ");
                    }
                }
            }
        }
 protected void OnChanged(PlayerMovedEventArgs e)
 {
     if (Changed != null)
     {
         Changed(this, e);
     }
 }
 private void OnMoved(object sender, PlayerMovedEventArgs e)
 {
     if (e.Player == Id)
     {
         CanMove = false;
     }
 }
Example #4
0
        /****************************************/


        private void PlayerMovedHandler(Object sender, PlayerMovedEventArgs e)
        {
            this.Invoke((MethodInvoker) delegate
            {
                message.Text = string.Format("{0} moved from {1} to {2}", e.CurrentPlayer.Name, e.Moved.From, e.Moved.To);

                //update the board
                _movedChecker.Image     = null;
                _movedChecker.AllowDrop = false;
                _movedChecker.BackColor = Color.Transparent;
            });
        }
Example #5
0
 public void OnPlayerMoved(object sender, PlayerMovedEventArgs args)
 {
     lock ( _lock ) {
         if (args.Player.World != _world)    //he left....chicken
         //_tracker.RemovePlayer(args.Player); remove will not work since the guy definitely has different position now
         //he will be removed from book keeping later in PlayerProximityTracker.FindPlayersAtDistance
         {
             return;
         }
         _tracker.MovePlayer(args.OldPosition.ToBlockCoords(), args.NewPosition.ToBlockCoords(), args.Player);
     }
 }
Example #6
0
        /// <summary>
        /// Event: Manages a player's movement
        /// </summary>
        private void OnPlayerMoved(object sender, PlayerMovedEventArgs e)
        {
            if (e.Player.World.gameMode == GameMode.ZombieSurvival)
            {
                if (e.Player.World.Name == _world.Name && _world != null)
                {
                    if (e.NewPosition != null)
                    {
                        Vector3I oldPos = new Vector3I(e.OldPosition.X / 32, e.OldPosition.Y / 32, e.OldPosition.Z / 32);
                        Vector3I newPos = new Vector3I(e.NewPosition.X / 32, e.NewPosition.Y / 32, e.NewPosition.Z / 32);

                        //check player bounds, revert if needed
                        if (oldPos.X != newPos.X || oldPos.Y != newPos.Y || oldPos.Z != newPos.Z)
                        {
                            if (!_world.Map.InBounds(newPos))
                            {
                                e.Player.TeleportTo(_world.Map.Spawn);
                                newPos = ( Vector3I )_world.Map.Spawn;
                            }
                            if (oldPos.X - newPos.X > 1 || oldPos.Y - newPos.Y > 1 || newPos.X - oldPos.X > 1 || newPos.Y - oldPos.Y > 1)
                            {
                                e.Player.TeleportTo(e.OldPosition);
                                newPos = oldPos;
                            }
                        }

                        //if they are inbounds, check infection zone (33*33) and infect if needed
                        if (_world.Map.InBounds(newPos))
                        {
                            if (oldPos.X != newPos.X || oldPos.Y != newPos.Y || oldPos.Z != newPos.Z)
                            {
                                foreach (Player p in _world.Players)
                                {
                                    Vector3I pos = p.Position.ToBlockCoords();
                                    if (e.NewPosition.DistanceSquaredTo(pos.ToPlayerCoords()) <= 33 * 33)
                                    {
                                        ToZombie(e.Player, p);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #7
0
        private void OtherPlayerMoved(object source, PlayerMovedEventArgs p)
        {
            MoveData data = p.Info;
            string   dir  = data.Move;

            if (dir == "left")
            {
                this.MoveLeft();
            }
            else if (dir == "right")
            {
                this.MoveRight();
            }
            else if (dir == "up")
            {
                this.MoveUp();
            }
            else if (dir == "down")
            {
                this.MoveDown();
            }
        }
Example #8
0
 private void PlayerMoved(object sender, PlayerMovedEventArgs e)
 {
     Update();
 }
 void PlayerMovedEventHandler(PlayerMovedEventArgs e)
 {
     Camera.Instance.Update(e.TimeElapsed);
 }
Example #10
0
 /// <summary>
 ///     Dispatches the <see cref="PlayerMoved"/> event asynchronously.
 /// </summary>
 /// <param name="eventArgs">the event arguments passed with the event</param>
 /// <returns>a task that represents the asynchronous operation</returns>
 protected virtual Task OnPlayerMovedAsync(PlayerMovedEventArgs eventArgs)
 => PlayerMoved.InvokeAsync(this, eventArgs);
 private void PlayerMovedInGrid(object sender, PlayerMovedEventArgs e)
 {
     UpdateCorners(e.Delta, e.Position);
     OnChanged(e);
 }
Example #12
0
        /****************************************/

        private void PlayerMovedHandler(Object sender, PlayerMovedEventArgs e)
        {
            Console.WriteLine( "\n {0} moved from {1} to {2}", e.CurrentPlayer.Name, e.Moved.From, e.Moved.To);
        }