상속: PlayerEventArgs
예제 #1
0
 private static void Player_Moved(object sender, Events.PlayerMovedEventArgs e)
 {
     try
     {
         if ((e.OldPosition.X != e.NewPosition.X) || (e.OldPosition.Y != e.NewPosition.Y) ||
             (e.OldPosition.Z != (e.NewPosition.Z)))
         {
             lock (e.Player.MessageBlockLock)
             {
                 if (e.Player.WorldMap == null)
                 {
                     return;
                 }
                 if (e.Player.WorldMap.MessageBlocks != null)
                 {
                     lock (e.Player.WorldMap.MessageBlocks)
                     {
                         foreach (MessageBlock mb in e.Player.WorldMap.MessageBlocks)
                         {
                             if (e.Player.WorldMap == null)
                             {
                                 return;
                             }
                             if (mb.IsInRange(e.Player))
                             {
                                 string M = mb.GetMessage();
                                 if (M == "")
                                 {
                                     return;
                                 }
                                 if (e.Player.LastUsedMessageBlock == null)
                                 {
                                     e.Player.LastUsedMessageBlock = DateTime.UtcNow;
                                     e.Player.Message(M);
                                     return;
                                 }
                                 if ((DateTime.UtcNow - e.Player.LastUsedMessageBlock).TotalSeconds > 4)
                                 {
                                     e.Player.Message(M);
                                     e.Player.LastUsedMessageBlock = DateTime.UtcNow;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Log(LogType.Error, "MessageBlock_Moving: " + ex);
     }
     ;
 }
예제 #2
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 " );
				}
			}
		}
예제 #3
0
        public static void Player_IsBack(object sender, Events.PlayerMovedEventArgs e)
        {
            if (e.Player.IsAway)
            {
                // We need to have block positions, so we divide by 32
                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 if the player actually moved and not just rotated
                if ((oldPos.X != newPos.X) || (oldPos.Y != newPos.Y) || (oldPos.Z != newPos.Z))
                {
                    Server.Players.Message("{0} &Eis back", e.Player.ClassyName);
                    e.Player.IsAway = false;
                }
            }
        }
예제 #4
0
 static 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);
                 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);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #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);
     }
 }
예제 #6
0
        /// <summary>
        /// Event: Manages a player's movement
        /// </summary>
        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 );
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #7
0
        public static void PlayerMoved(object sender, PlayerMovedEventArgs e)
        {
            if (e.Player.Info.InGame)
            {
                if (GameManager.BlueTeam.Count > 0)
                {
                    if (GameManager.GameIsOn)
                    {
                        foreach (Player B in GameManager.BlueTeam)
                        {
                            if (GameManager.BlueTeam.Contains(e.Player))
                            {
                                if (B.Position.ToVector3I() == e.Player.Position.ToVector3I())
                                {
                                    //kill b send to blue spawn
                                }
                            }
                        }
                    }
                }
            }

            if (GameManager.RedTeam.Count > 0)
            {
                if (e.Player.Info.InGame)
                {
                    if (GameManager.GameIsOn)
                    {
                        foreach (Player R in GameManager.RedTeam)
                        {
                            if (GameManager.BlueTeam.Contains(e.Player))
                            {
                                if (R.Position.ToVector3I() == e.Player.Position.ToVector3I())
                                {
                                    //kill R send to red spawn
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #8
0
파일: Events.cs 프로젝트: Jonty800/Guilds
        private static void OnPlayerMoved( object sender, PlayerMovedEventArgs e )
        {
            try {
                if ( IsInRangeOfSpawnpoint( e.Player.World, e.NewPosition ) )
                    return;
                if ( !GuildManager.PlayerHasGuild( e.Player.Info ) )
                    return;
                if ( !GuildManager.PlayersGuild( e.Player.Info ).PvP )
                    return;
                if ( e.Player.World != null ) {
                    if ( e.NewPosition != null && e.OldPosition != 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 );
                        //if they are inbounds, check zone (33*33) and kill if needed
                        if ( oldPos.X != newPos.X || oldPos.Y != newPos.Y || oldPos.Z != newPos.Z ) {
                            if ( e.Player.World.Map.InBounds( newPos ) ) {
                                if ( e.Player.PublicAuxStateObjects.ContainsKey( "dead" ) ) {
                                    e.Player.TeleportTo( e.OldPosition );
                                    return;
                                }
                                foreach ( Guild guild in Cache.Guilds ) {
                                    foreach ( string ps in guild.Members ) {
                                        PlayerInfo pi = PlayerDB.FindPlayerInfoExact( ps );
                                        if ( pi != null ) {
                                            Player p = pi.PlayerObject;
                                            if ( p != null ) {
                                                if ( p != e.Player ) {
                                                    if ( GuildManager.PlayersGuild( e.Player.Info ) != GuildManager.PlayersGuild( p.Info ) ) {
                                                        if ( GuildManager.PlayersGuild( p.Info ).PvP ) {
                                                            if ( p.World.Name == e.Player.World.Name ) {
                                                                if ( !IsInRangeOfSpawnpoint( p.World, p.Position ) ) {
                                                                    Vector3I pos = p.Position.ToBlockCoords();
                                                                    //check bat kills
                                                                    foreach ( Vector3I Block in p.GunCache.Values ) {
                                                                        if ( e.NewPosition.DistanceSquaredTo( Block.ToPlayerCoords() ) <= 49 * 49 ) {
                                                                            KillPlayer( p, e.Player, KillContext.Bat );
                                                                            return;
                                                                        }
                                                                    }
                                                                    foreach ( Vector3I Block in e.Player.GunCache.Values ) {
                                                                        if ( p.Position.DistanceSquaredTo( Block.ToPlayerCoords() ) <= 49 * 49 ) {
                                                                            KillPlayer( e.Player, p, KillContext.Bat );
                                                                            return;
                                                                        }
                                                                    }

                                                                    //check position kills
                                                                    if ( e.NewPosition.DistanceSquaredTo( pos.ToPlayerCoords() ) <= 33 * 33 ) {
                                                                        KillPlayer( e.Player, p, KillContext.Standard );
                                                                        return;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            } catch ( Exception ex ) {
                Logger.Log( LogType.SeriousError, ex.ToString() );
            }
        }