Esempio n. 1
0
        void Start()
        {
            matchMaker   = PlayerMatchMaker.instance;
            lobbyManager = (MobNetworkLobbyManager)NetworkManager.singleton;
            createBattleBtn.onClick.AddListener(() => {
                EventManager.TriggerEvent(Constants.EVENT_CONNECTION_STATUS_STARTING_A_CONNECTION);
                matchMaker.StartMatchMaker();
                matchMaker.GetMatchList(0, 20, 0, 0, matches => {
                    matchMaker.CreateOrJoinMatch(matches, 2, "", 0, 0);
                });
            });

            swordmanSelectionBtn.onClick.AddListener(() => {
                lobbyManager.characterType = CharacterType.Swordman;
            });

            mageSelectionBtn.onClick.AddListener(() => {
                lobbyManager.characterType = CharacterType.Mage;
            });

            berserkerSelectionBtn.onClick.AddListener(() => {
                lobbyManager.characterType = CharacterType.Berserker;
            });
        }
Esempio n. 2
0
        void Start()
        {
            lobbyManager      = (MobNetworkLobbyManager)NetworkManager.singleton;
            matchMaker        = PlayerMatchMaker.instance;
            exitConnectionTxt = exitConnectionBtn.GetComponentInChildren <Text>();

            VisiblePanel(false);

            switch (lobbyManager.playerState)
            {
            case PlayerState.WaitingConnection:
                VisiblePanel(true);
                connectionStatusTxt.text = LOOKING_AN_APPROPRIATE_BATTLE;
                break;

            case PlayerState.Disconnected:
                VisiblePanel(true);
                connectionStatusTxt.text = PLAYER_DISCONNECT;
                break;

            default:
                break;
            }

            exitConnectionBtn.onClick.AddListener(() => {
                exitConnectionTxt.text = EXITING;
                matchMaker.Exit(() => {
                    VisiblePanel(false);
                    exitConnectionTxt.text = EXIT;
                });
            });

            EventManager.StartListening(Constants.EVENT_CONNECTION_STATUS_STARTING_A_CONNECTION, new Action(() => {
                connectionStatusTxt.text = CONNECTING;
                VisiblePanel(true);
            }));

            EventManager.StartListening(Constants.EVENT_CONNECTION_STATUS_ON_START_HOST, new Action(() => {
                connectionStatusTxt.text = LOOKING_AN_APPROPRIATE_BATTLE;
                VisiblePanel(true);
            }));

            EventManager.StartListening(Constants.EVENT_CONNECTION_STATUS_ON_CLIENT_CONNECT, new Action(() => {
                connectionStatusTxt.text = LOOKING_AN_APPROPRIATE_BATTLE;
                VisiblePanel(true);
            }));

            EventManager.StartListening(Constants.EVENT_CONNECTION_STATUS_ON_PLAYER_COUNTDOWN, new Action <int>(countdown => {
                connectionStatusTxt.text = string.Format(BATTLE_STAT_IN_SECONDS, (countdown + 1));
                if (countdown < 0)
                {
                    exitConnectionBtn.interactable = true;
                    VisiblePanel(false);
                }
            }));

            EventManager.StartListening(Constants.EVENT_CONNECTION_STATUS_ON_SERVER_DISCONNECT, new Action(() => {
                connectionStatusTxt.text = PLAYER_DISCONNECT;
            }));

            EventManager.StartListening(Constants.EVENT_CONNECTION_STATUS_ON_LOBBY_STOP_CLIENT, new Action(() => {
                connectionStatusTxt.text = PLAYER_DISCONNECT;
            }));

            EventManager.StartListening(Constants.EVENT_CONNECTION_STATUS_ON_CLIENT_DISCONNECT, new Action(() => {
                connectionStatusTxt.text = CONNECTION_OCCURS_ERROR;
            }));

            EventManager.StartListening(Constants.EVENT_CONNECTION_STATUS_ON_CLIENT_ERROR, new Action(() => {
                connectionStatusTxt.text = CONNECTION_OCCURS_ERROR;
            }));

            EventManager.StartListening(Constants.EVENT_CONNECTION_STATUS_ON_DROP_CONNECTION, new Action(() => {
                connectionStatusTxt.text = PLAYER_DISCONNECT;
            }));

            EventManager.StartListening(Constants.EVENT_CONNECTION_STATUS_ON_PLAYER_HAS_ALREADY, new Action(() => {
                exitConnectionBtn.interactable = false;
            }));
        }