ateLogCallback (string strMessage); delegate void CloseConnectionCallback (string strReason); Thread thrMessaging; IPAddress ipAddr; bool Connected;
HandleMassageActivity HandleMessage;
NetworkClient (HandleMassageActivity handleMessage)
{. HandleMessage=handleMessage;
}
void ConnectToServer (String ipString, String userName)
{(Connected == false)
{(ipString, userName);
}
{( Disconnected at user's request. );
}
}
void InitializeConnection (String ipString, String userName)
{= new TcpClient () ;. Connect ( localhost raquo ;, 1986);=true;=new StreamWriter (tcpServer.GetStream ()) ;. WriteLine (userName) ;. Flush () ;=new Thread (new ThreadStart (ReceiveMessages)) ;. Start ();
}
void ReceiveMessages ()
{= new StreamReader (tcpServer.GetStream ()); ConResponse=srReceiver.ReadLine (); (ConResponse [0] == 1 )
{( Connected Successfully! );
}
{Reason= Not Connected: raquo ;; +=ConResponse.Substring (2, ConResponse.Length - 2); (Reason) ;;
} (Connected)
{newMessage=srReceiver.ReadLine (); (newMessage);
}
}
void UpdateLog (string strMessage)
{. WriteLine (strMessage);
} void CloseConnection (string Reason)
{
=false; .Close () ;. Close () ;. Close ();
}
void SendMessage (String message)
{. WriteLine (message) ;. Flush ();
}
void Dispose ()
{(Connected == true)
{= false; .Close () ;. Close () ;. Close ();
}
}
}
}System;System.Collections.Generic;System.Linq;System.Text;BaldaGameLogic.Delegates;BaldaGameLogic.GameModel;
BaldaGameLogic.GameLogic
{
class GameLogicManager
{GameSettings Settings {get; set; } List lt; LogicCell gt; LogicCells {get; private set; } List lt; LogicCell gt; MainWordLogicCells {get; private set; } LogicCell selectedCell;
List lt; Player gt; Players {get; set; } List lt; LogicCell gt; SelectedCellsForWord; String selectedWord {get; set; }
PlayerGameStatistic GameStatistic {get; set; }
Player activePlayer;
# region GameLogicFlags
bool IsCellSelectionExpected {get; set; }
bool IsLetterSelectionExpected {get; set; }
bool IsWordSelectionExpected {get; set; } bool IsSelectedNetworkGameMode {get; set; }
bool IsWordSelected {get; set; }
bool IsPreviousInvalid;
# endregion
# region GameLogicDelegates
DisplayMatrixCells DisplayCells {private get; set; }
DisplayMatrixCells DisplayCellAsLight {private get; set; }
DisplayMessage DisplayCurrentWord {private get; set; }
DisplayMessage DisplayCurrentPlayerName {private get; set; }
DisplayMessage DisplayCurrentGuide {private get; set; }
DisplayMessage DisplayCurrentError {private get; set; }
DispalyAction AddWordConfirmationButtons {private get; set; }
DispalyAction RemoveConfirmationLabels {private get; set; }
DispalyAction AddLetterConfirmationButtons {private get; set; }
ConditionAction IsWordExist {private get; set; }
# endregion
void CreateGameLogicObjects ()
{(); ();=new List lt; LogicCell gt; ();
}
void CreatePlayersObjects ()
{= new List lt; Player gt; (); (int i=1; i lt;=Settings.PlayerCount; i ++)
{. Add (new Player {Number=i, Name=String.Empty});
}=new PlayerGameStatistic (Players);
}