Ejemplo n.º 1
0
    public static void CloseGameAndClear()
    {
        if (PopupManager_RaS.Instance == null)
        {
            return;
        }

        GameObject.Destroy(PopupManager_RaS.Instance.gameObject);
        PopupManager_RaS.Instance = null;

        GameObject hostGO = GameObject.Find("LobbyClient");

        if (PopupManager_RaS.IsFree)
        {
            Debug.Log("A");
            Debug.Break();
            Application.Quit();
        }
        else
        {
            if (hostGO != null)
            {
                hostGO.GetComponent <LobbyClient>().Clear();
            }

            Application.Quit();
        }
    }
Ejemplo n.º 2
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         ClosePopup();
         DontDestroyOnLoad(this.gameObject);
         return;
     }
     else
     {
         GameObject.Destroy(this.gameObject);
         return;
     }
 }
Ejemplo n.º 3
0
    void Start()
    {
        if (Screen.orientation == ScreenOrientation.LandscapeRight)
        {
            Screen.orientation = ScreenOrientation.LandscapeRight;
        }
        else
        {
            Screen.orientation = ScreenOrientation.Landscape;
        }
        Screen.SetResolution(1920, 1080, true);
        Debug.Log("LobbyHost Start : " + BS_LogoViewer.BuildType.ToString());

        screenLog(BS_LogoViewer.BuildType.ToString());

        hostController = UXHostController.Instance;
        screenLog("IsConnect : " + hostController.IsConnected());
        if (hostController.IsConnected() == true)
        {
            if (UXHostController.GetRoomNumber() != -1)
            {
                UXHostController.SetRoomNumber(-1);
            }
            hostController.Clear();
        }

        int launcherCode = -1;

        bool result = hostController.SetCode(launcherCode);

        if (result == false)
        {
            hostController.CreateRoom(GAME_PACKAGE_NAME, hostController.GetMaxUser());
            Debug.Log("Room NUM : " + UXHostController.GetRoomNumberString());
            roomNumberTxt.text = UXHostController.GetRoomNumberString() + "";
            screenLog("ROOM INFO : " + UXConnectController.ROOM_SERVER_IP + ", " + UXConnectController.ROOM_SERVER_PORT);
            screenLog(UXHostController.GetRoomNumberString());
        }
        else
        {
                        #if UNITY_ANDROID && !UNITY_EDITOR
            int country = androidManager.GetCountryCode();
            PlayerPrefs.SetInt("ServerList", country);
                        #endif
            roomNumberTxt.text = UXHostController.GetRoomNumberString() + "";
        }

        hostController.OnConnected     += OnConnected;
        hostController.OnConnectFailed += OnConnected;
        hostController.OnJoinFailed    += OnJoinFailed;
        hostController.OnJoinSucceeded += OnJoinSucceeded;
        hostController.OnDisconnected  += OnDisconnected;

        hostController.OnUserAdded             += OnUserAdded;
        hostController.OnUserRemoved           += OnUserRemoved;
        hostController.OnNetworkReported       += OnNetworkReported;
        hostController.OnUserNetworkReported   += OnUserNetworkReported;
        hostController.OnUserLobbyStateChanged += OnUserLobbyStateChanged;
        hostController.OnAutoCountChanged      += OnAutoCountChanged;
        hostController.OnUpdateReadyCount      += OnUpdateReadyCount;
        hostController.OnUserLeavedInGame      += OnUserLeaved;

        hostController.OnGameStart    += OnGameStart;
        hostController.OnGameRestart  += OnGameRestart;
        hostController.OnGameResult   += OnGameResult;
        hostController.OnIndexChanged += OnIndexChanged;

        hostController.OnUserListReceived += OnUserListReceived;
        hostController.OnGameEnd          += OnGameEnd;
        hostController.OnExit             += OnExit;
        hostController.OnAckFailed        += OnAckFailed;

        //==========================================
        hostController.OnHostJoined += OnHostJoined;
        hostController.OnError      += OnError;
        hostController.OnReceived   += OnReceived;
        //==========================================
        hostController.OnHostDisconnected += hostController_OnHostDisconnected;

        hostController.OnJoinPremiumUser  += OnJoinPremiumUser;
        hostController.OnLeavePremiumUser += OnLeavePremiumUser;

        hostController.SetAutoStart(2, 1);
        if (result == false)
        {
            hostController.SetMaxUser(2); // for GOOGLE
            freeLabel.SetActive(true);
        }
        else
        {
            hostController.SetMaxUser(2);             // for GOOGLE
            freeLabel.SetActive(true);
        }
        PopupManager_RaS.IsFreeSetter(true);
        hostController.Connect();

        maxPlayer = hostController.GetMaxUser();
        Debug.Log("Max Player : " + maxPlayer);
        for (int i = 0; i < playerNumber.Length; i++)
        {
            playerNumber[i].SetActive(false);
        }

        Debug.Log("LobbyHost :: " + selectedPlayerCharacter.Length);
        for (int i = 0; i < selectedPlayerCharacter.Length; i++)
        {
            selectedPlayerCharacter[i] = (int)CHARACTER_TYPE.CHARACTER_NONE;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
        StartCoroutine(PlayIntroVideo());
#endif

        // blackOut.SetActive(false);

        iTween.MoveTo(Camera.main.gameObject, new Vector3(0, 0, -10), 4.0f);
    }
Ejemplo n.º 4
0
    void Start()
    {
        Screen.orientation = ScreenOrientation.Portrait;
        Screen.SetResolution(720, 1280, true);

        //blackOut.SetActive(true);

        m_ClientController = UXClientController.Instance;
        m_PlayerController = UXPlayerController.Instance;

        PopupManager_RaS.IsFreeSetter(false);             // TOOD : PopupManager 공통 모듈로 바꿔야함

        userCode   = m_PlayerController.GetCode();        // 유저 코드 가져옴
        roomNumber = UXConnectController.GetRoomNumber(); // 방 번호 가져옴

        //blackOut.SetActive(false);

        //userCode = m_PlayerController.GetCode ();
        //launcherCode = UXClientController.GetRoomNumber();

        i_PlayerID = m_PlayerController.GetIndex();

        m_ClientController.OnConnected     += OnConnected;
        m_ClientController.OnConnectFailed += OnConnectFailed;
        m_ClientController.OnJoinSucceeded += OnJoinSucceeded;
        m_ClientController.OnJoinFailed    += OnJoinFailed;
        m_ClientController.OnDisconnected  += OnDisconnected;

        m_ClientController.OnUserAdded        += OnUserAdded;
        m_ClientController.OnUserRemoved      += OnUserRemoved;
        m_ClientController.OnUserLeavedInGame += OnUserLeaved;
        m_ClientController.OnNetworkReported  += OnNetworkReported;
        m_ClientController.OnUpdateReadyCount += OnUpdateReadyCount;

        m_ClientController.OnGameStart    += OnGameStart;
        m_ClientController.OnGameRestart  += OnGameRestart;
        m_ClientController.OnGameResult   += OnGameResult;
        m_ClientController.OnIndexChanged += OnIndexChanged;

        m_ClientController.OnUserListReceived += OnUserListReceived;
        m_ClientController.OnGameEnd          += OnGameEnd;
        m_ClientController.OnExit             += OnExit;
        m_ClientController.OnAckFailed        += OnAckFailed;
        m_ClientController.OnHostDisconnected += OnHostDisconnected;

        //inapp.OnPurchaseSuccess += OnPurchaseSuccess;

        //==========================================
        m_ClientController.OnHostJoined += OnHostJoined;
        m_ClientController.OnError      += OnError;
        m_ClientController.OnReceived   += OnReceived;
        //==========================================

        if (m_ClientController.IsConnected() == false)
        {
            m_ClientController.Connect();
        }
        else
        {
            //m_ClientController.Join("none");
            m_ClientController.Join(GAME_PACKAGE_NAME);
        }

        cancelButton.SetActive(false);

        DontDestroyOnLoad(this.gameObject);
    }