コード例 #1
0
 public IList <IChatAspect> Load(RoomReference reference)
 {
     return(_chatRepository
            .FindByRoom(reference.Code)
            .Select(_chatAspectMapper.Map)
            .ToList());
 }
コード例 #2
0
        /// <summary>
        ///   Joins the peer to a <see cref = "LiteLobbyGame" />.
        ///   Called by <see cref = "HandleJoinOperation">HandleJoinOperation</see>.
        ///   Overridden to inject custom discussion rooms
        /// </summary>
        /// <param name = "joinOperation">
        ///   The join operation.
        /// </param>
        /// <param name = "sendParameters">
        ///   The send Parameters.
        /// </param>
        protected override void HandleJoinGameWithLobby(JoinRequest joinOperation, SendParameters sendParameters)
        {
            _dbId = (int)joinOperation.ActorProperties[(byte)ActProps.DbId];
            var devType = (int)joinOperation.ActorProperties[(byte)ActProps.DevType];

            handleOnlineStatus(_photonPer, _dbId, true, devType);

            // remove the peer from current game if the peer
            // allready joined another game
            this.RemovePeerFromCurrentRoom();

            // get a game reference from the game cache
            // the game will be created by the cache if it does not exists allready
            RoomReference gameReference = DiscussionGameCache.Instance.GetRoomReference(joinOperation.GameId,
                                                                                        joinOperation.LobbyId);

            // save the game reference in peers state
            this.RoomReference = gameReference;

            // enqueue the operation request into the games execution queue
            gameReference.Room.EnqueueOperation(this, joinOperation.OperationRequest, sendParameters);

            ////no base.HandleJoinGameWithLobby(), we've duplicated all its code here

            RoomReference lobbyReference = DiscussionLobbyCache.Instance.GetRoomReference(joinOperation.LobbyId);
            var           discLobby      = lobbyReference.Room as DiscussionLobby;

            if (discLobby != null)
            {
                discLobby.SaveRoomName(joinOperation.GameId);
            }
        }
コード例 #3
0
        public IRoomAspect Load(RoomReference reference)
        {
            var roomEntity   = _roomRepository.FindById(reference.Code);
            var participants = _participantRepository.FindByRoom(reference.Code);

            return(_roomAspectMapper.Map(roomEntity, participants));
        }
コード例 #4
0
        public void Create(string loginToken, LearningRoomModel model)
        {
            var login         = _loginTokenGateway.Get(loginToken);
            var roomReference = new RoomReference(Guid.NewGuid().ToString());

            var roomAspct = new RoomAspect
            {
                Reference        = roomReference,
                CreatedBy        = login.OpenId,
                CreatedOn        = DateTime.Parse(model.CreatedOn),
                EndDate          = DateTime.Parse(model.EndDate),
                LearningContent  = model.LearningContent,
                Place            = model.Place,
                ParticipantCount = model.ParticipantCount,
                StartDate        = DateTime.Parse(model.StartDate),
                Title            = model.Title,
                Participants     = new List <Participant>
                {
                    new Participant
                    {
                        Reference = new ParticipantReference(Guid.NewGuid().ToString()),
                        IsDeleted = false,
                        Room      = roomReference,
                        User      = login.OpenId
                    }
                }
            };

            _learningRoomSynchronizor.Add(new LearningRoomDomain(roomAspct));
        }
コード例 #5
0
    public void NewRoom(ref RoomReference roomReference)
    {
        this.roomReference = roomReference;

        SetupExits();
        SetupObjects();
    }
コード例 #6
0
ファイル: LiteLobbyPeer.cs プロジェクト: JasoonS/TotalTempo2
        /// <summary>
        ///   Joins the peer to a <see cref = "LiteLobbyGame" />.
        ///   Called by <see cref = "HandleJoinOperation">HandleJoinOperation</see>.
        /// </summary>
        /// <param name = "joinOperation">
        ///   The join operation.
        /// </param>
        /// <param name = "sendParameters">
        ///   The send Parameters.
        /// </param>
        protected virtual void HandleJoinGameWithLobby(JoinRequest joinOperation, SendParameters sendParameters)
        {
            // remove the peer from current game if the peer
            // allready joined another game
            this.RemovePeerFromCurrentRoom();

            RoomReference gameReference = null;

            if (joinOperation.ActorNr == 0)
            {
                // get a game reference from the game cache
                // the game will be created by the cache if it does not exists allready
                gameReference = LiteLobbyGameCache.Instance.GetRoomReference(joinOperation.GameId, this, joinOperation.LobbyId);
            }
            else
            {
                if (!LiteLobbyGameCache.Instance.TryGetRoomReference(joinOperation.GameId, this, out gameReference))
                {
                    SendOperationResponse(
                        new OperationResponse
                    {
                        OperationCode = joinOperation.OperationRequest.OperationCode,
                        ReturnCode    = -1,
                        DebugMessage  = "the specified game is not exists."
                    },
                        sendParameters);
                    return;
                }
            }
            // save the game reference in peers state
            this.RoomReference = gameReference;

            // enqueue the operation request into the games execution queue
            gameReference.Room.EnqueueOperation(this, joinOperation.OperationRequest, sendParameters);
        }
コード例 #7
0
        protected virtual void HandleLeaveOperation(OperationRequest operationRequest, SendParameters sendParameters)
        {
            // check if the peer have a reference to game
            if (RoomReference == null)
            {
                if (Log.IsDebugEnabled)
                {
                    Log.DebugFormat("Received leave operation on peer without a game: peerId={0}", ConnectionId);
                }

                return;
            }

            // enqueue the leave operation into game queue.
            RoomReference.Room.EnqueueOperation(this, operationRequest, sendParameters);

            // release the reference to the game
            // the game cache will recycle the game instance if no
            // more refrences to the game are left.
            RoomReference.Dispose();

            // finally the peers state is set to null to indicate
            // that the peer is not attached to a room anymore.
            RoomReference = null;
        }
コード例 #8
0
        public ILearningRoomWithChats Load(RoomReference reference)
        {
            var roomAspect   = _roomAspectLoader.Load(reference);
            var chatsAspects = _chatAspectLoader.Load(reference);

            return(new LearningRoomWithChats(roomAspect)
            {
                ChatAspects = chatsAspects
            });
        }
コード例 #9
0
        public ILearningRoomWithSignIn Load(RoomReference reference)
        {
            var roomAspect    = _roomAspectLoader.Load(reference);
            var signInAspects = _signInAspectLoader.Load(reference);

            return(new LearningRoomWithSignIn(roomAspect)
            {
                SignIns = signInAspects
            });
        }
コード例 #10
0
    public void NewLevel()
    {
        TunnelBP      tunnelBP;
        RoomReference firstLeftTunnelRoom;
        RoomReference firstRightTunnelRoom;

        //create both tunnels traveling left and right
        int[][] leftTunnel  = SetupTunnel();
        int[][] rightTunnel = SetupTunnel();

        //this is the setup for the core blueprint
        do
        {
            tunnelBP = SetupCoreBlueprint();
        }while(tunnelBP.levelBP == null);

        coreRoomReference      = tunnelBP.roomReference;
        tunnelBP.roomReference = null;
        tunnelBP.levelBP       = null;

        //this is to setup the left tunnel blueprint
        //tunnelBP = SetupTunnelBlueprint(true, leftTunnel, levelBlueprint, coreRoomReference);
        do
        {
            tunnelBP = SetupTunnelBlueprint(true, leftTunnel, levelBlueprint, coreRoomReference);
        }while(tunnelBP.levelBP == null);

        firstLeftTunnelRoom = tunnelBP.roomReference;
        coreRoomReference.children.Add(firstLeftTunnelRoom);
        levelBlueprint         = tunnelBP.levelBP;
        tunnelBP.roomReference = null;
        tunnelBP.levelBP       = null;

        //this is to setup the right tunnel blueprint
        //tunnelBP = SetupTunnelBlueprint(false, rightTunnel, levelBlueprint, coreRoomReference);
        do
        {
            tunnelBP = SetupTunnelBlueprint(false, rightTunnel, levelBlueprint, coreRoomReference);
        }while(tunnelBP.levelBP == null);

        firstRightTunnelRoom = tunnelBP.roomReference;
        coreRoomReference.children.Add(firstRightTunnelRoom);
        levelBlueprint         = tunnelBP.levelBP;
        tunnelBP.roomReference = null;
        tunnelBP.levelBP       = null;

        if (debugMode)
        {
            //DebugRoomReference(coreRoomReference);
        }

        //Takes the first room reference and constructs the level from it
        ConstructLevel(coreRoomReference);
    }
コード例 #11
0
        private void broadcastOnlineListChanged()
        {
            RoomReference lobbyReference = DiscussionLobbyCache.Instance.GetRoomReference(DISCUSSION_LOBBY);
            var           dLobby         = lobbyReference.Room as DiscussionLobby;

            if (dLobby != null)
            {
                dLobby.AllRoomsBroadcast(null, new OperationRequest(), new SendParameters(),
                                         (byte)DiscussionEventCode.InstantUserPlusMinus);
            }
        }
コード例 #12
0
        private static bool DisposeRoomReference(RoomReference r)
        {
            if (r == null)
            {
                return(true);
            }

            // release the reference to the game
            // the game cache will recycle the game instance if no
            // more refrences to the game are left.
            r.Dispose();
            return(false);
        }
コード例 #13
0
 public RoomReference(int x, int y, int type, int[] exits, int entrance, int roomsFirstExit, int roomsSecondExit, RoomReference parent)
 {
     this.x                 = x;
     this.y                 = y;
     this.type              = type;
     this.exits[0]          = exits[0];
     this.exits[1]          = exits[1];
     this.exits[2]          = exits[2];
     this.exits[3]          = exits[3];
     this.entrance          = entrance;
     this.exitReferences[0] = roomsFirstExit;
     this.exitReferences[1] = roomsSecondExit;
     this.parent            = parent;
 }
コード例 #14
0
        protected virtual void RemovePeerFromCurrentRoom()
        {
            // check if the peer already joined another game
            if (RoomReference != null)
            {
                // remove peer from his current game.
                var message = new RoomMessage((byte)GameMessageCodes.RemovePeerFromGame, this);
                RoomReference.Room.EnqueueMessage(message);

                // release room reference
                RoomReference.Dispose();
                RoomReference = null;
            }
        }
コード例 #15
0
        /// <summary>
        ///   Joins the peer to a <see cref = "LiteLobby" />.
        ///   Called by <see cref = "HandleJoinOperation">HandleJoinOperation</see>.
        /// </summary>
        /// <param name = "joinRequest">
        ///   The join operation.
        /// </param>
        /// <param name = "sendParameters">
        ///   The send Parameters.
        /// </param>
        protected virtual void HandleJoinLobby(JoinRequest joinRequest, SendParameters sendParameters)
        {
            // remove the peer from current game if the peer
            // allready joined another game
            this.RemovePeerFromCurrentRoom();

            // get a lobby reference from the game cache
            // the lobby will be created by the cache if it does not exists allready
            RoomReference lobbyReference = LiteLobbyRoomCache.Instance.GetRoomReference(joinRequest.GameId);

            // save the lobby(room) reference in peers state
            this.RoomReference = lobbyReference;

            // enqueue the operation request into the games execution queue
            lobbyReference.Room.EnqueueOperation(this, joinRequest.OperationRequest, sendParameters);
        }
コード例 #16
0
    TunnelBP SetupCoreBlueprint()
    {
        levelBlueprint = new int[levelWidth, levelHeight];
        levelBlueprint[levelWidth / 2, levelHeight / 2] = 1;
        int[] newExits = new int[4];
        newExits[1] = 1;
        newExits[3] = 1;

        RoomReference roomReference = new RoomReference(levelWidth / 2, levelHeight / 2, 1, newExits, 0, 3, 1, null);

        if (debugMode)
        {
            DebugBlueprint(1, levelWidth / 2, levelHeight / 2);
        }                                                             //leave this here for debug purposes, shows where the display was called from
        return(new TunnelBP(levelBlueprint, roomReference));
    }
コード例 #17
0
        public async Task CreateChatMessage(string loginToken, string roomId, string message)
        {
            var login         = _loginTokenGateway.Get(loginToken);
            var roomReference = new RoomReference(roomId, CacheField.Room);
            var learningRoom  = _learningRoomGateway.Load(roomReference);

            learningRoom.ChatAspects.Add(new ChatAspect
            {
                Reference = new ChatReference(Guid.NewGuid().ToString()),
                Room      = roomReference,
                Content   = message,
                CreatedBy = login.OpenId,
                CreatedOn = DateTimeUtil.GetNow()
            });

            await Task.Run(() => _learningRoomWithChatsSynchronizor.Update(learningRoom));
        }
コード例 #18
0
ファイル: LitePeer.cs プロジェクト: cernysw/UnityDemo
        /// <summary>
        ///   Called when client disconnects.
        ///   Ensures that disconnected players leave the game <see cref = "Room" />.
        ///   The player is not removed immediately but a message is sent to the room. This avoids
        ///   threading issues by making sure the player remove is not done concurrently with operations.
        /// </summary>
        protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail)
        {
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("OnDisconnect: conId={0}, reason={1}, reasonDetail={2}", this.ConnectionId, reasonCode, reasonDetail);
            }

            if (this.RoomReference == null)
            {
                return;
            }

            var message = new RoomMessage((byte)GameMessageCodes.RemovePeerFromGame, this);

            this.RoomReference.Room.EnqueueMessage(message);
            this.RoomReference.Dispose();
            this.RoomReference = null;
        }
コード例 #19
0
 //recursively display the children of the room references?
 void DebugRoomReference(RoomReference roomRef)
 {
     if (roomRef.children.Count == 0)
     {
         Debug.Log("Room Type: " + roomRef.type);
         Debug.Log("End of path");
     }
     else if (roomRef.children.Count == 1)
     {
         Debug.Log("Room Type: " + roomRef.type);
         DebugRoomReference(roomRef.children[0]);
     }
     else if (roomRef.children.Count == 2)
     {
         Debug.Log("Room Type: " + roomRef.type);
         DebugRoomReference(roomRef.children[0]);
         DebugRoomReference(roomRef.children[1]);
     }
 }
コード例 #20
0
    //Removes a powered up room from the wave spawn list and adds its children to the list in its place.
    public void PowerUpRoom(RoomReference roomRef)
    {
        if (transformerUpgradeCost == transformerUpgradeTally)
        {
            transformerUpgradeTally = 0;
            transformerUpgradeCost++;
        }
        else
        {
            transformerUpgradeTally++;
        }

        waveSpawnRooms.Remove(roomRef);

        foreach (RoomReference child in roomRef.children)
        {
            waveSpawnRooms.Add(child);
        }
    }
コード例 #21
0
 public void AllRoomsBroadcast(LitePeer peer,
                               OperationRequest operationRequest,
                               SendParameters sendParameters,
                               byte EventCode)
 {
     foreach (string roomName in roomList)
     {
         RoomReference  rr             = DiscussionGameCache.Instance.GetRoomReference(roomName);
         DiscussionRoom discussionRoom = rr.Room as DiscussionRoom;
         if (discussionRoom != null)
         {
             discussionRoom.Broadcast(peer,
                                      operationRequest,
                                      sendParameters,
                                      EventCode,
                                      BroadcastTo.RoomAll);
         }
     }
     BroadcastLobby(operationRequest, sendParameters, EventCode);
 }
コード例 #22
0
        protected virtual void HandleJoinOperation(OperationRequest operationRequest, SendParameters sendParameters)
        {
            // create join operation
            var joinRequest = new JoinRequest(Protocol, operationRequest);

            if (ValidateOperation(joinRequest, sendParameters) == false)
            {
                return;
            }

            // remove peer from current game
            RemovePeerFromCurrentRoom();

            // get a game reference from the game cache
            // the game will be created by the cache if it does not exists already
            var gameReference = GetRoomReference(joinRequest);

            // save the game reference in the peers state
            RoomReference = gameReference;

            // finally enqueue the operation into game queue
            gameReference.Room.EnqueueOperation(this, operationRequest, sendParameters);
        }
コード例 #23
0
        //overritten to inject discussion lobby cache
        /// <summary>
        ///   Joins the peer to a <see cref = "LiteLobby" />.
        ///   Called by <see cref = "HandleJoinOperation">HandleJoinOperation</see>.
        /// </summary>
        /// <param name = "joinRequest">
        ///   The join operation.
        /// </param>
        /// <param name = "sendParameters">
        ///   The send Parameters.
        /// </param>
        protected override void HandleJoinLobby(JoinRequest joinRequest, SendParameters sendParameters)
        {
            _dbId = (int)joinRequest.ActorProperties[(byte)ActProps.DbId];
            var devType = (int)joinRequest.ActorProperties[(byte)ActProps.DevType];

            handleOnlineStatus(_photonPer, _dbId, true, devType);

            // remove the peer from current game if the peer
            // allready joined another game
            this.RemovePeerFromCurrentRoom();

            // get a lobby reference from the game cache
            // the lobby will be created by the cache if it does not exists allready
            RoomReference lobbyReference = DiscussionLobbyCache.Instance.GetRoomReference(joinRequest.GameId);

            // save the lobby(room) reference in peers state
            this.RoomReference = lobbyReference;

            // enqueue the operation request into the games execution queue
            lobbyReference.Room.EnqueueOperation(this, joinRequest.OperationRequest, sendParameters);

            lobbyReference.Room.EnqueueOperation(this, new OperationRequest((byte)DiscussionOpCode.NotifyLeaveUser),
                                                 sendParameters);
        }
コード例 #24
0
    void ConstructLevel(RoomReference roomRef)
    {
        //what I need to do is take the core rooms reference
        //if its type is zero place the room at its coordantes
        //add the room itsself to its reference.
        //ensure the rooms exits are correct based on its parents exit

        //I NEED EACH ROOM REFERENCE TO HAVE A CLEAR UNDERSTANDING OF ITS OWN EXIT TYPES, 1 OR 2


        //checks if the room is the core, in which case has a custom placement
        if (roomRef.type == 1)
        {
            roomRef.room          = Instantiate(CoreRoom, new Vector3(roomRef.x * roomWidth, roomRef.y * roomHeight, 0), Quaternion.identity, RoomContainer.transform);
            roomRef.isRoomPowered = true;
        }
        else
        {
            //This block of statments checks what exits are being used and selects from the opproperate list to use for the room.
            if (roomRef.exits[0] != 0 && roomRef.exits[1] != 0 && roomRef.exits[2] != 0)
            {
                roomRef.room = Instantiate(URDRooms[Random.Range(0, URDRooms.Length)], new Vector3(roomRef.x * roomWidth, roomRef.y * roomHeight, 0), Quaternion.identity, RoomContainer.transform);
            }
            else if (roomRef.exits[1] != 0 && roomRef.exits[2] != 0 && roomRef.exits[3] != 0)
            {
                roomRef.room = Instantiate(RDLRooms[Random.Range(0, RDLRooms.Length)], new Vector3(roomRef.x * roomWidth, roomRef.y * roomHeight, 0), Quaternion.identity, RoomContainer.transform);
            }
            else if (roomRef.exits[0] != 0 && roomRef.exits[2] != 0 && roomRef.exits[3] != 0)
            {
                roomRef.room = Instantiate(UDLRooms[Random.Range(0, UDLRooms.Length)], new Vector3(roomRef.x * roomWidth, roomRef.y * roomHeight, 0), Quaternion.identity, RoomContainer.transform);
            }
            else if (roomRef.exits[0] != 0 && roomRef.exits[1] != 0 && roomRef.exits[3] != 0)
            {
                roomRef.room = Instantiate(URLRooms[Random.Range(0, URLRooms.Length)], new Vector3(roomRef.x * roomWidth, roomRef.y * roomHeight, 0), Quaternion.identity, RoomContainer.transform);
            }
            else if (roomRef.exits[0] != 0 && roomRef.exits[3] != 0)
            {
                roomRef.room = Instantiate(ULRooms[Random.Range(0, ULRooms.Length)], new Vector3(roomRef.x * roomWidth, roomRef.y * roomHeight, 0), Quaternion.identity, RoomContainer.transform);
            }
            else if (roomRef.exits[0] != 0 && roomRef.exits[2] != 0)
            {
                roomRef.room = Instantiate(UDRooms[Random.Range(0, UDRooms.Length)], new Vector3(roomRef.x * roomWidth, roomRef.y * roomHeight, 0), Quaternion.identity, RoomContainer.transform);
            }
            else if (roomRef.exits[0] != 0 && roomRef.exits[1] != 0)
            {
                roomRef.room = Instantiate(URRooms[Random.Range(0, URRooms.Length)], new Vector3(roomRef.x * roomWidth, roomRef.y * roomHeight, 0), Quaternion.identity, RoomContainer.transform);
            }
            else if (roomRef.exits[3] != 0 && roomRef.exits[2] != 0)
            {
                roomRef.room = Instantiate(LDRooms[Random.Range(0, LDRooms.Length)], new Vector3(roomRef.x * roomWidth, roomRef.y * roomHeight, 0), Quaternion.identity, RoomContainer.transform);
            }
            else if (roomRef.exits[3] != 0 && roomRef.exits[1] != 0)
            {
                roomRef.room = Instantiate(LRRooms[Random.Range(0, LRRooms.Length)], new Vector3(roomRef.x * roomWidth, roomRef.y * roomHeight, 0), Quaternion.identity, RoomContainer.transform);
            }
            else if (roomRef.exits[2] != 0 && roomRef.exits[1] != 0)
            {
                roomRef.room = Instantiate(DRRooms[Random.Range(0, DRRooms.Length)], new Vector3(roomRef.x * roomWidth, roomRef.y * roomHeight, 0), Quaternion.identity, RoomContainer.transform);
            }

            if (roomRef.room == null)
            {
                Debug.LogWarning("The f***s happened here?");
                Debug.Break();
            }

            if (roomRef.room != null)
            {
                roomRef.room.GetComponent <Room>().NewRoom(ref roomRef);
            }
        }

        if (roomRef.children.Count == 0)
        {
        }
        else if (roomRef.children.Count == 1)
        {
            ConstructLevel(roomRef.children[0]);
        }
        else if (roomRef.children.Count == 2)
        {
            ConstructLevel(roomRef.children[0]);
            ConstructLevel(roomRef.children[1]);
        }
    }
コード例 #25
0
 protected virtual bool TryCreateRoom(string gameId, out RoomReference roomReference, params object[] args)
 {
     return(HiveGameCache.Instance.TryCreateRoom(gameId, this, out roomReference, args));
 }
コード例 #26
0
ファイル: GameClientPeer.cs プロジェクト: JasoonS/TotalTempo2
 protected virtual bool TryGetRoomReference(string gameId, out RoomReference roomReference)
 {
     return(GameCache.Instance.TryGetRoomReference(gameId, this, out roomReference));
 }
コード例 #27
0
        public ILearningRoom Load(RoomReference reference)
        {
            var roomAspect = _roomAspectLoader.Load(reference);

            return(new LearningRoomDomain(roomAspect));
        }
コード例 #28
0
ファイル: GameClientPeer.cs プロジェクト: theGameShop/Flipper
 protected override bool TryGetRoomReference(string gameId, out RoomReference roomReference)
 {
     return(this.application.GameCache.TryGetRoomReference(gameId, this, out roomReference));
 }
コード例 #29
0
ファイル: GameClientPeer.cs プロジェクト: theGameShop/Flipper
 protected override bool TryCreateRoom(string gameId, out RoomReference roomReference, params object[] args)
 {
     return(this.application.GameCache.TryCreateRoom(gameId, this, out roomReference, args));
 }
コード例 #30
0
        public IList <ISignInAspect> Load(RoomReference reference)
        {
            var signInEntities = _signInRepository.FindByRoom(reference.Code);

            return(signInEntities.Select(_signInAspectMapper.Map).ToList());
        }