Changeset 202 for trunk/UGameClient.pas
- Timestamp:
- May 17, 2018, 5:41:47 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGameClient.pas
r185 r202 6 6 7 7 uses 8 Classes, SysUtils, UGame, Forms, fgl, UGameProtocol ;8 Classes, SysUtils, UGame, Forms, fgl, UGameProtocol, UGameServer; 9 9 10 10 type 11 TClientConnectType = (ctLocal, ctNetwork); 12 11 13 { TClient } 12 14 13 15 TClient = class 14 16 private 17 FActive: Boolean; 15 18 FForm: TForm; 16 19 FGame: TGame; … … 19 22 FOnReceive: TCommandEvent; 20 23 FOnMove: TMoveEvent; 24 procedure SetActive(AValue: Boolean); 21 25 procedure SetControlPlayer(AValue: TPlayer); 22 26 procedure SetForm(AValue: TForm); … … 24 28 procedure PlayerMove(CellFrom, CellTo: TCell; var CountOnce, CountRepeat: Integer; 25 29 Update: Boolean; var Confirm: Boolean); 26 procedure ReceiveCmd(Command: TCommand; DataOut, DataIn: TStream); 30 protected 31 procedure ReceiveCmd(Command: TCommand; DataOut, DataIn: TStream); virtual; 32 procedure DoTurnStart(Sender: TObject); virtual; 27 33 public 28 34 Name: string; 29 35 View: TView; 36 LocalServer: TServer; 37 RemoteAddress: string; 38 RemotePort: Word; 39 ConnectType: TClientConnectType; 30 40 Protocol: TGameProtocolClient; 31 41 procedure DoChange; … … 38 48 property OnReceive: TCommandEvent read FOnReceive write FOnReceive; 39 49 property OnChange: TNotifyEvent read FOnChange write FOnChange; 50 property Active: Boolean read FActive write SetActive; 40 51 end; 41 52 … … 107 118 end; 108 119 120 procedure TClient.DoTurnStart(Sender: TObject); 121 begin 122 123 end; 124 109 125 procedure TClient.SetControlPlayer(AValue: TPlayer); 110 126 begin … … 115 131 if Assigned(FControlPlayer) then begin 116 132 FControlPlayer.OnMove := PlayerMove; 133 end; 134 end; 135 136 procedure TClient.SetActive(AValue: Boolean); 137 var 138 ServerClient: TServerClient; 139 begin 140 if FActive = AValue then Exit; 141 FActive := AValue; 142 if FActive then begin 143 case ConnectType of 144 ctLocal: if LocalServer.Active then begin 145 ServerClient := LocalServer.GetNewServerClient; 146 ServerClient.Player := ControlPlayer; 147 ServerClient.Protocol.Pin.Connect(Protocol.Pin); 148 end else raise Exception.Create('Local server is not active'); 149 //ctNetwork: ; 150 end; 151 end else begin 152 Protocol.Pin.Disconnect; 117 153 end; 118 154 end; … … 129 165 View := TView.Create; 130 166 Protocol := TGameProtocolClient.Create; 167 Protocol.OnTurnStart := DoTurnStart; 131 168 end; 132 169
Note:
See TracChangeset
for help on using the changeset viewer.