コード例 #1
0
        private void HandleGamePieceSync_One(string[] segments)
        {
            //0#|syncgmepce#|matchId#|playerAccountId#|playerSlot#|pieceNetworkId#|pieceName
            // #|positionX#|positionY#|hitpoints#|defense#|attack#|turnDelay#|rotation

            try
            {
                GamePieceNetworkState pieceNetworkState = new GamePieceNetworkState
                                                          (
                    segments[3],
                    Int32.Parse(segments[4]),
                    segments[5],
                    segments[6],
                    Int32.Parse(segments[7]),
                    Int32.Parse(segments[8]),
                    Int32.Parse(segments[9]),
                    Int32.Parse(segments[10]),
                    Int32.Parse(segments[11]),
                    Int32.Parse(segments[12]),
                    float.Parse(segments[13])
                                                          );

                MatchHandler.SyncGamePieceToMatch(segments[2], pieceNetworkState);
            }

            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
コード例 #2
0
        private void ProcessSpectateMatchRequest_One(string clientId, string[] segments)
        {
            Account account = ClientManager.GetClientById(clientId).AccountRelative;

            MatchHandler.AddSpectatorToMatch
                (segments[2], clientId, account.AccountId, account.Username);
        }
コード例 #3
0
        private void EndMatch_One(string[] segments)
        {
            string matchId = segments[2];

            MatchHandler.EndMatch(matchId);

            MatchEventDispatcher.InvokeMatchEndEvent(new MatchEndEventArgs(matchId));
        }
コード例 #4
0
        private void HandleTurnStateUpdate_One(string[] segments)
        {
            try
            {
                MatchHandler.HandleTurnStateUpdate(segments[2], Int32.Parse(segments[3]));
            }

            catch (Exception e) { Console.WriteLine(e.ToString()); }
        }
コード例 #5
0
        private void HandleSyncAttackTarget_One(string[] segments)
        {   //protocol#|cmd#|matchId#|attackerId#|dmg#|targetId
            try
            {
                MatchHandler.SynchAttackTarget
                    (segments[2], segments[3], segments[4]);
            }

            catch (Exception e) { Console.WriteLine(e.ToString()); }
        }
コード例 #6
0
        private void ProcessAttackSyncComplete_One(string[] segments)
        {
            try
            {
                MatchHandler.ProcessAttackSyncComplete
                    (segments[2], segments[3], Int32.Parse(segments[4]), Int32.Parse(segments[5]));
            }

            catch (Exception e) { Console.WriteLine(e.ToString()); }
        }
コード例 #7
0
        private void InterEventDispatcher_MatchStartEvent(MatchStartEventArgs args)
        {
            string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}",
                                       (int)ReadProtocol.GetVersion(),
                                       m_SegmentTerminator,
                                       NetworkCommand.GetCommand(NetworkCommandType.StartMatch),
                                       args.MatchId,
                                       args.PlayerIdOfFirstToMove);

            MatchHandler.SendMessageToUsersInMatch(args.MatchId, cmd);
        }
コード例 #8
0
        private void MatchEventDispatcher_SpectatorSyncEvent(SpectatorSyncEventArgs args)
        {
            string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}",
                                       (int)ReadProtocol.GetVersion(),
                                       m_SegmentTerminator,
                                       NetworkCommand.GetCommand(NetworkCommandType.SyncMatchSpectator),
                                       args.Match.MatchIdentity,
                                       args.PlayerState.AccountIdentity,
                                       args.PlayerState.Username);

            MatchHandler.SendMessageToUsersInMatch(args.Match, cmd);
        }
コード例 #9
0
        private void InterEventDispatcher_TurnStateSyncEvent(TurnStateSyncEventArgs args)
        {
            string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}{1}{6}",
                                       (int)ReadProtocol.GetVersion(),
                                       m_SegmentTerminator,
                                       NetworkCommand.GetCommand(NetworkCommandType.TurnStateSync),
                                       args.MatchId,
                                       args.CurrentPlayerId,
                                       args.TurnStep.ToString(),
                                       args.LowestTurnStep.ToString());

            MatchHandler.SendMessageToUsersInMatch(args.MatchId, cmd);
        }
コード例 #10
0
        private void HandleMatchMessage_One(string[] segments)
        {
            //protocol#|lbymsg#|matchId#|username#|time#|message<#>
            string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}{1}{6}",
                                       (int)ReadProtocol.GetVersion(),
                                       m_SegmentTerminator,
                                       NetworkCommand.GetCommand(NetworkCommandType.MatchMessage),
                                       segments[2],
                                       segments[3],
                                       segments[4],
                                       segments[5]);

            MatchHandler.SendMessageToUsersInMatch(segments[2], cmd);
        }
コード例 #11
0
        private void InterEventDispatcher_AttackSyncCompleteEvent(AttackSyncCompleteEventArgs args)
        {
            string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}{1}{6}{1}{7}",
                                       (int)ReadProtocol.GetVersion(),
                                       m_SegmentTerminator,
                                       NetworkCommand.GetCommand(NetworkCommandType.ProcessAttack),
                                       args.MatchId,
                                       args.AttackingPieceId,
                                       args.DefendingPlayerId,
                                       args.BoardVectorX.ToString(),
                                       args.BoardVectorY.ToString());

            MatchHandler.SendMessageToUsersInMatch(args.MatchId, cmd);
        }
コード例 #12
0
        private void AttemptMatchCreation_One(string clientId, string[] segments)
        {
            try
            {   //protocol#|crtmtch#|userId#|username
                string accountId = segments[2];
                string username  = segments[3];

                MatchHandler.CreateNewMatch(accountId, username);
            }

            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
コード例 #13
0
        private void HandleNetworkPieceMove_One(string[] segments)
        {
            //protocol#|command#|matchId#|pieceNetId#|x#|y

            string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}{1}{6}",
                                       (int)ReadProtocol.GetVersion(),
                                       m_SegmentTerminator,
                                       NetworkCommand.GetCommand(NetworkCommandType.NetworkPieceMoveEvent),
                                       segments[2],
                                       segments[3],
                                       segments[4],
                                       segments[5]);

            MatchHandler.SendMessageToUsersInMatch(segments[2], cmd);
        }
コード例 #14
0
        private void HandleSpectatorJoinEvent(string matchId, string clientId, bool succeeded)
        {
            MatchState match = MatchHandler.GetMatchStateById(matchId);

            string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}",
                                       (int)ReadProtocol.GetVersion(),
                                       m_SegmentTerminator,
                                       NetworkCommand.GetCommand(NetworkCommandType.SpectateMatchResult),
                                       matchId,
                                       succeeded.ToString().ToLowerInvariant());

            ClientManager.GetClientById(clientId).SendData(cmd);

            SyncMatchSpectators(match);
        }
コード例 #15
0
        private void SendGamePieceSyncToSpectator
            (string matchId, string spectatorId, string controllerId, GamePieceNetworkState[] pieces)
        {
            for (int i = 0; i < pieces.Length; i++)
            {
                MatchHandler.SendMessageToUsersInMatch
                    (matchId, GetSyncCommandFromPieceNetworkState(matchId, pieces[i]));
            }

            string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}",
                                       (int)ReadProtocol.GetVersion(),
                                       m_SegmentTerminator,
                                       NetworkCommand.GetCommand(NetworkCommandType.EndGamePieceSync),
                                       matchId,
                                       controllerId);

            ClientManager.SendMessageToClientByAccount(spectatorId, cmd);
        }
コード例 #16
0
        private void HandleMatchCreationEvent(MatchState match)
        {
            //protocol#|mtchcrtd#|matchId#|playerOneId#|playerOneUsername
            string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}",
                                       (int)ReadProtocol.GetVersion(),
                                       m_SegmentTerminator,
                                       NetworkCommand.GetCommand(NetworkCommandType.MatchCreated),
                                       match.MatchIdentity,
                                       match.PlayerOne.AccountIdentity,
                                       match.PlayerOne.Username);

            MatchHandler.SendMessageToUsersInMatch(match, cmd);

            ClientState client = ClientManager.GetClientByAccount
                                     (AccountHandler.GetAccountById(match.PlayerOne.AccountIdentity));

            ClientManager.SendMessageToAllClients(cmd, client);
        }
コード例 #17
0
        internal static void RemoveOnlineAccount(Account account)
        {
            if (m_AccountsOnline.ContainsKey(account.Username))
            {
                m_AccountsOnline.Remove(account.Username);
            }

            if (m_AccountIdentities.ContainsKey(account.AccountId))
            {
                m_AccountIdentities.Remove(account.AccountId);
            }

            if (account.CurrentMatch != null)
            {
                MatchHandler.HandleDisconnectFromMatch
                    (account.CurrentMatch, account.AccountId);
            }
        }
コード例 #18
0
        private void SendGamePieceSyncToMatch(string matchId, string controllerId, GamePieceNetworkState[] pieces, bool endSync)
        {
            for (int i = 0; i < pieces.Length; i++)
            {
                MatchHandler.SendMessageToUsersInMatch
                    (matchId, GetSyncCommandFromPieceNetworkState(matchId, pieces[i]));
            }

            if (endSync)
            {
                string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}",
                                           (int)ReadProtocol.GetVersion(),
                                           m_SegmentTerminator,
                                           NetworkCommand.GetCommand(NetworkCommandType.EndGamePieceSync),
                                           matchId,
                                           controllerId);

                MatchHandler.FlagFirstSyncForPlayer(matchId, controllerId);
                MatchHandler.SendMessageToUsersInMatch(matchId, cmd);
            }
        }
コード例 #19
0
 private void HandleEndPieceSync_One(string[] segments)
 {
     //protocol#|cmd#|matchId#|accountId
     MatchHandler.HandlePieceSyncComplete(segments[2], segments[3]);
 }
コード例 #20
0
 private void InterEventDispatcher_MatchDepartureTimerExpiredEvent(MatchDepartureTimerEventArgs args)
 {
     MatchHandler.RemoveUserFromMatch(args.Match, args.PlayerState.AccountIdentity);
 }
コード例 #21
0
 private void ProcessJoinMatchAttempt_One(string clientId, string[] segments)
 {
     MatchHandler.AttemptToJoinMatch
         (ClientManager.GetClientById(clientId), segments[2]);
 }