public LocalPlayerAgent(int pid) : base(pid) { var client = GameApp.Service<Services.Network>().THSClient; if (client.NetworkStatus == Network.Client.NetworkStatusEnum.Connected) { m_NetworkClient = client; } }
public override void Update(float deltaTime) { if (m_networkClient == null) { if (GameApp.Service<Network>().THSClient == null) { throw new Exception("Network Service is not started correctly. Network Client is null."); } m_networkClient = GameApp.Service<Network>().THSClient; } switch (m_networkClient.NetworkStatus) { case THSNetwork.Client.NetworkStatusEnum.Connecting: m_lblMessage.FormattedText = GameApp.Service<TextRenderer>().FormatText("服务器连接中...", m_textFormatOptions); break; case THSNetwork.Client.NetworkStatusEnum.ResendingConnect: m_lblMessage.FormattedText = GameApp.Service<TextRenderer>().FormatText("重新发送连接请求中...", m_textFormatOptions); break; case THSNetwork.Client.NetworkStatusEnum.Connected: m_lblMessage.FormattedText = GameApp.Service<TextRenderer>().FormatText("已连接成功...", m_textFormatOptions); break; case THSNetwork.Client.NetworkStatusEnum.ConnectFailed: m_lblMessage.FormattedText = GameApp.Service<TextRenderer>().FormatText("无法连接到服务器", m_textFormatOptions); break; default: break; } if (m_networkClient != null && m_networkClient.NetworkStatus == THSNetwork.Client.NetworkStatusEnum.Connected) { Root.Dispatcher = null; // detach network login ui GameApp.Service<NetworkUI>().Enter(); } base.Update(deltaTime); }
void btnLogin_MouseButton1Down(object sender, UI.MouseEventArgs e) { //login m_lblMessage.FormattedText = GameApp.Service<TextRenderer>().FormatText("服务器连接中...", m_textFormatOptions); m_networkClient = GameApp.Service<Network>().THSClient; m_networkClient.Connect(); }
public override void Update(float deltaTime) { if (m_networkClient == null) { if (GameApp.Service<Network>().THSClient == null) { throw new Exception("Network Service is not started correctly. Network Client is null."); } m_networkClient = GameApp.Service<Network>().THSClient; } if (m_networkClient != null && m_networkClient.RoomStatus == THSNetwork.Client.RoomStatusEnum.Starting) { Root.Dispatcher = null; // detach menu ui if (m_networkClient.Seed != -1) { System.Diagnostics.Debug.Print(string.Format("Seed: {0}", m_networkClient.Seed)); param.Seed=m_networkClient.Seed; } if (m_networkClient.StartupIndex == 0) { GameApp.Service<GameManager>().StartGame(param , new Agents.BaseAgent[] { new Agents.LocalPlayerAgent(0), new Agents.RemoteAgent(1) }); } else { GameApp.Service<GameManager>().StartGame(param , new Agents.BaseAgent[] { new Agents.RemoteAgent(0), new Agents.LocalPlayerAgent(1) }); } m_networkClient.RoomStatus = THSNetwork.Client.RoomStatusEnum.Started; } base.Update(deltaTime); }
public void Enter() { m_networkClient = GameApp.Service<Network>().THSClient; InitializePage(); PrepareGameStartupParam(); }
public override void Shutdown() { THSClient = null; }
public override void Startup() { THSClient = new THSNetwork.Client(); THSClient.RemoteServerIp = Settings.Instance.MyAppSettings.GameSettings.RemoteServerIp; THSClient.RemoteServerPort = Settings.Instance.MyAppSettings.GameSettings.RemoteServerPort; }