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


C# World.EnterWorld方法代码示例

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


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

示例1: GenRandomRoom

 public static bool GenRandomRoom(World world, float x, float y, Wall theWall)
 {
     try
     {
         Random rand = new Random();
         if (rand.Next(1, 60) != 1)
             return false;
         //Console.Out.WriteLine("Generating room...");
         List<string> dirs = new List<string>();
         for (int tx = -1; tx <= 1; tx++)
             for (int ty = -1; ty <= 1; ty++)
             {
                 WmapTile targetTile = world.Map[(int)x + tx, (int)y + ty];
                 WmapTile thisTile = world.Map[(int)x, (int)y];
                 if (targetTile.TileId == 0xff)
                 {
                     if (tx == -1 && ty == 0)
                         dirs.Add("left");
                     else if (tx == 1 && ty == 0)
                         dirs.Add("right");
                     else if (tx == 0 && ty == 1)
                         dirs.Add("down");
                     else if (tx == 0 && ty == -1)
                         dirs.Add("up");
                 }
             }
         if (dirs.Count < 1)
             return false;
         dirs.Shuffle();
         //Console.Out.WriteLine("Room direction: " + dirs.First());
         float mainX = x;
         float mainY = y;
         float entranceX = x;
         float entranceY = y;
         switch (dirs.First())
         {
             case "up":
                 mainX = x - 6; mainY = y - 8;
                 entranceY = y - 1; break;
             case "down":
                 mainX = x - 6; mainY = y + 1;
                 entranceY = y + 1; break;
             case "left":
                 mainX = x - 12; mainY = y - 3;
                 entranceX = x - 1; break;
             case "right":
                 mainX = x + 1; mainY = y - 3;
                 entranceX = x + 1; break;
         }
         List<WmapTile> addedTiles = new List<WmapTile>();
         for (int ty = (int)mainY; ty <= mainY + 7; ty++)
             for (int tx = (int)mainX; tx <= mainX + 11; tx++)
             {
                 WmapTile tTile = world.Map[tx, ty];
                 if (tTile.TileId != 0xff || tTile.ObjType != 0)
                 {
                     //Console.Out.WriteLine("Found collision while generating room!");
                     return false;
                 }
                 tTile.TileId = world.Map[(int)x, (int)y].TileId;
                 addedTiles.Add(tTile);
             }
         //Console.Out.WriteLine("Generated tiles, placing...");
         int tileNum = 0;
         for (int ty = (int)mainY; ty <= mainY + 7; ty++)
             for (int tx = (int)mainX; tx <= mainX + 11; tx++)
             {
                 WmapTile ctile = addedTiles[tileNum];
                 if ((tx == (int)mainX || tx == (int)mainX + 11 || ty == (int)mainY || ty == (int)mainY + 7) && !(tx == entranceX && ty == entranceY))
                 {
                     //Console.Out.WriteLine("Placed wall");
                     Wall e = new Wall(theWall.ObjectType, XmlDatas.TypeToElement[theWall.ObjectType]);
                     e.Move(tx, ty);
                     world.EnterWorld(e);
                     ctile.ObjType = theWall.ObjectType;
                 }
                 else
                 {
                     //Console.Out.WriteLine("Placed treasure");
                     if (rand.Next(1, 30) == 1)
                     {
                         Entity e = Entity.Resolve(XmlDatas.IdToType["Coral Gift"]);
                         e.Move(tx + 0.5f, ty + 0.5f);
                         world.EnterWorld(e);
                         ctile.ObjType = XmlDatas.IdToType["Coral Gift"];
                     }
                 }
                 world.Map[tx, ty] = ctile;
             }
         //Console.Out.WriteLine("Placed tiles!");
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
 }
开发者ID:RiiggedMPGH,项目名称:Owl-Realms-Source,代码行数:97,代码来源:GenLogic.cs

示例2: GenWall

 public static void GenWall(World world, float x, float y, Random rand)
 {
     short objType = 0x1960;
     List<Tuple<short,int>> ores = (world as Mine).GetOres();
     ores.Shuffle();
     if (rand.Next(0, ores.First().Item2) == 1)
     {
         objType = ores.First().Item1;
     }
     Wall e = new Wall(objType, XmlDatas.TypeToElement[objType]);
     e.Move(x, y);
     world.EnterWorld(e);
 }
开发者ID:Club559,项目名称:Mining,代码行数:13,代码来源:GenLogic.cs

示例3: GenRandomRoom


//.........这里部分代码省略.........
                                dirs.Add("down");
                            else if (tx == 0 && ty == -1)
                                dirs.Add("up");
                        }
                    }
                if(dirs.Count < 1)
                    return false;
                dirs.Shuffle();
                //Console.Out.WriteLine("Room direction: " + dirs.First());
                float mainX = x;
                float mainY = y;
                float entranceX = x;
                float entranceY = y;

                int rsX = 1;
                int rsY = 1;
                do
                    rsX = rand.Next(6, 12 + 1);
                while (rsX % 2 > 0);

                do
                    rsY = rand.Next(6, 12 + 1);
                while (rsY % 2 > 0);

                //Console.Out.WriteLine("Room size: " + rsX + ", " + rsY);

                switch (dirs.First())
                {
                    case "up":
                        mainX = x - (rsX / 2); mainY = y - rsY;
                        entranceY = y - 1; break;
                    case "down":
                        mainX = x - (rsX / 2); mainY = y + 1;
                        entranceY = y + 1; break;
                    case "left":
                        mainX = x - rsX; mainY = y - ((rsY - 2)/2);
                        entranceX = x - 1; break;
                    case "right":
                        mainX = x + 1; mainY = y - ((rsY - 2)/2);
                        entranceX = x + 1; break;
                }
                entranceX -= 0.5f;
                entranceY -= 0.5f;
                List<WmapTile> addedTiles = new List<WmapTile>();
                for(int ty = (int)mainY; ty <= mainY + (rsY - 1); ty++)
                    for (int tx = (int)mainX; tx <= mainX + (rsX - 1); tx++)
                    {
                        WmapTile tTile = world.Map[tx, ty];
                        if (tTile.TileId != 0xff || tTile.ObjType != 0)
                        {
                            Console.Out.WriteLine("Found collision while generating room!");
                            return false;
                        }
                        tTile.TileId = world.Map[(int)x, (int)y].TileId;
                        addedTiles.Add(tTile);
                    }
                //Console.Out.WriteLine("Generated tiles, placing...");
                int tileNum = 0;
                float blackPotSpotX = (float)rand.Next((int)mainX + 1, (int)mainX + rsX);
                float blackPotSpotY = (float)rand.Next((int)mainY + 1, (int)mainY + rsY);
                for(int ty = (int)mainY; ty <= mainY + (rsY - 1); ty++)
                    for (int tx = (int)mainX; tx <= mainX + (rsX - 1); tx++)
                    {
                        WmapTile ctile = addedTiles[tileNum];
                        world.Map[tx, ty] = ctile;
                        if ((tx == (int)mainX || tx == (int)mainX + (rsX - 1) || ty == (int)mainY || ty == (int)mainY + (rsY - 1)) && !(tx == entranceX && ty == entranceY))
                        {
                            //Console.Out.WriteLine(tx + ", " + ty + " - " + entranceX + ", " + entranceY);
                            //Console.Out.WriteLine("Placed wall");
                            GenWall(world, tx + 0.5f, ty + 0.5f, rand);
                        }
                        else
                        {
                            //Console.Out.WriteLine("Placed treasure");
                            if (rand.Next(1, 25) == 1)
                            {
                                if ((world as Mine).RoomsFound == 3 ? (tx != blackPotSpotX && ty != blackPotSpotY) : true)
                                {
                                    Entity e = Entity.Resolve((short)rand.Next(0x196f, 0x1972));
                                    e.Move(tx + 0.5f, ty + 0.5f);
                                    world.EnterWorld(e);
                                }
                            }
                        }
                    }
                (world as Mine).RoomsFound++;
                if ((world as Mine).RoomsFound == 4)
                {
                    Entity e = Entity.Resolve(XmlDatas.IdToType["Pot of Descent"]);
                    e.Move(blackPotSpotX + 0.5f, blackPotSpotY + 0.5f);
                    world.EnterWorld(e);
                }
                //Console.Out.WriteLine("Placed tiles!");
                return true;
            }
            catch(Exception e)
            {
                return false;
            }
        }
开发者ID:Club559,项目名称:Mining,代码行数:101,代码来源:GenLogic.cs

示例4: ShowBagsW

        public void ShowBagsW(Random rand, IEnumerable<Item> loots, Player owner, World entWorld)
        {
            int bagType = 0;
            Item[] items = new Item[8];
            int idx = 0;

            short bag;
            Container container;
            foreach (var i in loots)
            {
                if (i.BagType > bagType) bagType = i.BagType;
                items[idx] = i;
                idx++;

                if (idx == 8)
                {
                    bag = 0x0500;
                    switch (bagType)
                    {
                        case 0: bag = 0x0500; break;
                        case 1: bag = 0x0503; break;
                        case 2: bag = 0x0507; break;
                        case 3: bag = 0x0508; break;
                        case 4: bag = 0x0509; break;
                        case 5: bag = 0xffd; break;
                        case 6: bag = 0xffe; break;
                        case 7: bag = 0xfff; break;
                    }
                    container = new Container(bag, 1000 * 60, true);
                    for (int j = 0; j < 8; j++)
                        container.Inventory[j] = items[j];
                    container.BagOwner = owner == null ? (int?)null : owner.AccountId;
                    container.Move(
                        Host.Self.X,
                        Host.Self.Y);
                    container.Size = 80;
                    entWorld.EnterWorld(container);

                    bagType = 0;
                    items = new Item[8];
                    idx = 0;
                }
            }

            if (idx > 0)
            {
                bag = 0x0500;
                switch (bagType)
                {
                    case 0: bag = 0x0500; break;
                    case 1: bag = 0x0503; break;
                    case 2: bag = 0x0507; break;
                    case 3: bag = 0x0508; break;
                    case 4: bag = 0x0509; break;
                    case 5: bag = 0xffd; break;
                    case 6: bag = 0xffe; break;
                    case 7: bag = 0xfff; break;
                }
                container = new Container(bag, 1000 * 60, true);
                for (int j = 0; j < idx; j++)
                    container.Inventory[j] = items[j];
                container.BagOwner = owner == null ? (int?)null : owner.AccountId;
                container.Move(
                    Host.Self.X,
                    Host.Self.Y);
                container.Size = 80;
                if (entWorld != null) //was null sometimes
                {
                    entWorld.EnterWorld(container);
                }
            }
        }
开发者ID:Club559,项目名称:Mining,代码行数:72,代码来源:LootBehavior.cs


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