Esempio n. 1
0
        /// <summary>
        /// Join last room user was in.  If user hasn't ever been in a room, put him in a default public room
        /// </summary>
        public void JoinLastRoom()
        {
            UserAccountProxy userAccountProxy = GameFacade.Instance.RetrieveProxy <UserAccountProxy>();

            RoomId lastVisitedRoom = null;

            // Try and get last room from user properties, if it doesn't exist, use the default hardcoded room
            if (!userAccountProxy.TryGetAccountProperty <RoomId>(UserAccountProperties.LastRoomId, ref lastVisitedRoom))
            {
                lastVisitedRoom = mDefaultPublicRoomId;
            }

            Console.WriteLine("Going to last visited room: " + lastVisitedRoom.ToString());
            RoomAPICommands.SwitchRoom(lastVisitedRoom, MessageSubType.ClientOwnedRooms);
            GameFacade.Instance.SendNotification(GameFacade.SWITCHING_TO_GREEN_SCREEN_ROOM);
        }
Esempio n. 2
0
        public override void HandleNotification(INotification notification)
        {
            if (mRoomPickerGui == null)
            {
                Init();
            }
            switch (notification.Name)
            {
            case GameFacade.CLOSE_ALL_WINDOWS:
                mRoomPickerGui.Showing = false;
                mMapGui.Showing        = false;
                break;

            case GameFacade.TOGGLE_ROOM_PICKER_GUI:
                mRoomPickerGui.Showing = !mRoomPickerGui.Showing;
                if (mRoomPickerGui.Showing)
                {
                    MessageSubType roomRequestTypeToggleRoomPickerGui = (MessageSubType)notification.Body;
                    mRoomPickerGui.RequestRooms(roomRequestTypeToggleRoomPickerGui);
                }
                break;

            case GameFacade.SHOW_ROOM_PICKER_GUI:
                MessageSubType MessageSubTypehowRoomPickerGui = (MessageSubType)notification.Body;
                mRoomPickerGui.Showing = true;
                mRoomPickerGui.RequestRooms(MessageSubTypehowRoomPickerGui);
                break;

            case GameFacade.SHOW_SERVER_ROOM_API:
                RoomAPICommands.RequestRoomsFromServer(MessageSubType.ClientOwnedRooms);
                mRoomAPIGui.Showing = true;
                break;

            case GameFacade.ROOM_LOADING_STARTED:
                mCurrentRoomId = (RoomId)notification.Body;
                mRoomAPIGui.UpdateCurrentRoomId(mCurrentRoomId);
                break;

            case GameFacade.MAP_BUTTON_CLICKED:
                mMapGui.Showing = !mMapGui.Showing;
                break;
            }
        }
        public override void ExitState()
        {
            Console.WriteLine("GreenScreenRoomGameState.ExitState");

            GameFacade.Instance.RemoveMediator(typeof(GreenScreenRoomStateMachine).Name);

            RoomManagerProxy roomManagerProxy = GameFacade.Instance.RetrieveProxy <RoomManagerProxy>();

            if (roomManagerProxy != null && roomManagerProxy.CurrentRoom != null)
            {
                RoomId currentRoomId = roomManagerProxy.CurrentRoom.RoomId;
                RoomAPICommands.LeaveRoom(currentRoomId);
            }

            // Unregister Commands
            GameFacade.Instance.RemoveCommand(GameFacade.SEND_CHAT);
            GameFacade.Instance.RemoveCommand(GameFacade.RECV_CHAT);
            GameFacade.Instance.RemoveCommand(GameFacade.SEND_EMOTICON);
            GameFacade.Instance.RemoveCommand(GameFacade.RECV_EMOTICON);
        }