示例#1
0
        private static bool HandleStepSwitch(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData)
        {
            switch (Event)
            {
            case ItemEventType.InstanceLoaded:
            case ItemEventType.Moved:
            case ItemEventType.Placed:

                Item.RequestUpdate(1);
                break;

            case ItemEventType.UpdateTick:

                string Flags = "0";

                if (Instance.GetActorsOnPosition(Item.RoomPosition.GetVector2()).Count > 0)
                {
                    Flags = "1";
                }

                if (Item.DisplayFlags != Flags)
                {
                    Item.DisplayFlags = Flags;
                    Item.BroadcastStateUpdate(Instance);
                }

                Item.RequestUpdate(1);
                break;
            }

            return(true);
        }
示例#2
0
        private static void RecycleItems(Session Session, ClientMessage Message)
        {
            if (!mEnabled)
            {
                Session.SendData(NotificationMessageComposer.Compose("The recycler is temporarily disabled. Please check back later."));
                return;
            }

            int Amount = Message.PopWiredInt32();

            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

            if (Instance == null || Amount != 5)
            {
                return;
            }

            ItemDefinition Reward = ItemDefinitionManager.GetDefinition(GetRandomReward());

            if (Reward == null)
            {
                return;
            }

            List <Item> ItemsToRecycle = new List <Item>();

            for (int i = 0; i < 5; i++)
            {
                Item Item = Session.InventoryCache.GetItem(Message.PopWiredUInt32());

                if (Item == null || !Item.Definition.AllowRecycle || ItemsToRecycle.Contains(Item))
                {
                    return;
                }

                ItemsToRecycle.Add(Item);
            }

            Item NewItem = null;

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                foreach (Item Item in ItemsToRecycle)
                {
                    Session.InventoryCache.RemoveItem(Item.Id);
                    Item.RemovePermanently(MySqlClient);

                    Session.SendData(InventoryItemRemovedComposer.Compose(Item.Id));
                }

                NewItem = ItemFactory.CreateItem(MySqlClient, Reward.Id, Session.CharacterId, string.Empty, string.Empty,
                                                 0);
            }

            Session.InventoryCache.Add(NewItem);

            Session.SendData(RecyclerResultComposer.Compose(true, NewItem.Id));
            Session.SendData(InventoryItemAddedComposer.Compose(NewItem));
        }
示例#3
0
 //Call instance deco in room
 private void RoomInstanceDeco()
 {
     for (int i = 0; i < _rooms.Count; i++)
     {
         RoomInstance script = _rooms[i].GetComponent <RoomInstance>();
         script.AddSimpleDecoration(Random.Range(0, 3));
     }
 }
示例#4
0
 //Call instance in room
 private void RoomInstanceWall()
 {
     for (int i = 0; i < _rooms.Count; i++)
     {
         RoomInstance script = _rooms[i].GetComponent <RoomInstance>();
         script.BigWall();
     }
 }
示例#5
0
 public void AddToRoom(RoomInstance room, Transform e)
 {
     if (room.area.level.levelType != LevelType.Practice)
     {
         Transform t = GetRoom(room.index);
         e.transform.parent = t;
     }
 }
示例#6
0
    void SaveCurrentRoom()
    {
        RoomInstance tempRoomInstance = currentRoomGrid[4];

        tempRoomInstance.isVisited            = true;
        tempRoomInstance.roomStateDescription = "RoomHasBeenVisited";
        currentRoomGrid[4] = tempRoomInstance;
    }
示例#7
0
 public DoorInstance(OrthogonalLine doorLine, Vector2Int facingDirection, RoomBase connectedRoom, RoomInstance connectedRoomInstance)
 {
     this.doorLine              = doorLine;
     this.facingDirection       = facingDirection;
     this.connectedRoom         = connectedRoom;
     this.connectedRoomInstance = connectedRoomInstance;
     this.isHorizontal          = FacingDirection == Vector2Int.up || FacingDirection == Vector2Int.down;
 }
示例#8
0
        protected override void OnDisconnected()
        {
            $"Game TCP session with Id {Id} disconnected!".Info();

            // If they are in game, broadcast quit
            RoomInstance?.TryLeaveGame(this);
            Channel?.LeaveChannel(this);
        }
示例#9
0
 //Call pikes in room
 private void AddPikes()
 {
     for (int i = 0; i < _rooms.Count; i++)
     {
         RoomInstance script = _rooms[i].GetComponent <RoomInstance>();
         script.AddPikes();
     }
 }
        public void ExecuteRoomUnmute(int roomTo, int ignoreUser)
        {
            RoomInstance instance = InstanceManager.Game.Rooms.GetRoomInstance(roomTo);

            foreach (RoomUser user in instance.Users.Values)
            {
                instance.RemoveUniqueStatus(user.SessionID, "mute");
            }
        }
示例#11
0
        public override void OnSelfLeaveRoom(RoomInstance Instance)
        {
            if (mSelfActor == null)
            {
                return;
            }

            mSelfActor = null;
        }
示例#12
0
        private static bool HandleScoreboard(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData, uint Opcode)
        {
            switch (Event)
            {
            case ItemEventType.Interact:

                if (!Instance.CheckUserRights(Session))
                {
                    break;
                }

                RoomActor Actor = Instance.GetActorByReferenceId(Session.CharacterId);

                if (Actor == null)
                {
                    break;
                }

                if (!Distance.TilesTouching(Actor.Position.GetVector2(), Item.RoomPosition.GetVector2()))
                {
                    Actor.MoveToItemAndInteract(Item, RequestData, Opcode);
                    break;
                }

                int Val = 0;
                int.TryParse(Item.DisplayFlags, out Val);

                if (RequestData == 1)
                {
                    Val--;

                    if (Val < 0)
                    {
                        Val = 99;
                    }
                }
                else if (RequestData == 2)
                {
                    Val++;

                    if (Val > 99)
                    {
                        Val = 0;
                    }
                }
                else
                {
                    Val = (Val == -1 ? 0 : -1);
                }

                Item.DisplayFlags = Val.ToString();
                Item.BroadcastStateUpdate(Instance);
                break;
            }

            return(true);
        }
示例#13
0
 public IEnumerator EnterRoom(RoomInstance room)
 {
     if (curRoom != null)
     {
         yield return(EixtRoom(ExitRoomType.EnterNextRoom));
     }
     curRoom = room;
     yield return(curRoom.Enter());
 }
示例#14
0
        /// <summary>
        /// Creates a new room and returns its ID
        /// </summary>
        /// <returns></returns>
        public static int CreateRoom(RoomInstance room)
        {
            var id = Rooms.AddNext(room);

            room.Id = id;

            room.SettingsChanged();

            return(id);
        }
示例#15
0
        public override void OnSelfLeaveRoom(RoomInstance Instance)
        {
            if (mSelfActor == null)
            {
                return;
            }

            //mSelfActor.Chat("*leaves*", false);
            mSelfActor = null;
        }
示例#16
0
 public void Initialize(RoomInstance room, JRoomContentConfig contentConfig, string param)
 {
     this.room          = room;
     isInitialize       = false;
     isLoadingBath      = false;
     this.room          = room;
     this.contentConfig = contentConfig;
     curBatch           = -1;
     OnInitialize(room, contentConfig);
 }
示例#17
0
    static public RoomInstance Create(AreaInstance area, RoomData roomData)
    {
        GameObject   obj  = new GameObject("RoomInstance " + roomData.index + " " + roomData.roomType);
        RoomInstance room = obj.AddComponent <RoomInstance>();

        if (room.Initialize(area, roomData))
        {
            return(room);
        }
        return(null);
    }
        public void OnRoomEnter(RoomInstance roomInstance)
        {
            nextCurrentRoom = roomInstance;

            if (currentRoom == null)
            {
                currentRoom     = nextCurrentRoom;
                nextCurrentRoom = null;
                UpdateCurrentRoomInfo();
            }
        }
示例#19
0
 public void BroadcastStateUpdate(RoomInstance Instance)
 {
     if (mCachedDefinition.Type == ItemType.FloorItem)
     {
         Instance.BroadcastMessage(RoomFloorItemUpdateFlagsComposer.Compose(mId, mDisplayFlags));
     }
     else if (mCachedDefinition.Type == ItemType.WallItem)
     {
         Instance.BroadcastMessage(RoomWallItemMovedComposer.Compose(this));
     }
 }
示例#20
0
        private static void TradeComplete(Session Session, ClientMessage Message)
        {
            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

            if (Instance == null)
            {
                return;
            }

            Trade Trade = Instance.TradeManager.GetTradeForUser(Session.CharacterId);

            if (Trade == null)
            {
                return;
            }

            Session TargetSession = SessionManager.GetSessionByCharacterId(Trade.UserOne == Session.CharacterId ?
                                                                           Trade.UserTwo : Trade.UserOne);

            if (TargetSession == null || !Trade.AcceptTrade(Trade.UserOne == Session.CharacterId))
            {
                return;
            }

            if (Trade.TradeStage == TradeStage.Finalized)
            {
                Session User1 = (TargetSession.CharacterId == Trade.UserOne ? TargetSession : Session);
                Session User2 = (TargetSession.CharacterId == Trade.UserTwo ? TargetSession : Session);

                Trade.DeliverItems(User1, User2);

                Session.SendData(TradeFinalizedComposer.Compose());
                TargetSession.SendData(TradeFinalizedComposer.Compose());

                Instance.TradeManager.StopTradeForUser(Session.CharacterId);
                Instance.TradeManager.StopTradeForUser(TargetSession.CharacterId);

                RoomActor Actor1 = Instance.GetActorByReferenceId(Session.CharacterId);
                RoomActor Actor2 = Instance.GetActorByReferenceId(TargetSession.CharacterId);

                if (Actor1 != null)
                {
                    Actor1.RemoveStatus("trd");
                    Actor1.UpdateNeeded = true;
                }

                if (Actor2 != null)
                {
                    Actor2.RemoveStatus("trd");
                    Actor2.UpdateNeeded = true;
                }
            }
        }
示例#21
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        switch (collision.tag)
        {
        case "Room":
            currentRoom = collision.GetComponent <RoomInstance>();
            break;

        default:
            break;
        }
    }
示例#22
0
        public override void OnUserEnter(RoomInstance Instance, RoomActor Actor)
        {
            if (mSelfActor == null || Actor.Type == RoomActorType.AiBot)
            {
                return;
            }

            if (mSelfBot.Effect > 0)
            {
                mSelfActor.ApplyEffect(mSelfBot.Effect);
            }
        }
示例#23
0
    public IEnumerator EnterArea()
    {
        if (!isEnterArea)
        {
            isEnterArea = true;
            GameEvent.AreaEvent.FireOnBeforeEnterArea(level, this);
            RoomInstance room = GetRoomInstance(GetDefaultRoomData().index);
            yield return(EnterRoom(room));

            GameEvent.AreaEvent.FireOnEnterArea(level, this);
        }
    }
示例#24
0
        private static void GetPlaylist(Session Session, ClientMessage Message)
        {
            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

            if (Instance == null || !Instance.CheckUserRights(Session, true))
            {
                return;
            }

            Session.SendData(JukeboxPlaylistComposer.Compose(Instance.MusicController.PlaylistCapacity,
                                                             Instance.MusicController.Playlist.Values.ToList()));
        }
        public RoomInteractor(int roomId, RoomInstance rInstance)
        {
            mRoomInstance     = rInstance;
            mDefaultHeightmap = mRoomInstance.RoomInfo.DefaultHeightmap;
            mFloorFurni       = InstanceManager.Game.Furni.GetRoomFloorFurni(roomId);
            mWallFurni        = InstanceManager.Game.Furni.GetRoomWallFurni(roomId);
            GenerateMaps();
            mPlayerMap = new bool[mMatrix.GetUpperBound(0), mMatrix.GetUpperBound(1)];

            mThread = new Thread(RoomWorker);
            mThread.Start();
        }
示例#26
0
    private void Start()
    {
        doorPassSound = GetComponent <AudioSource>();

        defaultDoorColor = new Color(1f, 1f, 1f, 1f);
        lockedDoorColor  = new Color(1f, 0.2f, 0.2f, 1f);

        spriteRenderer = GetComponent <SpriteRenderer>();
        spriteRenderer.sortingOrder = 5;
        player     = FindObjectOfType <PlayerMovement>().gameObject;
        parentRoom = GetComponentInParent <RoomInstance>();
    }
示例#27
0
        public void Update(RoomInstance Instance)
        {
            if (mUpdateTicks > 0)
            {
                mUpdateTicks--;
            }

            if (mUpdateNeeded && mUpdateTicks <= 0)
            {
                mUpdateNeeded = false;
                ItemEventDispatcher.InvokeItemEventHandler(null, this, Instance, ItemEventType.UpdateTick);
            }
        }
示例#28
0
        public override void OnUserEnter(RoomInstance Instance, RoomActor Actor)
        {
            if (mSelfActor == null || Actor.ReferenceId != mSelfBot.PetData.OwnerId || Actor.Type != RoomActorType.UserCharacter ||
                (mCurrentAction != PetBotAction.Idle && mCurrentAction != PetBotAction.Roaming))
            {
                return;
            }

            if (RandomGenerator.GetNext(0, 1) == 1)
            {
                RespondToEvent("SEE_OWNER");
            }
        }
示例#29
0
 public static void InvokeItemEventHandler(Session Session, Item Item, RoomInstance Instance, ItemEventType Type, int RequestData = 0, uint Opcode = 0, bool checkrights = true)
 {
     if (mEventHandlers.ContainsKey(Item.Definition.Behavior))
     {
         foreach (ItemEventHandler EventHandler in mEventHandlers[Item.Definition.Behavior])
         {
             if (!EventHandler.Invoke(Session, Item, Instance, Type, RequestData, Opcode))
             {
                 return;
             }
         }
     }
 }
示例#30
0
 /// <summary>
 /// 调用房间
 /// </summary>
 /// <param name="targetRoom"></param>
 /// <returns></returns>
 public IEnumerator DoBuildRoom(RoomData roomData)
 {
     if (GetRoomInstance(roomData.index) != null)
     {
         Debug.LogError("房间 " + roomData.index + " 已经创建了");
     }
     else
     {
         RoomInstance room = RoomInstance.Create(this, roomData);
         m_Rooms.Add(room);
         yield return(room.BuildRoom(this));
     }
 }
示例#31
0
        /// <summary>
        /// Gets a room reference for a room with a specified id.
        /// If the room with the specified id does not exists, a new room will be created.
        /// </summary>
        /// <param name="roomName">
        /// The room id.
        /// </param>
        /// <param name="args">
        /// Optionally arguments used for room creation.
        /// </param>
        /// <returns>
        /// a <see cref="RoomReference"/>
        /// </returns>
        public RoomReference GetRoomReference(string roomName, params object[] args)
        {
            lock (this.syncRoot)
            {
                RoomInstance roomInstance;
                if (!this.roomInstances.TryGetValue(roomName, out roomInstance))
                {
                    if (log.IsDebugEnabled)
                    {
                        log.DebugFormat("Creating room instance: roomName={0}", roomName);
                    }

                    Room room = this.CreateRoom(roomName, args);
                    roomInstance = new RoomInstance(this, room);
                    this.roomInstances.Add(roomName, roomInstance);
                }

                return roomInstance.AddReference();
            }
        }
示例#32
0
        /// <summary>
        /// Tries to create a new room.
        /// </summary>
        /// <param name="roomName">
        /// The room id.
        /// </param>
        /// <param name="ownerPeer">
        /// The peer that holds this reference.
        /// </param>
        /// <param name="roomReference">
        /// When this method returns true, contains a new <see cref="RoomReference"/> for the room 
        /// with the specified room id; otherwise, set to null. 
        /// </param>
        /// <param name="args">
        /// Optionally arguments used for room creation.
        /// </param>
        /// <returns>
        /// False if the cache contains a room with the specified room id; otherwise, true.
        /// </returns>
        public bool TryCreateRoom(string roomName, PeerBase ownerPeer, out RoomReference roomReference, params object[] args)
        {
            lock (this.SyncRoot)
            {
                if (this.RoomInstances.ContainsKey(roomName))
                {
                    roomReference = null;
                    return false;
                }

                Room room = this.CreateRoom(roomName, args);
                var roomInstance = new RoomInstance(this, room);
                this.RoomInstances.Add(roomName, roomInstance);
                roomReference = roomInstance.AddReference(ownerPeer);
                return true;
            }
        }
示例#33
0
		public RTSLobby(RoomInstance room) {
			Console.WriteLine("[ RTS LOBBY ]");
			this.room = room;
		}
示例#34
0
		public RTSMatch(RoomInstance room) {
			Console.WriteLine("[ RTS MATCH ]");
			this.room = room;
		}