コード例 #1
0
ファイル: MapService.cs プロジェクト: wgq4812/revcore
        public void SpawnRxjhObject(RxjhObject obj, MapInstance instance)
        {
            var creature = obj as Creature;

            if (creature != null)
            {
                lock (instance.CreaturesLock)
                {
                    if (obj is Npc)
                    {
                        instance.AddNpc((Npc)obj);
                    }
                    else if (obj is Player)
                    {
                        instance.Players.Add((Player)obj);
                    }
                    else if (obj is Item)
                    {
                        instance.Items.Add((Item)obj);
                    }
                }

                creature.Instance = instance;
            }
        }
コード例 #2
0
        public static void Run(byte faction)
        {
            MapInstance map     = ServerManager.GenerateMapInstance(148, faction == 1 ? MapInstanceType.Act4ShipAngel : MapInstanceType.Act4ShipDemon, new InstanceBag());
            MapNpc      mapNpc1 = new MapNpc
            {
            };

            mapNpc1.Initialize(map);
            map.AddNpc(mapNpc1);
            MapNpc mapNpc2 = new MapNpc
            {
            };

            mapNpc2.Initialize(map);
            map.AddNpc(mapNpc2);
            Observable.Interval(TimeSpan.FromMinutes(1)).Subscribe(obs =>
            {
                OpenShip();
                Observable.Timer(TimeSpan.FromMinutes(1)).Subscribe(observer =>
                {
                    map.Broadcast(
                        UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("SHIP_MINUTE"), 0));
                    LockShip();
                });
                Observable.Timer(TimeSpan.FromSeconds(30)).Subscribe(observer =>
                {
                    map.Broadcast(UserInterfaceHelper.GenerateMsg(
                                      string.Format(Language.Instance.GetMessageFromKey("SHIP_SECONDS"), 30), 0));
                });
                Observable.Timer(TimeSpan.FromSeconds(50)).Subscribe(observer =>
                {
                    map.Broadcast(UserInterfaceHelper.GenerateMsg(
                                      string.Format(Language.Instance.GetMessageFromKey("SHIP_SECONDS"), 10), 0));
                });
                Observable.Timer(TimeSpan.FromMinutes(1)).Subscribe(observer =>
                {
                    map.Broadcast(
                        UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("SHIP_SETOFF"), 0));
                    List <ClientSession> sessions = map.Sessions.Where(s => s?.Character != null).ToList();
                    Observable.Timer(TimeSpan.FromSeconds(0)).Subscribe(x => TeleportPlayers(sessions));
                });
            });
        }