当前位置: 首页>>代码示例>>C#>>正文


C# Player.TeleportTo方法代码示例

本文整理汇总了C#中Player.TeleportTo方法的典型用法代码示例。如果您正苦于以下问题:C# Player.TeleportTo方法的具体用法?C# Player.TeleportTo怎么用?C# Player.TeleportTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Player的用法示例。


在下文中一共展示了Player.TeleportTo方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TeleportHandler

        static void TeleportHandler( Player player, CommandReader cmd ) {
            string name = cmd.Next();
            if( name == null ) {
                CdTeleport.PrintUsage( player );
                return;
            }

            if( cmd.Next() != null ) {
                cmd.Rewind();
                int x, y, z;
                if( cmd.NextInt( out x ) && cmd.NextInt( out y ) && cmd.NextInt( out z ) ) {

                    if( x <= -1024 || x >= 1024 || y <= -1024 || y >= 1024 || z <= -1024 || z >= 1024 ) {
                        player.Message( "Coordinates are outside the valid range!" );

                    } else {
                        player.TeleportTo( new Position {
                            X = (short)(x * 32 + 16),
                            Y = (short)(y * 32 + 16),
                            Z = (short)(z * 32 + 16),
                            R = player.Position.R,
                            L = player.Position.L
                        } );
                    }
                } else {
                    CdTeleport.PrintUsage( player );
                }

            } else {
                if( name == "-" ) {
                    if( player.LastUsedPlayerName != null ) {
                        name = player.LastUsedPlayerName;
                    } else {
                        player.Message( "Cannot repeat player name: you haven't used any names yet." );
                        return;
                    }
                }
                Player[] matches = Server.FindPlayers( player, name, false, true, true );
                if( matches.Length == 1 ) {
                    Player target = matches[0];
                    World targetWorld = target.World;
                    if( targetWorld == null ) PlayerOpException.ThrowNoWorld( target );

                    if( targetWorld == player.World ) {
                        player.TeleportTo( target.Position );

                    } else {
                        switch( targetWorld.AccessSecurity.CheckDetailed( player.Info ) ) {
                            case SecurityCheckResult.Allowed:
                            case SecurityCheckResult.WhiteListed:
                                if( targetWorld.IsFull ) {
                                    player.Message( "Cannot teleport to {0}&S because world {1}&S is full.",
                                                    target.ClassyName,
                                                    targetWorld.ClassyName );
                                    return;
                                }
                                player.StopSpectating();
                                player.JoinWorld( targetWorld, WorldChangeReason.Tp, target.Position );
                                break;
                            case SecurityCheckResult.BlackListed:
                                player.Message( "Cannot teleport to {0}&S because you are blacklisted on world {1}",
                                                target.ClassyName,
                                                targetWorld.ClassyName );
                                break;
                            case SecurityCheckResult.RankTooLow:
                                player.Message( "Cannot teleport to {0}&S because world {1}&S requires {2}+&S to join.",
                                                target.ClassyName,
                                                targetWorld.ClassyName,
                                                targetWorld.AccessSecurity.MinRank.ClassyName );
                                break;
                        }
                    }

                } else if( matches.Length > 1 ) {
                    player.MessageManyMatches( "player", matches );

                } else {
                    player.MessageNoPlayer( name );
                }
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:81,代码来源:ModerationCommands.cs

示例2: PatrolHandler

        static void PatrolHandler( Player player, CommandReader cmd ) {
            World playerWorld = player.World;
            if( playerWorld == null ) PlayerOpException.ThrowNoWorld( player );

            Player target = playerWorld.GetNextPatrolTarget( player );
            if( target == null ) {
                player.Message( "Patrol: No one to patrol in this world." );
                return;
            }

            player.TeleportTo( target.Position );
            player.Message( "Patrol: Teleporting to {0}", target.ClassyName );
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:13,代码来源:ModerationCommands.cs

示例3: SetSpawnHandler

        static void SetSpawnHandler( Player player, CommandReader cmd ) {
            World playerWorld = player.World;
            if( playerWorld == null ) PlayerOpException.ThrowNoWorld( player );


            string playerName = cmd.Next();
            if( playerName == null ) {
                Map map = player.WorldMap;
                map.Spawn = player.Position;
                player.TeleportTo( map.Spawn );
                player.Send( Packet.MakeAddEntity( Packet.SelfID, player.ListName, player.Position ) );
                player.Message( "New spawn point saved." );
                Logger.Log( LogType.UserActivity,
                            "{0} changed the spawned point.",
                            player.Name );

            } else if( player.Can( Permission.Bring ) ) {
                Player[] infos = playerWorld.FindPlayers( player, playerName );
                if( infos.Length == 1 ) {
                    Player target = infos[0];
                    player.LastUsedPlayerName = target.Name;
                    if( player.Can( Permission.Bring, target.Info.Rank ) ) {
                        target.Send( Packet.MakeAddEntity( Packet.SelfID, target.ListName, player.Position ) );
                    } else {
                        player.Message( "You may only set spawn of players ranked {0}&S or lower.",
                                        player.Info.Rank.GetLimit( Permission.Bring ).ClassyName );
                        player.Message( "{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName );
                    }

                } else if( infos.Length > 0 ) {
                    player.MessageManyMatches( "player", infos );

                } else {
                    infos = Server.FindPlayers( player, playerName, true, false, true );
                    if( infos.Length > 0 ) {
                        player.Message( "You may only set spawn of players on the same world as you." );
                    } else {
                        player.MessageNoPlayer( playerName );
                    }
                }
            } else {
                player.MessageNoAccess( CdSetSpawn );
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:44,代码来源:ModerationCommands.cs

示例4: KillHandler

        internal static void KillHandler(Player player, Command cmd)
        {
            string name = cmd.Next();
            string reason = cmd.NextAll();
            if (name == null)
            {
                player.Message("Please enter a name");
                return;
            }

            Player target = Server.FindPlayerOrPrintMatches(player, name, false, true);
            if (target == null) return;
            if (target.Immortal)
            {
                player.Message("&SYou failed to kill {0}&S, they are immortal", target.ClassyName);
                return;
            }

            double time = (DateTime.Now - player.Info.LastUsedKill).TotalSeconds;
            if (time < 10)
            {
                player.Message("&WYou can use /Kill again in " + Math.Round(10 - time) + " seconds.");
                return;
            }
            if (target == null)
            {
                player.Message("You need to enter a player name to Kill");
                return;
            }
            else
            {
                if (target == player)
                {
                    player.TeleportTo(player.World.Map.Spawn);
                    player.Info.LastUsedKill = DateTime.Now;
                    Server.Players.CanSee(target).Message("{0}&C killed itself in confusion!", player);
                    return;
                }

                if (player.Can(Permission.Kill, target.Info.Rank) && reason.Length < 1)
                {
                    target.TeleportTo(player.World.Map.Spawn);
                    player.Info.LastUsedKill = DateTime.Now;
                    Server.Players.CanSee(target).Message("{0}&C was &4Killed&C by {1}", target.ClassyName, player.ClassyName);
                    return;
                }
                else if (player.Can(Permission.Kill, target.Info.Rank) && reason != null)
                {
                    target.TeleportTo(player.World.Map.Spawn);
                    player.Info.LastUsedKill = DateTime.Now;
                    Server.Players.CanSee(target).Message("{0}&C was &4Killed&C by {1}&c: {2}", target.ClassyName, player.ClassyName, reason);
                }
                else
                {
                    player.Message("You can only Kill players ranked {0}&S or lower",
                                    player.Info.Rank.GetLimit(Permission.Kill).ClassyName);
                    player.Message("{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName);
                }
            }
        }
开发者ID:EricKilla,项目名称:LegendCraft,代码行数:60,代码来源:ModerationCommands.cs

示例5: TPZone

 static void TPZone(Player player, Command cmd)
 {
     string zoneName = cmd.Next();
     if (zoneName == null){
         player.Message("No zone name specified. See &W/Help tpzone");
         return;
     }else{
         Zone zone = player.World.Map.Zones.Find(zoneName);
         if (zone == null){
             player.MessageNoZone(zoneName);
             return;
         }
         Position zPos = new Position((((zone.Bounds.XMin + zone.Bounds.XMax) / 2) * 32),
             (((zone.Bounds.YMin + zone.Bounds.YMax) / 2) * 32),
             (((zone.Bounds.ZMin + zone.Bounds.ZMax) / 2) + 2) * 32);
         player.TeleportTo((zPos));
         player.Message("&WTeleporting you to zone " + zone.ClassyName);
     }
 }
开发者ID:EricKilla,项目名称:LegendCraft,代码行数:19,代码来源:ModerationCommands.cs

示例6: TopHandler

        private static void TopHandler(Player player, CommandReader cmd) {
            int x = player.Position.X/32;
            int y = player.Position.Y/32;
            int z = player.WorldMap.Height;
            retry2:
            if (player.World.map.GetBlock(x, y, z - 3) == Block.Air) {
                z = z - 1;
                goto retry2;
            }
            retry:
            if (player.World.map.GetBlock(x, y, z - 2) != Block.Air ||
                player.World.map.GetBlock(x, y, z - 1) != Block.Air) {
                z = z + 1;
                goto retry;
            }

            player.TeleportTo(new Position {
                X = (short) (x*32 + 16),
                Y = (short) (y*32 + 16),
                Z = (short) (z*32 + 16),
                R = player.Position.R,
                L = player.Position.L
            });
            player.Message("Teleported to top");
        }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:25,代码来源:ModerationCommands.cs

示例7: BackHandler

		private static void BackHandler(Player player, CommandReader cmd) {
			if (player.LastPosition == null || player.LastWorld == null) {
				player.Message("Unknown last location!");
				return;
			}
			if (player.LastWorld != player.World) {
				player.JoinWorld(player.LastWorld, WorldChangeReason.ManualJoin, player.LastPosition);
			} else {
				player.TeleportTo(player.LastPosition);
				player.Message("Teleported to last location!");
			}
		}
开发者ID:Magi1053,项目名称:ProCraft,代码行数:12,代码来源:ModerationCommands.cs

示例8: TeleportPHandler

 static void TeleportPHandler(Player player, CommandReader cmd)
 {
     int x, y, z;
     int rot = player.Position.R;
     int lot = player.Position.L;
     
     if (cmd.NextInt(out x) && cmd.NextInt(out y) && cmd.NextInt(out z)) {
         if (cmd.NextInt(out rot) && cmd.NextInt(out lot)) {
             if (rot < 0 || rot > 255) {
                 player.Message("R must be inbetween 0 and 255, using player R");
                 rot = player.Position.R;
             }
             if (lot < 0 || lot > 255) {
                 player.Message("L must be inbetween 0 and 255, using player L");
                 lot = player.Position.L;
             }
         }
         
         if (x < short.MinValue || x > short.MaxValue || y < short.MinValue ||
             y > short.MaxValue || z < short.MinValue || z > short.MaxValue) {
             player.Message("Coordinates are outside the valid range!");
         } else {
             if (player.World != null) {
                 player.LastWorld = player.World;
                 player.LastPosition = player.Position;
             }
             player.TeleportTo(new Position((short)x, (short)y, (short)z, 
                                            (byte)rot, (byte)lot));
         }
     } else {
         CdTeleportP.PrintUsage(player);
     }
 }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:33,代码来源:ModerationCommands.cs

示例9: TeleportHandler

        private static void TeleportHandler(Player player, CommandReader cmd) {
            string name = cmd.Next();
            if (name == null) {
                CdTeleport.PrintUsage(player);
                return;
            }
            if (player.World.Name.ToLower() == "maze") {
                player.Message("Hey no cheating!");
                return;
            }
            if (name == "zone") {
                string zoneName = cmd.Next();
                if (zoneName == null) {
                    player.Message("No zone name specified. See &H/Help tpzone");
                    return;
                } else {
                    Zone zone = player.World.Map.Zones.Find(zoneName);
                    if (zone == null) {
                        player.MessageNoZone(zoneName);
                        return;
                    }
                    int zoneX = (zone.Bounds.XMin + zone.Bounds.XMax)/2;
                    int zoneY = (zone.Bounds.YMin + zone.Bounds.YMax)/2;
                    int zoneZ = (zone.Bounds.ZMin + zone.Bounds.ZMax)/2;
                    retry2:
                    if (player.World.map.GetBlock(zoneX, zoneY, zoneZ - 1) == Block.Air) {
                        zoneZ = zoneZ - 1;
                        goto retry2;
                    }
                    retry:
                    if (player.World.map.GetBlock(zoneX, zoneY, zoneZ) != Block.Air ||
                        player.World.map.GetBlock(zoneX, zoneY, zoneZ + 1) != Block.Air) {
                        zoneZ = zoneZ + 1;
                        goto retry;
                    }
					Position zPos = new Position((zoneX) * 32 + 16, (zoneY) * 32 + 16, (zoneZ) * 32 + 64);
					if (player.World != null) {
						player.LastWorld = player.World;
						player.LastPosition = player.Position;
					}
                    player.TeleportTo((zPos));
                    player.Message("&sTeleporting you to zone " + zone.ClassyName);
                    return;
                }
            }
            if (name == "random" || name == "rand") {
                Random rand = new Random();
                int x = rand.Next(0, player.WorldMap.Width);
                int y = rand.Next(0, player.WorldMap.Length);
                int z = player.Position.Z/32 + 1;
                retry2:
                if (player.World.map.GetBlock(x, y, z - 3) == Block.Air) {
                    z = z - 1;
                    goto retry2;
                }
                retry:
                if (player.World.map.GetBlock(x, y, z - 2) != Block.Air ||
                    player.World.map.GetBlock(x, y, z - 1) != Block.Air) {
                    z = z + 1;
                    goto retry;
                }

				if (player.World != null) {
					player.LastWorld = player.World;
					player.LastPosition = player.Position;
				}
                player.TeleportTo(new Position {
                    X = (short) (x*32 + 16),
                    Y = (short) (y*32 + 16),
                    Z = (short) (z*32 + 16),
                    R = player.Position.R,
                    L = player.Position.L
                });
                player.Message("Teleported to: ({0}, {1}, {2})", x, y, z);
                return;
            }

            if (cmd.Next() != null) {
                cmd.Rewind();
                int x, y, z, rot, lot;
                rot = player.Position.R;
                lot = player.Position.L;
                if (cmd.NextInt(out x) && cmd.NextInt(out y) && cmd.NextInt(out z)) {
                    if (cmd.HasNext) {
                        if (cmd.HasNext) {
                            if (cmd.NextInt(out rot) && cmd.NextInt(out lot)) {
                                if (rot > 255 || rot < 0) {
                                    player.Message("R must be inbetween 0 and 255. Set to player R");
                                }
                                if (lot > 255 || lot < 0) {
                                    player.Message("L must be inbetween 0 and 255. Set to player L");
                                }
                            }
                        }
                    }
                    if (x <= -1024 || x >= 1024 || y <= -1024 || y >= 1024 || z <= -1024 || z >= 1024) {
                        player.Message("Coordinates are outside the valid range!");

					} else {
						if (player.World != null) {
//.........这里部分代码省略.........
开发者ID:Magi1053,项目名称:ProCraft,代码行数:101,代码来源:ModerationCommands.cs

示例10: PossessHandler

        internal static void PossessHandler(Player player, Command cmd)
        {
            string name = cmd.Next();
            if (name == null)
            {
                CdPossess.PrintUsage(player);
                return;
            }

            if (!Player.IsValidName(name))
                return;

            else
            {

                Player target = Server.FindPlayerOrPrintMatches(player, name, true, true);

                if (target == null)
                {
                    return;
                }

                /*if (target == player)
                {
                    player.Message("You can't possess yourself.");
                    return;
                }*/

                if (player.Can(Permission.Possess, target.Info.Rank))
                {
                    Position P = target.Position;
                    player.TeleportTo(P);
                    Server.TargetName = target.Name;
                    Possess(player, cmd, target.Name);
                    player.Message("Now possessing " + target.Name);
                    return;
                }

                else
                {
                    player.Message("You can only Possess players ranked {0}&S or lower",
                                    player.Info.Rank.GetLimit(Permission.Possess).ClassyName);
                    player.Message("{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName);
                }
            }
        }
开发者ID:Desertive,项目名称:800craft,代码行数:46,代码来源:ModerationCommands.cs

示例11: TPHandler2

        static void TPHandler2(Player player, Command cmd)
        {
            string name = cmd.Next();
            if (name == null)
            {

                return;
            }

            if (cmd.Next() != null)
            {
                cmd.Rewind();
                int x, y, z;
                if (cmd.NextInt(out x) && cmd.NextInt(out y) && cmd.NextInt(out z))
                {

                    if (x <= -1024 || x >= 1024 || y <= -1024 || y >= 1024 || z <= -1024 || z >= 1024)
                    {
                        player.Message("Coordinates are outside the valid range!");

                    }
                    else
                    {
                        player.TeleportTo(new Position
                        {
                            X = (short)(x * 32 + 16),
                            Y = (short)(y * 32 + 16),
                            Z = (short)(z * 32 + 16),
                            R = player.Position.R,
                            L = player.Position.L
                        });
                    }
                }
                else
                {
                    return;
                }

            }
            else
            {
                Player[] matches = Server.FindPlayers(player, name, true);
                if (matches.Length == 1)
                {
                    Player target = matches[0];
                    World targetWorld = target.World;
                    if (targetWorld == null) PlayerOpException.ThrowNoWorld(target);

                    if (targetWorld == player.World)
                    {
                        player.TeleportTo(target.Position);

                    }
                    else
                    {
                        switch (targetWorld.AccessSecurity.CheckDetailed(player.Info))
                        {
                            case SecurityCheckResult.Allowed:
                            case SecurityCheckResult.WhiteListed:
                                if (targetWorld.IsFull)
                                {
                                    player.Message("Cannot teleport to {0}&S because world {1}&S is full.",
                                                    target.ClassyName,
                                                    targetWorld.ClassyName);
                                    return;
                                }
                                player.StopSpectating();
                                player.JoinWorld(targetWorld, WorldChangeReason.Tp, target.Position);
                                break;
                            case SecurityCheckResult.BlackListed:
                                player.Message("Cannot teleport to {0}&S because you are blacklisted on world {1}",
                                                target.ClassyName,
                                                targetWorld.ClassyName);
                                break;
                            case SecurityCheckResult.RankTooLow:
                                player.Message("Cannot teleport to {0}&S because world {1}&S requires {2}+&S to join.",
                                                target.ClassyName,
                                                targetWorld.ClassyName,
                                                targetWorld.AccessSecurity.MinRank.ClassyName);
                                break;
                            // TODO: case PermissionType.RankTooHigh:
                        }
                    }

                }
                else if (matches.Length > 1)
                {
                    player.MessageManyMatches("player", matches);

                }
                else
                {
                    // Try to guess if player typed "/TP" instead of "/Join"
                    World[] worlds = WorldManager.FindWorlds(player, name);

                    if (worlds.Length == 1)
                    {
                        player.LastUsedWorldName = worlds[0].Name;
                        player.StopSpectating();
                        player.ParseMessage("/Join " + worlds[0].Name, false);
//.........这里部分代码省略.........
开发者ID:Desertive,项目名称:800craft,代码行数:101,代码来源:ModerationCommands.cs

示例12: PatrolHandler

        static void PatrolHandler( Player player, Command cmd ) {
            World playerWorld = player.World;
            if( playerWorld == null ) PlayerOpException.ThrowNoWorld( player );

            Player target = playerWorld.GetNextPatrolTarget( player,
                                                             p => player.Can( Permission.Spectate, p.Info.Rank ),
                                                             true );
            if( target == null ) {
                player.Message( "Patrol: No one to spec-patrol in this world." );
                return;
            }

            player.TeleportTo( target.Position );
            player.Message( "Patrol: Teleporting to {0}", target.ClassyName );
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:15,代码来源:ModerationCommands.cs


注:本文中的Player.TeleportTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。