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


C# PlayerObject.TeleportRandom方法代碼示例

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


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

示例1: Act

        private void Act(IList<NPCActions> acts, PlayerObject player)
        {
            for (var i = 0; i < acts.Count; i++)
            {
                NPCActions act = acts[i];
                uint gold;
                uint count;
                string path;

                switch (act.Type)
                {
                    case ActionType.Teleport:
                        var map = SMain.Envir.GetMapByNameAndInstance((string)act.Params[0]);
                        if (map == null) return;

                        var coords = (Point)act.Params[1];

                        if (coords.X > 0 && coords.Y > 0) player.Teleport(map, coords);
                        else player.TeleportRandom(200, 0, map);
                        break;

                    case ActionType.InstanceTeleport:
                        map = SMain.Envir.GetMapByNameAndInstance((string)act.Params[0], (int)act.Params[1]);
                        if (map == null) return;
                        player.Teleport(map, (Point)act.Params[2]);
                        break;

                    case ActionType.GiveGold:
                        gold = (uint)act.Params[0];

                        if (gold + player.Account.Gold >= uint.MaxValue)
                            gold = uint.MaxValue - player.Account.Gold;

                        player.GainGold(gold);
                        break;

                    case ActionType.TakeGold:
                        gold = (uint)act.Params[0];

                        if (gold >= player.Account.Gold) gold = player.Account.Gold;

                        player.Account.Gold -= gold;
                        player.Enqueue(new S.LoseGold { Gold = gold });
                        break;

                    case ActionType.GiveItem:
                        count = (uint)act.Params[1];

                        while (count > 0)
                        {
                            UserItem item = SMain.Envir.CreateFreshItem((ItemInfo)act.Params[0]);

                            if (item == null)
                            {
                                SMain.Enqueue(string.Format("Failed to create UserItem: {0}, Page: {1}", act.Params[0], Key));
                                return;
                            }

                            if (item.Info.StackSize > count)
                            {
                                item.Count = count;
                                count = 0;
                            }
                            else
                            {
                                count -= item.Info.StackSize;
                                item.Count = item.Info.StackSize;
                            }

                            if (player.CanGainItem(item, false))
                                player.GainItem(item);
                        }
                        break;

                    case ActionType.TakeItem:
                        ItemInfo info = (ItemInfo)act.Params[0];

                        count = (uint)act.Params[1];

                        for (int o = 0; o < player.Info.Inventory.Length; o++)
                        {
                            UserItem item = player.Info.Inventory[o];
                            if (item == null) continue;
                            if (item.Info != info) continue;

                            if (count > item.Count)
                            {
                                player.Enqueue(new S.DeleteItem { UniqueID = item.UniqueID, Count = item.Count });
                                player.Info.Inventory[o] = null;

                                count -= item.Count;
                                continue;
                            }

                            player.Enqueue(new S.DeleteItem { UniqueID = item.UniqueID, Count = count });
                            if (count == item.Count)
                                player.Info.Inventory[o] = null;
                            else
                                item.Count -= count;
                            break;
//.........這裏部分代碼省略.........
開發者ID:WillMcKill,項目名稱:MirRage,代碼行數:101,代碼來源:NPCObject.cs


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