Наследование: MonoBehaviour
Пример #1
0
        public void Shutdown()
        {
            this.gameClient?.Shutdown();
            this.gameClient = null;

            this.gameServer?.Shutdown();
            this.gameServer = null;
        }
Пример #2
0
    // Start is called before the first frame update
    void Start()
    {
        var rootGameObjectList = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects().ToList();

        _menuCanvas  = rootGameObjectList.Find(p => p.name == "MenuCanvas");
        _board       = rootGameObjectList.Find(p => p.name == "Board");
        _boardCanvas = rootGameObjectList.Find(p => p.name == "BoardCanvas");

        _clientPanel     = _menuCanvas.transform.Find("ClientPanel");
        _clientStateText = _clientPanel.Find("ClientStateText").GetComponent <Text>();

        var connectButton = _clientPanel.Find("ConnectButton");

        _connectButtonImage = connectButton.GetComponent <Image>();
        _connectButtonText  = connectButton.Find("ConnectButtonText").GetComponent <Text>();

        var userInfoPanelParent = _clientPanel.Find("UserInfoPanel");

        _userWelcomeGrid = userInfoPanelParent.Find("UserWelcomeGrid").gameObject;
        var userAccountGridParent = userInfoPanelParent.Find("UserAccountGrid");

        _userAccountGrid           = userAccountGridParent.gameObject;
        _accountNameInputField     = userAccountGridParent.Find("AccountNameInput").GetComponent <InputField>();
        _accountPasswordInputField = userAccountGridParent.Find("AccountPasswordInput").GetComponent <InputField>();
        _loginButton  = userAccountGridParent.Find("LoginButton").GetComponent <Button>();
        _userMenuGrid = userInfoPanelParent.Find("UserMenuGrid").gameObject;
        var userWaitingGridParent = userInfoPanelParent.Find("UserWaitingGrid");

        _waitingText          = userWaitingGridParent.Find("WaitingText").GetComponent <Text>();
        _waitingTimeText      = userWaitingGridParent.Find("WaitingTimeText").GetComponent <Text>();
        _userWaitingGrid      = userWaitingGridParent.gameObject;
        _userInviteGrid       = userInfoPanelParent.Find("UserInviteGrid").gameObject;
        _userPrepareGrid      = userInfoPanelParent.Find("UserPrepareGrid").gameObject;
        _deckStringInput      = _userPrepareGrid.transform.Find("DeckStringInput").GetComponent <InputField>();
        _userVisitAccountGrid = userInfoPanelParent.Find("UserVisitAccountGrid").gameObject;
        _accountStringInput   = _userVisitAccountGrid.transform.Find("AccountStringInput").GetComponent <InputField>();

        _clientPanel.gameObject.SetActive(true);
        _board.SetActive(false);
        _boardCanvas.SetActive(false);

        _gameController = new UnityGameController(this, new RandomAI());
        _gameClient     = new UnityGameClient(this, "127.0.0.1", 50051, _gameController);

        // initial mocked state
        ProccessGameClientState(GameClientState.None, GameClientState.None);
    }
Пример #3
0
 public void Initialize(GameClient client)
 {
     this.UserId     = client.UserId;
     this.gameClient = new UnityGameClient(client);
     Debug.Log("UserId = " + gameClient.UserId);
 }