/// <summary> /// Starts a server. /// </summary> public void StartServer() { try { Instantiate(Server).GetComponent <BackgammonServer>(); BackgammonClient client = Instantiate(Client).GetComponent <BackgammonClient>(); client.ClientName = GameManager.Instance.UserName; client.IsHost = true; client.ConnectToServer("127.0.0.1", 9000); } catch (Exception e) { Debug.Log(e.Message); } }
/// <summary> /// Starts a client using the specified host address. /// </summary> /// <param name="hostAddress"></param> public void StartClient(string hostAddress) { if (string.IsNullOrEmpty(hostAddress)) { hostAddress = "127.0.0.1"; } try { BackgammonClient client = Instantiate(Client).GetComponent <BackgammonClient>(); client.ClientName = GameManager.Instance.UserName; client.IsHost = false; client.ConnectToServer(hostAddress, 9000); } catch (Exception e) { Debug.Log(e.Message); } }
/// <summary> /// Used to initialize any variables or game state before the game starts. /// </summary> void Awake() { Instance = this; Player1.Name = GameManager.Instance.Player1Name; Player2.Name = GameManager.Instance.Player2Name; Player1.PlayerControlMode = GameManager.Instance.Player1ControlMode; Player2.PlayerControlMode = GameManager.Instance.Player2ControlMode; IsCrawfordRuleEnabled = GameManager.Instance.IsCrawfordRuleEnabled; IsMurphyRuleEnabled = GameManager.Instance.IsMurphyRuleEnabled; Variant = GameManager.Instance.BackgammonVariant; PlayMode = GameManager.Instance.BackgammonPlayMode; MatchScore = GameManager.Instance.MatchScore; InitialStakes = GameManager.Instance.InitialStakes; if (IsMultiplayerGame) { m_Client = FindObjectOfType <BackgammonClient>(); } }