Пример #1
0
    void OnUserListReceived(List <UXUser> list)
    {
        UXLog.SetLogMessage("OnUserListReceived > list : " + list.Count + " == 17");
        Debug.Log("OnUserListReceived > list : " + list.Count + " == 17");

        playerCount = hostController.GetConnectUserCount();
    }
Пример #2
0
    void OnJoinSucceeded(bool isHost)
    {
        UXLog.SetLogMessage("OnJoinSucceed > isHost : " + isHost + " == 3");
        Debug.Log("OnJoinSucceed > isHost : " + isHost + " == 3");

        hostController.RefreshUserListFromServer();
        playerCount = hostController.GetConnectUserCount();
    }
        public override void Join(string data)
        {
            string sendString = "{\"cmd\":\"join_launcher\",\"l_code\":\"" + launcherCode + "\",\"package_name\":\"" + data + "\"}" + DATA_DELIMITER;

            UXConnectController.SetRoomNumber(launcherCode);
            UXLog.SetLogMessage("sen" + sendString);
            Send(sendString);
        }
Пример #4
0
    void OnUserRemoved(string name, int code)
    {
        UXLog.SetLogMessage("OnUserRemoved > name : " + name + " , Code : " + code + " == 6");
        Debug.Log("OnUserRemoved > name : " + name + " , Code : " + code + " == 6");
        hostController.RefreshUserListFromServer();
        playerCount = hostController.GetConnectUserCount();

        CheckPremiumUser();
    }
Пример #5
0
    void OnUserLobbyStateChanged(int userIndex, UXUser.LobbyState state)
    {
        UXLog.SetLogMessage("OnUserLobbyStateChanged > userIndex : " + userIndex + ", state : " + state + " == 9");
        Debug.Log("OnUserLobbyStateChanged > userIndex : " + userIndex + ", state : " + state + " == 9");

        if (state == UXUser.LobbyState.Ready)
        {
            Camera.main.GetComponent <AudioSource>().PlayOneShot(numberOnSound);
        }
    }
Пример #6
0
    void OnGameEnd()
    {
        UXLog.SetLogMessage("Game End" + " == 18");
        Debug.Log("Game End" + " == 18");

        isGameStart = false;
        foreach (Transform child in this.transform)
        {
            child.gameObject.SetActive(true);
        }
    }
Пример #7
0
        /** Release event handler and disconnect socket	*/
        public void Clear()//연결끊을때 사용
        {
            if (connect != null)
            {
                connect.OnReceived            -= OnMessageReceived;
                connect.OnServerConnected     -= OnServerConnected;
                connect.OnServerConnectFailed -= OnServerConnectFailed;
                connect.OnServerDisconnected  -= OnServerDisconnected;
                connect.OnServerError         -= OnServerError;

                Disconnect();
            }
            connect = null;
            UXLog.Close();
        }
Пример #8
0
    void OnGameStart()
    {
        UXLog.SetLogMessage("Start Game!!" + " == 13");
        Debug.Log("Start Game!!" + " == 13");

        DontDestroyOnLoad(this.gameObject);

        isGameStart = true;
        foreach (Transform child in this.transform)
        {
            child.gameObject.SetActive(false);
        }
        CopyGameUserList();

        Application.LoadLevel("CharacterSelectLobbyBS");
    }
Пример #9
0
 //Callback when decodeImage has decoded the image/texture
 void onDecoderMessage(string data)
 {
     Debug.Log("EasyCodeScannerExample - onDecoderMessage data:" + data);
     UXLog.SetLogMessage("EasyCodeScannerExample - onDecoderMessage data:" + data);
     if (string.IsNullOrEmpty(data) == true || data == "")
     {
         RoomNumberWindow.qrCodeIsNull = false;
         Application.LoadLevel("2_RoomNumber");
         return;
     }
     if (data.Length > 5)
     {
         RoomNumberWindow.qrCodeIsNull = false;
         Application.LoadLevel("2_RoomNumber");
         return;
     }
     RoomNumberWindow.qrString = data;
     Application.LoadLevel("2_RoomNumber");
 }
        void ProcessReceivedMessage(string data)
        {
            if (string.IsNullOrEmpty(data) == true || data.Length <= 0)
            {
                Debug.Log("Empty");
                return;
            }

            Debug.Log(" ProcessReceivedMessage Launchhhhhhhhhhhhh   " + data);
            var    N       = JSON.Parse(data);
            string command = N["cmd"];

            if (command == "join_user_result")
            {
                int  rec     = N["gp_ack"].AsInt;
                bool isFirst = N["is_first"].AsBool;
                bigscreenState = N["package_name"];
                Debug.Log("bigscreenState" + bigscreenState);
                bool result = (rec == UXRoomConnect.ACK_RESULT_OK);

                if (result == true)
                {
                    isJoin       = true;
                    isHostJoined = true;
                    if (OnJoinSucceeded != null)
                    {
                        OnJoinSucceeded(isHostJoined);
                    }

                    if (isFirst == true)
                    {
                        if (OnFirstUser != null)
                        {
                            OnFirstUser();
                        }
                    }
                }
                else
                {
                    isJoin = false;
                    Debug.Log(" join fail ");

                    if (OnJoinFailed != null)
                    {
                        OnJoinFailed(rec);
                    }
                }
            }
            else if (command == "launcher_power_result")
            {
                int  rec    = N["gp_ack"].AsInt;
                bool result = (rec == UXRoomConnect.ACK_RESULT_OK);

                if (result == true)
                {
                    isActive = true;
                }
                else
                {
                    isActive = false;
                }
            }
            else if (command == "pad_button_touch_result")
            {
                int  rec    = N["gp_ack"].AsInt;
                bool result = (rec == UXRoomConnect.ACK_RESULT_OK);

                string buttonType = N["button_type"];

                if (buttonType == "click")
                {
                    isPlay = true;
                    string gameInfo = N["game_appinfo"];
                    OnBigscreenGameInfo(gameInfo);
                }
                else if (buttonType == "back")
                {
                    isPlay = false;
                    string storePage = N["store_page"];
                    if (OnStorePageState != null)
                    {
                        OnStorePageState(storePage);
                    }
                }
                else if (buttonType == "ok")
                {
                    if (OnStartGamePad != null)
                    {
                        padPackage = N["pad_package"];

                        Debug.Log("Lib   button type   ok   ");
                        OnStartGamePad(padPackage);
                    }
                }
            }
            else if (command == "leave_user_result")
            {
                UXLog.SetLogMessage("leave user result");
                Clear();

                if (OnUserLeft != null)
                {
                    UXLog.SetLogMessage(" OnUserLeft");
                    OnUserLeft();
                }
            }
            else if (command == "first_user")
            {
                Debug.Log("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&  command == first_user !!!!!!!!!!!");
                if (OnChangeFirstUser != null)
                {
                    OnChangeFirstUser();
                }
            }
            else
            {
                base.ProcessReceivedMessage(data);
            }
        }
Пример #11
0
    void OnReceived(int userCode, string msg)
    {
        int userIndex = GameUserList.IndexOf(userCode);

        UXLog.SetLogMessage("OnReceived > userIndex : " + userIndex + ", msg : " + msg + " == 22");
        Debug.Log("OnReceived > userIndex : " + userIndex + ", msg : " + msg + " == 22");

        string splitchar = ",";

        string[] words = null;

        msg.Trim();
        words = msg.Split(splitchar.ToCharArray(), System.StringSplitOptions.None);

        if (words[0] == "Exit")
        {
            //SendAll("Exit");

            //Debug.Break();
            //hostController.SendEndGame();
            //Application.Quit();
        }

        if (Application.loadedLevelName.Equals("LobbyHost"))
        {
            Debug.Log("Received ::isPremium? " + UXHostController.room.IsPremium);
            if (freeLabel == null)
            {
                freeLabel = GameObject.Find("Free Play");
            }

            if (UXHostController.room.IsPremium)
            {
                freeLabel.SetActive(false);
            }
            else
            {
                freeLabel.SetActive(true);
            }
        }

        GameObject bigScreen = GameObject.Find("BS");

        if (bigScreen == null)
        {
            return;
        }

        switch (words[0])
        {
        // Character Select
        case "CharacterSelect":
            if (bigScreen.GetComponent <BS_CharacterSelectLobbyManager>().IsSoldOutCharacter(int.Parse(words[1])) == false)   //선택가능
            {
                bigScreen.GetComponent <BS_CharacterSelectLobbyManager>().SetSelectedCharacter(userIndex, int.Parse(words[1]));
                for (int i = 0; i < playerCount; i++)
                {
                    if (i != userIndex)
                    {
                        SendToCode(GameUserList[i], "SoldOut," + words[1]);                                 // 팔렸다고 모두에게 알ㄹㅣ기
                    }
                }
            }
            else                                                            // soldout
            {
                SendToCode(GameUserList[userIndex], "SoldOut," + words[1]); //이건 머야
            }
            break;

        // Tutorial

        // In Game
        case "JoystickDown":
            bigScreen.GetComponent <BS_InGameManager>().JoystickDown(userIndex, int.Parse(words[1]));
            break;

        case "JoystickUp":
            bigScreen.GetComponent <BS_InGameManager>().JoystickUp(userIndex);
            break;

        // Result
        case "Replay":
            roomMasterCode = -1;
            hostController.RefreshUserListFromServer();
            CopyGameUserList();
            playerCount = hostController.GetConnectUserCount();
            hostController.SendEndGame();
            Application.LoadLevel("LobbyHost");
            break;

        case "Pause":
            SendAll("Pause_cli");
            GameObject.Find("PauseUI").GetComponent <Image>().enabled    = true;
            GameObject.Find("PauseBlack").GetComponent <Image>().enabled = true;
            Time.timeScale = 0f;
            break;

        case "Resume":
            SendAll("Resume_cli");
            GameObject.Find("PauseUI").GetComponent <Image>().enabled    = false;
            GameObject.Find("PauseBlack").GetComponent <Image>().enabled = false;
            Time.timeScale = 1f;
            break;

//            case "QROn":
//                GameObject.Find("QR_Back_Host").transform.localScale = Vector2.one;
//                break;
//            case "QROff":
//                GameObject.Find("QR_Back_Host").transform.localScale = Vector2.zero;
//                break;
        }
    }
Пример #12
0
 void OnError(int err, string msg)
 {
     UXLog.SetLogMessage("OnError > err : " + err + ", msg : " + msg + " == 21");
     Debug.Log("OnError > err : " + err + ", msg : " + msg + " == 21");
 }
Пример #13
0
 void OnHostJoined()
 {
     UXLog.SetLogMessage("OnHostJoined" + " == 20");
     Debug.Log("OnHostJoined" + " == 20");
 }
Пример #14
0
 void OnExit()
 {
     UXLog.SetLogMessage("Game Exit" + " == 19");
     Debug.Log("Game Exit" + " == 19");
 }
Пример #15
0
 void OnNetworkReported(int count, float time)
 {
     UXLog.SetLogMessage("OnNetworkReported > count : " + count + ", time : " + time + " == 7");
     Debug.Log("OnNetworkReported > count : " + count + ", time : " + time + " == 7");
 }
Пример #16
0
 void OnGameResult()
 {
     UXLog.SetLogMessage("OnGameResult" + " == 15");
     Debug.Log("OnGameResult" + " == 15");
 }
Пример #17
0
 void OnIndexChanged(int idx)
 {
     UXLog.SetLogMessage("OnIndexChanged > idx : " + idx + " == 16");
     Debug.Log("OnIndexChanged > idx : " + idx + " == 16");
 }
Пример #18
0
 void OnGameRestart()
 {
     UXLog.SetLogMessage("Restart Game" + " == 14");
     Debug.Log("Restart Game" + " == 14");
 }
Пример #19
0
        protected void ProcessReceivedMessage(string data)
        {
            if (string.IsNullOrEmpty(data) == true || data.Length <= 0)
            {
                Debug.Log("Empty"); //data 비어있떠
                return;
            }

            Debug.Log("UXConnectController ProcessReceivedMessage data : " + data);

            var    N       = JSON.Parse(data);
            string command = N["cmd"];

            if (command == "ack_result")
            {
                if (isSendAck == true && ackSender != null)                   //x
                {
                    ackSender.ReceiveResult();
                }
            }
            else if (command == "user_add")
            {
                int    code    = N ["u_code"].AsInt;
                string name    = ParseUser(N ["name"]);
                UXUser userObj = new UXUser(name, code);

                Debug.Log("UserAdd : " + name);

                room.AddUser(userObj);

                var array = N ["user_list"];

                if (array != null)
                {
                    List <UXUser> list = ParseUserList((JSONArray)array);                     //리스트 갱신

                    room.UpdateUserList(list);
                }

                if (OnUserAdded != null)
                {
                    int userIndex = GetUserIndexFromCode(code);
                    OnUserAdded(userIndex, code);                      //playerCount 갱신, index 증가 -> index는 접속할 유저에게 할당할 index  +이벤트 하나더 (로비매니저)
                }
            }
            else if (command == "user_del")
            {
                int code      = N ["u_code"].AsInt;
                int userIndex = GetUserIndexFromCode(code);

                Debug.Log("UserDel: " + userIndex);
                if (OnGetRemovedIndex != null)
                {
                    OnGetRemovedIndex(userIndex);
                }

                room.RemoveUser(userIndex);

                var array = N ["user_list"];

                if (array != null)
                {
                    List <UXUser> list = ParseUserList((JSONArray)array);
                    room.UpdateUserList(list);
                }

                if (!isGameStarted)
                {
                    if (OnUserRemoved != null)
                    {
                        OnUserRemoved(name, code);
                    }
                }
                else
                {
                    if (OnUserLeavedInGame != null)
                    {
                        OnUserLeavedInGame(userIndex, code);
                    }
                }
            }
            else if (command == "update_user_index_result")                 // 사용되고 있음
            {
                int index = N ["index"].AsInt;

                UXPlayerController player = UXPlayerController.Instance;
                player.SetIndex(index);
                if (OnIndexChanged != null)
                {
                    UXLog.SetLogMessage(" onindexchanged");
                    OnIndexChanged(index);
                }
            }
            else if (command == "send_error")
            {
            }
            else if (command == "exit_result")
            {
                if (OnExit != null)
                {
                    OnExit();
                }
            }
            else if (command == "host_close")
            {
                if (OnHostDisconnected != null)
                {
                    OnHostDisconnected();
                }
            }
            else if (command == "data")
            {
                string val = N ["data"].Value.ToString();

                if (val == "")
                {
                    val = N ["data"].ToString();
                }

                int senderCode = N ["sender"].AsInt;
                int userIndex  = GetUserIndexFromCode(senderCode);

                if (OnReceived != null)
                {
                    //OnReceived (userIndex, val);
                    OnReceived(senderCode, val);
                }
            }
            else if (command == "check_network_state_result")                   //이거 안올듯. 위에서 cmd:check_network_state를안보내
            {
                int    cur   = N ["count"].AsInt;
                string temp  = N ["time"];
                long   stime = long.Parse(temp);

                networkCheckValues [cur - 1] = DateTime.Now.Ticks - stime;

                if (cur >= networkCheckCount)
                {
                    float totalTime = 0;
                    for (int i = 0; i < networkCheckCount; i++)
                    {
                        totalTime += networkCheckValues [i];
                    }

                    if (OnNetworkReported != null)
                    {
                        OnNetworkReported(networkCheckCount, totalTime);
                    }

                    UXPlayerController player = UXPlayerController.Instance;

                    if (isSendNetWorkResult == true)
                    {
                        string sendString = "{\"cmd\":\"report_network_state\",\"u_code\":\"" + player.GetCode() + "\",\"l_code\":\"" + launcherCode + "\",\"count\":\"" + networkCheckCount + "\",\"time\":\"" + totalTime + "\"}&";
                        Send(sendString);
                    }
                }
            }
            else if (command == "start_game_result")
            {
                isGameStarted = true;

                if (OnGameStart != null)
                {
                    OnGameStart();
                }
            }
            else if (command == "restart_game_result")
            {
                isGameStarted = true;

                if (OnGameRestart != null)
                {
                    OnGameRestart();
                }
            }
            else if (command == "result_game_result")                //안쓰일듯
            {
                if (OnGameResult != null)
                {
                    OnGameResult();
                }
            }
            else if (command == "end_game_result")
            {
                isGameStarted = false;

                if (OnGameEnd != null)
                {
                    OnGameEnd();
                }
            }
            else if (command == "host_joined")
            {
                isHostJoined = true;

                if (OnHostJoined != null)
                {
                    OnHostJoined();
                }
            }
            else if (command == "get_user_list_result")
            {
                Debug.Log("UserList: ");
                List <UXUser>    userList       = ParseUserList((JSONArray)N ["user_list"]);
                UXUserController userController = UXUserController.Instance;


                if (userController.IsEqual(userList) == false)
                {
                    userController.CopyList(userList);

                    if (OnUserListReceived != null)
                    {
                        OnUserListReceived(userList);                          //log찍는듯
                    }
                }

                /*
                 * if (connectMode == UXConnectController.Mode.Client) { //PAD면
                 *      UXPlayerController playerController = UXPlayerController.Instance;
                 *      for (int i = 0; i < userController.GetCount (); i++) {
                 *              UXUser user = (UXUser)userController.GetAt (i); //유저마다
                 *              if (playerController.GetCode () == user.GetCode ()) { //코드를 비교 해서 나를 찾는거
                 *                      if (i != playerController.GetIndex ()) {
                 *                              if (OnIndexChanged != null) {
                 *                                      OnIndexChanged (i);
                 *                              }
                 *
                 *                              playerController.SetIndex (i);
                 *                              Debug.Log ("SetInedx : " + i);
                 *                      }
                 *                      break;
                 *              }
                 *      }
                 * }
                 */
            }
            else if (command == "update_ready_count_result")
            {
                int ready = N ["ready"].AsInt;
                int total = N ["total"].AsInt;

                if (OnUpdateReadyCount != null)
                {
                    OnUpdateReadyCount(ready, total);
                }
            }
        }
Пример #20
0
 void OnUpdateReadyCount(int ready, int total)
 {
     UXLog.SetLogMessage("OnUpdateReadyCount > ready : " + ready + ", total : " + total + " == 12");
     Debug.Log("OnUpdateReadyCount > ready : " + ready + ", total : " + total + " == 12");
 }
Пример #21
0
 void OnAutoCountChanged(int restSecond)
 {
     UXLog.SetLogMessage("OnAutoCountChanged > restSecond:" + restSecond + " == 11");
     Debug.Log("OnAutoCountChanged > restSecond:" + restSecond + " == 11");
 }
Пример #22
0
 void OnUserNetworkReported(int userIndex, int count, float time)
 {
     UXLog.SetLogMessage("OnUserNetworkReported > userIndex : " + userIndex + ", count : " + count + ", time : " + time + " == 8");
     Debug.Log("OnUserNetworkReported > userIndex : " + userIndex + ", count : " + count + ", time : " + time + " == 8");
 }