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


C# Player.GetMaxMaps方法代码示例

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


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

示例1: Use


//.........这里部分代码省略.........
                string name = parameters[0].ToLower();
                int mapnumber = 0;
                ushort x = 1, y = 1, z = 1;
                int seed = 0;
                bool useSeed = false;
                try
                {
                    x = Convert.ToUInt16(parameters[1]);
                    y = Convert.ToUInt16(parameters[2]);
                    z = Convert.ToUInt16(parameters[3]);
                }
                catch { Player.SendMessage(p, "Invalid dimensions."); return; }
                if (parameters.Length == 6)
                {
                    try { seed = Convert.ToInt32(parameters[5]); }
                    catch { seed = parameters[5].GetHashCode(); }
                    useSeed = true;
                }
                if (!isGood(x)) { Player.SendMessage(p, x + " is not a good dimension! Use a power of 2 next time."); }
                if (!isGood(y)) { Player.SendMessage(p, y + " is not a good dimension! Use a power of 2 next time."); }
                if (!isGood(z)) { Player.SendMessage(p, z + " is not a good dimension! Use a power of 2 next time."); }

                if (!Player.ValidName(name)) { Player.SendMessage(p, "Invalid name!"); return; }
                //if (System.IO.File.Exists("levels/" + name + ".lvl")) { Player.SendMessage(p, "Level \"" + name + "\" already exists!"); return; }

                StringBuilder dir = new StringBuilder("levels/" + name);
                dir.Append(mapnumber != 0 ? "." + mapnumber.ToString() : "");
                dir.Append(".lvl");

                while (System.IO.File.Exists(dir.ToString()))
                {
                    if (p != null)
                    {
                        if (mapnumber < p.GetMaxMaps())
                        {
                            Server.s.Log(mapnumber.ToString());
                            Server.s.Log(dir.ToString());
                            Server.s.Log(p.GetMaxMaps().ToString());
                            mapnumber++;
                            dir = null;
                            dir = new StringBuilder("levels/" + name);
                            dir.Append(mapnumber != 0 ? "." + mapnumber.ToString() : "");
                            dir.Append(".lvl");
                        }
                        else { Player.SendMessage(p, "You have used up your maps!"); return; }
                    }
                    else { Player.SendMessage(p, "Level \"" + name + "\" already exists!"); return; }
                }

                name = name + "." + mapnumber.ToString();

                /*retry:
                StringBuilder dir = new StringBuilder("levels/" + name);
                dir.Append(mapnumber != 0 ? "." + mapnumber.ToString() : "");
                dir.Append(".lvl");
                if (System.IO.File.Exists(dir.ToString()))
                {
                    if (p != null)
                    {
                        if (mapnumber <= p.GetMaxMaps())
                        {
                            mapnumber++;
                            goto retry;
                        }
                        else { Player.SendMessage(p, "You have used up your maps!"); return; }
                    }
开发者ID:Cazzar,项目名称:MCaznowl-Build,代码行数:67,代码来源:CmdNewLvl.cs


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