private void HandleGamePieceSync_One(string[] segments) { if (MatchHandler.CurrentMatch == null) { return; } try { GamePieceNetworkState netState = 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]) ); InterEventDispatcher.InvokeGamePieceSyncReceivedEvent (new GamePieceSyncReceivedEventArgs(segments[2], netState.ControllerIdentity, netState)); } catch (Exception e) { Debug.Log(e.ToString()); } }
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()); } }
internal static void SyncGamePieceToMatch(string matchId, GamePieceNetworkState pieceNetworkState) { if (m_Matches.ContainsKey(matchId)) { MatchState match = m_Matches[matchId]; match.SyncGamePieceNetworkState(pieceNetworkState); } }
private string GetSyncCommandFromPieceNetworkState(string matchId, GamePieceNetworkState piece) { return(string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}{1}{6}{1}{7}{1}{8}{1}{9}{1}{10}{1}{11}{1}{12}{1}{13}{1}{14}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.SyncGamePiece), matchId, piece.ControllerIdentity, piece.ControllerPosition, piece.NetworkIdentity, piece.GamePieceName, piece.PositionX, piece.PositionY, piece.Hitpoints, piece.DefenseRating, piece.AttackRating, piece.TurnDelay, piece.Rotation)); }
void UpdateGamePiece(GamePieceNetworkState netState) { if (ActiveGamePieces.ContainsKey(netState.NetworkIdentity)) { Debug.LogFormat("Updating Netstate: {0}", netState.GamePieceName); GamePiece piece = ActiveGamePieces[netState.NetworkIdentity]; piece.CurrentHitPoints = netState.Hitpoints; piece.SetCurrentVector(netState.PositionX, netState.PositionY); UpdatePiecePosition(piece.gameObject, piece); Quaternion deltaRot = piece.gameObject.transform.rotation; deltaRot.eulerAngles = new Vector3(0, netState.Rotation, 0); piece.gameObject.transform.rotation = deltaRot; } }