コード例 #1
0
ファイル: Portal.cs プロジェクト: po-omena/NR-CORE
        public void CreateWorld(Player player)
        {
            World world = null;

            foreach (var p in Program.Resources.Worlds.Data.Values
                     .Where(p => p.portals != null && p.portals.Contains(ObjectType)))
            {
                if (p.id < 0)
                {
                    world = player.Manager.GetWorld(p.id);
                }
                else
                {
                    DynamicWorld.TryGetWorld(p, player.Client, out world);
                    world = player.Manager.AddWorld(world ?? new World(p));
                }
                break;
            }

            if (PlayerOpened)
            {
                world.PlayerDungeon = true;
                world.Opener        = Opener;
                world.Invites       = new HashSet <string>();
                world.Invited       = new HashSet <string>();
            }

            WorldInstance = world;
            WorldInstanceSet?.Invoke(this, world);
        }
コード例 #2
0
        private void AddWorld(ProtoWorld proto, bool actAsNexus = false)
        {
            int id;

            if (actAsNexus)
            {
                id = World.Nexus;
            }
            else
            {
                id = (proto.id < 0)
                    ? proto.id
                    : Interlocked.Increment(ref _nextWorldId);
            }

            World world;

            DynamicWorld.TryGetWorld(proto, null, out world);
            if (world != null)
            {
                AddWorld(id, world);
                return;
            }

            AddWorld(id, new World(proto));
        }
コード例 #3
0
ファイル: RealmManager.cs プロジェクト: smillyz/Valor-Server
        private void AddWorld(ProtoWorld proto, bool actAsNexus = false)
        {
            int id;

            if (actAsNexus)
            {
                id = World.Nexus;
            }
            else
            {
                id = (proto.id < 0)
                    ? proto.id
                    : Interlocked.Increment(ref _nextWorldId);
            }

            DynamicWorld.TryGetWorld(proto, null, out var world);
            if (world != null)
            {
                if (world is Marketplace && !Config.serverSettings.enableMarket)
                {
                    return;
                }

                AddWorld(id, world);
                return;
            }

            AddWorld(id, new World(proto));
        }
コード例 #4
0
        private static void Handle(Player player)
        {
            var cli = player.Client;

            if (cli.Account.RaidToken < 1)
            {
                player.SendError("You do not have an Alert to launch.");
                return;
            }

            if (cli.Account.Credits < 1000)
            {
                player.SendError("You do not have the required amount of gold to launch an Alert.");
                return;
            }

            var rnd = new Random();

            cli.Manager.Database.UpdateAlertToken(cli.Account, -1);
            player.AlertToken--;
            player.ForceUpdate(player.AlertToken);

            player.SendHelp("Launching Alert... Good luck!");
            var alertArea = player.Owner.Manager.Resources.Worlds[AlertAreas[rnd.Next(AlertAreas.Length)]];

            DynamicWorld.TryGetWorld(alertArea, player.Client, out var world);
            world = player.Owner.Manager.AddWorld(world ?? new World(alertArea));

            player.Owner.Timers.Add(new WorldTimer(8000, (w, t) => {
                player.Client.Reconnect(new Reconnect {
                    Host        = "",
                    Port        = 2050,
                    GameId      = world.Id,
                    Name        = world.SBName,
                    IsFromArena = false
                });
            }));
        }
コード例 #5
0
        private void AEUnlockPortal(RealmTime time, Item item, Position target, ActivateEffect eff)
        {
            var gameData = Manager.Resources.GameData;

            // find locked portal
            var portals = Owner.StaticObjects.Values
                          .Where(s => s is Portal && s.ObjectDesc.ObjectId.Equals(eff.LockedName) && s.DistSqr(this) <= 9)
                          .Select(s => s as Portal);

            if (!portals.Any())
            {
                return;
            }
            var portal = portals.Aggregate(
                (curmin, x) => (curmin == null || x.DistSqr(this) < curmin.DistSqr(this) ? x : curmin));

            if (portal == null)
            {
                return;
            }

            // get proto of world
            ProtoWorld proto;

            if (!Manager.Resources.Worlds.Data.TryGetValue(eff.DungeonName, out proto))
            {
                Log.Error("Unable to unlock portal. \"" + eff.DungeonName + "\" does not exist.");
                return;
            }

            if (proto.portals == null || proto.portals.Length < 1)
            {
                Log.Error("World is not associated with any portals.");
                return;
            }

            // create portal of unlocked world
            var portalType = (ushort)proto.portals[0];
            var uPortal    = Resolve(Manager, portalType) as Portal;

            if (uPortal == null)
            {
                Log.Error("Error creating portal: {0}", portalType);
                return;
            }

            var portalDesc  = gameData.Portals[portal.ObjectType];
            var uPortalDesc = gameData.Portals[portalType];

            // create world
            World world;

            if (proto.id < 0)
            {
                world = Manager.GetWorld(proto.id);
            }
            else
            {
                DynamicWorld.TryGetWorld(proto, Client, out world);
                world = Manager.AddWorld(world ?? new World(proto));
            }
            uPortal.WorldInstance = world;

            // swap portals
            if (!portalDesc.NexusPortal || !Manager.Monitor.RemovePortal(portal))
            {
                Owner.LeaveWorld(portal);
            }
            uPortal.Move(portal.X, portal.Y);
            uPortal.Name = uPortalDesc.DisplayId;
            var uPortalPos = new Position()
            {
                X = portal.X - .5f, Y = portal.Y - .5f
            };

            if (!uPortalDesc.NexusPortal || !Manager.Monitor.AddPortal(world.Id, uPortal, uPortalPos))
            {
                Owner.EnterWorld(uPortal);
            }

            // setup timeout
            if (!uPortalDesc.NexusPortal)
            {
                var timeoutTime = gameData.Portals[portalType].Timeout;
                Owner.Timers.Add(new WorldTimer(timeoutTime * 1000, (w, t) => w.LeaveWorld(uPortal)));
            }

            // announce
            Owner.BroadcastPacket(new Notification
            {
                Color    = new ARGB(0xFF00FF00),
                ObjectId = Id,
                Message  = "Unlocked by " + Name
            }, null);
            foreach (var player in Owner.Players.Values)
            {
                player.SendInfo(string.Format("{0} unlocked by {1}!", world.SBName, Name));
            }
        }