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


C# Player.ChangeLevel方法代码示例

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


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

示例1: Use

        // Code to run when used by a player
        public override void Use(Player p,string message)
        {
            bool blnLevelFound = false;
            Level targetLevel = null;
            if (message != "")
            {
                message = message.ToLower();
                if (p.level.name.ToLower() != message)
                {
                    foreach (Level level in Server.levels)
                    {
                        if (level.name.ToLower() == message)
                        {
                            targetLevel = level;
                            blnLevelFound = true;
                            break;
                        }
                    }
                    if (blnLevelFound)
                    {
                        if (targetLevel.PlayerCanVisit(p))
                        {
                            p.ChangeLevel(targetLevel);
                            if (!p.hidden)
                            {
                                Player.GlobalChat(p, p.color + "*" + p.name + "&e went to \"" + p.level.name + "\".", false);
                            }
                        }
                        else
                        {
                            p.SendMessage("You do not have perimssion to visit this level");
                        }
                    }
                    else
                    {
                        // Level either not found or non-existant

                        p.SendMessage("There is no level \"" + message + "\" loaded.");
                    }

                }
                else
                {
                    p.SendMessage("You are already on that level!");
                }
            }
            else
            {
                Help(p);
            }
        }
开发者ID:TaFinalDestination,项目名称:MCSharp,代码行数:52,代码来源:CmdGoto.cs

示例2: Use

        // Code to run when used by a player
        public override void Use(Player p, string message)
        {
            if (message != "")
            {
                if (Player.ValidName(message))
                {
                    Player target = Player.Find(message);
                    if (target != null)
                    {
                        // if the target is visible or your rank is higher than theirs, then teleport
                        if (!target.hidden || p.Rank > target.Rank)
                        {
                            if (p.level != target.level)
                            {
                                // Change levels if needed
                                p.ChangeLevel(target.level.name);
                            }
                            // Teleport to the player
                            unchecked
                            {
                                p.SendPos((byte)-1, target.pos[0], target.pos[1], target.pos[2], target.rot[0], 0);
                            }
                        }
                        else
                        {
                            // Player is offline
                            p.SendMessage("There is no player \"" + message + "\"!");
                        }
                    }
                    else
                    {
                        // Player is offline
                        p.SendMessage("There is no player \"" + message + "\"!");
                    }

                }
                else
                {
                    p.SendMessage("Invalid Name!");
                }
            }
            else
            {
                Help(p);
            }
        }
开发者ID:duaneking,项目名称:MCSharp,代码行数:47,代码来源:CmdTp.cs


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