當前位置: 首頁>>代碼示例>>C#>>正文


C# Player.Spectate方法代碼示例

本文整理匯總了C#中fCraft.Player.Spectate方法的典型用法代碼示例。如果您正苦於以下問題:C# Player.Spectate方法的具體用法?C# Player.Spectate怎麽用?C# Player.Spectate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在fCraft.Player的用法示例。


在下文中一共展示了Player.Spectate方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SpectateHandler

        static void SpectateHandler( Player player, CommandReader cmd ) {
            string targetName = cmd.Next();
            if( targetName == null ) {
                PlayerInfo lastSpec = player.LastSpectatedPlayer;
                if( lastSpec != null ) {
                    Player spec = player.SpectatedPlayer;
                    if( spec != null ) {
                        player.Message( "Now spectating {0}", spec.ClassyName );
                    } else {
                        player.Message( "Last spectated {0}", lastSpec.ClassyName );
                    }
                } else {
                    CdSpectate.PrintUsage( player );
                }
                return;
            }

            Player target = Server.FindPlayerOrPrintMatches( player, targetName, false, false, true );
            if( target == null ) return;

            if( !player.Can( Permission.Spectate, target.Info.Rank ) ) {
                player.Message( "You may only spectate players ranked {0}&S or lower.",
                player.Info.Rank.GetLimit( Permission.Spectate ).ClassyName );
                player.Message( "{0}&S is ranked {1}",
                                target.ClassyName, target.Info.Rank.ClassyName );
                return;
            }

            if( !player.Spectate( target ) ) {
                player.Message( "Already spectating {0}", target.ClassyName );
            }
        }
開發者ID:fragmer,項目名稱:fCraft,代碼行數:32,代碼來源:ModerationCommands.cs

示例2: SpectateHandler

        static void SpectateHandler( Player player, Command cmd )
        {
            string targetName = cmd.Next();
            if( targetName == null ) {
                PlayerInfo lastSpec = player.LastSpectatedPlayer;
                if( lastSpec != null ) {
                    Player spec = player.SpectatedPlayer;
                    if( spec != null )
                    {
                        if (spec.World.Name != player.World.Name)
                        {
                            player.JoinWorld(spec.World, WorldChangeReason.SpectateTargetJoined);
                            player.Message("Joined " + spec.World.Name + " to continue spectating " + spec.ClassyName);
                        }
                        player.Message( "Now spectating {0}", spec.ClassyName );
                    }
                    else
                    {
                        player.Message( "Last spectated {0}", lastSpec.ClassyName );
                    }
                } else {
                    CdSpectate.PrintUsage( player );
                }
                return;
            }

            Player target = Server.FindPlayerOrPrintMatches( player, targetName, false, true );
            if( target == null ) return;

            if( target == player ) {
                player.Message( "You cannot spectate yourself." );
                return;
            }

            if( !player.Can( Permission.Spectate, target.Info.Rank ) ) {
                player.Message( "You may only spectate players ranked {0}&S or lower.",
                player.Info.Rank.GetLimit( Permission.Spectate ).ClassyName );
                player.Message( "{0}&S is ranked {1}",
                                target.ClassyName, target.Info.Rank.ClassyName );
                return;
            }

            if( !player.Spectate( target ) ) {
                player.Message( "Already spectating {0}", target.ClassyName );
            }
        }
開發者ID:EricKilla,項目名稱:LegendCraft,代碼行數:46,代碼來源:ModerationCommands.cs

示例3: SpecPatrolHandler

        static void SpecPatrolHandler( Player player, CommandReader 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;
            }

            target.LastPatrolTime = DateTime.UtcNow;
            player.Spectate( target );
        }
開發者ID:fragmer,項目名稱:fCraft,代碼行數:15,代碼來源:ModerationCommands.cs

示例4: SpecPatrolHandler

        static void SpecPatrolHandler( Player player, Command 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;
            }

            target.LastPatrolTime = DateTime.UtcNow;
            player.Spectate( target );
        }
開發者ID:Desertive,項目名稱:800craft,代碼行數:13,代碼來源:ModerationCommands.cs


注:本文中的fCraft.Player.Spectate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。