Exemplo n.º 1
0
 public static LiengHandler getInstance()
 {
     if (instance == null)
     {
         instance = new LiengHandler();
     }
     return(instance);
 }
Exemplo n.º 2
0
    //GameControl gameControl;

    public void initConnect()
    {
        NetworkUtil.GI().registerHandler(ProcessHandler.getInstance());
        ProcessHandler.setListenner(this);
        PHandler.setListenner(this);
        TLMNHandler.setListenner(this);
        XiToHandler.setListenner(this);
        XocDiaHandler.setListenner(this);
        LiengHandler.setListenner(this);
    }
Exemplo n.º 3
0
    public void SetCasino(int type, UnityAction callback)
    {
        switch (GameConfig.CurrentGameID)
        {
            #region TLMN
        case GameID.TLMN:
            Card.setCardType(1);
            //objPlayer = objPlayerTLMN;
            ProcessHandler.setSecondHandler(TLMNHandler.getInstance());
            LoadAssetBundle.LoadScene(SceneName.GAME_TLMN, SceneName.GAME_TLMN, () => {
                TLMNControl.instance.UnloadAllSubScene();
                CurrentCasino = (TLMNControl.instance);
                try {
                    if (callback != null)
                    {
                        callback.Invoke();
                    }
                    for (int i = 0; i < ListMsg.Count; i++)
                    {
                        ProcessHandler.getInstance().processMessage(ListCMDID[i], ListMsg[i]);
                    }
                    ListCMDID.Clear();
                    ListMsg.Clear();
                } catch (Exception e) {
                    Debug.LogException(e);
                }
            });
            break;

            #endregion
            #region TLMN SL
        case GameID.TLMNSL:
            Card.setCardType(1);
            //objPlayer = objPlayerTLMN;
            ProcessHandler.setSecondHandler(TLMNHandler.getInstance());
            LoadAssetBundle.LoadScene(SceneName.GAME_TLMN_SOLO, SceneName.GAME_TLMN_SOLO, () => {
                CurrentCasino = (TLMNSoloControl.instace);
                try {
                    if (callback != null)
                    {
                        callback.Invoke();
                    }
                    for (int i = 0; i < ListMsg.Count; i++)
                    {
                        ProcessHandler.getInstance().processMessage(ListCMDID[i], ListMsg[i]);
                    }
                    ListCMDID.Clear();
                    ListMsg.Clear();
                } catch (Exception e) {
                    Debug.LogException(e);
                }
            });
            break;

            #endregion
            #region SAM
        case GameID.SAM:
            //objPlayer = objPlayerSam;
            Card.setCardType(1);
            ProcessHandler.setSecondHandler(TLMNHandler.getInstance());
            LoadAssetBundle.LoadScene(SceneName.GAME_SAM, SceneName.GAME_SAM, () => {
                CurrentCasino = (SamControl.instace);
                try {
                    if (callback != null)
                    {
                        callback.Invoke();
                    }
                    for (int i = 0; i < ListMsg.Count; i++)
                    {
                        ProcessHandler.getInstance().processMessage(ListCMDID[i], ListMsg[i]);
                    }
                    ListCMDID.Clear();
                    ListMsg.Clear();
                } catch (Exception e) {
                    Debug.LogException(e);
                }
            });
            break;

            #endregion
            #region PHOM
        case GameID.PHOM:
            Card.setCardType(0);
            //objPlayer = objPlayerPhom;
            ProcessHandler.setSecondHandler(PHandler.getInstance());
            LoadAssetBundle.LoadScene(SceneName.GAME_PHOM, SceneName.GAME_PHOM, () => {
                CurrentCasino = (PhomControl.instace);
                try {
                    if (callback != null)
                    {
                        callback.Invoke();
                    }
                    for (int i = 0; i < ListMsg.Count; i++)
                    {
                        ProcessHandler.getInstance().processMessage(ListCMDID[i], ListMsg[i]);
                    }
                    ListCMDID.Clear();
                    ListMsg.Clear();
                } catch (Exception e) {
                    Debug.LogException(e);
                }
            });
            break;

            #endregion
            #region MAU BINH
        case GameID.MAUBINH:
            Card.setCardType(1);
            //objPlayer = objPlayerMauBinh;
            LoadAssetBundle.LoadScene(SceneName.GAME_MAU_BINH, SceneName.GAME_MAU_BINH, () => {
                CurrentCasino = (MauBinhControl.instace);
                try {
                    if (callback != null)
                    {
                        callback.Invoke();
                    }
                    for (int i = 0; i < ListMsg.Count; i++)
                    {
                        ProcessHandler.getInstance().processMessage(ListCMDID[i], ListMsg[i]);
                    }
                    ListCMDID.Clear();
                    ListMsg.Clear();
                } catch (Exception e) {
                    Debug.LogException(e);
                }
            });
            break;

            #endregion
            #region XOC DIA
        case GameID.XOCDIA:
            //objPlayer = objPlayerXocDia;

            ProcessHandler.setSecondHandler(XocDiaHandler.getInstance());
            LoadAssetBundle.LoadScene(SceneName.GAME_XOC_DIA, SceneName.GAME_XOC_DIA, () => {
                CurrentCasino = (XocDiaControl.instance);
                try {
                    if (callback != null)
                    {
                        callback.Invoke();
                    }
                    Debug.LogError(CurrentCasino + " bi tre:  " + ListMsg.Count);
                    for (int i = 0; i < ListMsg.Count; i++)
                    {
                        ProcessHandler.getInstance().processMessage(ListCMDID[i], ListMsg[i]);
                        Debug.LogError("========   " + ListCMDID[i]);
                    }
                    ListCMDID.Clear();
                    ListMsg.Clear();
                } catch (Exception e) {
                    Debug.LogException(e);
                }
            });
            break;

            #endregion
            #region LIENG
        case GameID.LIENG:
            Card.setCardType(0);
            //objPlayer = objPlayerLieng;
            ProcessHandler.setSecondHandler(LiengHandler.getInstance());
            LoadAssetBundle.LoadScene(SceneName.GAME_LIENG, SceneName.GAME_LIENG, () => {
                LiengControl.instance.UnloadAllSubScene();
                CurrentCasino = (LiengControl.instance);
                try {
                    if (callback != null)
                    {
                        callback.Invoke();
                    }
                    Debug.LogError("====so luong:  " + ListMsg.Count);
                    //for (int i = 0; i < ListMsg.Count; i++) {
                    //	ProcessHandler.getInstance().processMessage(ListCMDID[i], ListMsg[i]);
                    //}
                    //ListCMDID.Clear();
                    //ListMsg.Clear();
                    //StartCoroutine(runCMD());
                } catch (Exception e) {
                    Debug.LogException(e);
                }
            });
            break;

            #endregion
            #region BA CAY
        case GameID.BACAY:
            Card.setCardType(0);
            //objPlayer = objPlayerLieng;
            ProcessHandler.setSecondHandler(LiengHandler.getInstance());
            LoadAssetBundle.LoadScene(SceneName.GAME_BA_CAY, SceneName.GAME_BA_CAY, () => {
                BaCayControl.instance.UnloadAllSubScene();
                CurrentCasino = (BaCayControl.instance);
                try {
                    if (callback != null)
                    {
                        callback.Invoke();
                    }
                    for (int i = 0; i < ListMsg.Count; i++)
                    {
                        ProcessHandler.getInstance().processMessage(ListCMDID[i], ListMsg[i]);
                    }
                    ListCMDID.Clear();
                    ListMsg.Clear();
                } catch (Exception e) {
                    Debug.LogException(e);
                }
            });
            break;

            #endregion
            #region POKER
        case GameID.POKER:
            Card.setCardType(1);
            //objPlayer = objPlayerLieng;
            ProcessHandler.setSecondHandler(LiengHandler.getInstance());
            LoadAssetBundle.LoadScene(SceneName.GAME_POKER, SceneName.GAME_POKER, () => {
                PokerControl.instance.UnloadAllSubScene();
                CurrentCasino = (PokerControl.instance);
                try {
                    if (callback != null)
                    {
                        callback.Invoke();
                    }
                    for (int i = 0; i < ListMsg.Count; i++)
                    {
                        ProcessHandler.getInstance().processMessage(ListCMDID[i], ListMsg[i]);
                    }
                    ListCMDID.Clear();
                    ListMsg.Clear();
                } catch (Exception e) {
                    Debug.LogException(e);
                }
            });
            break;

            #endregion
            #region XI TO
        case GameID.XITO:
            Card.setCardType(0);
            //objPlayer = objPlayerLieng;
            //ProcessHandler.setSecondHandler(LiengHandler.getInstance());
            LoadAssetBundle.LoadScene(SceneName.GAME_XI_TO, SceneName.GAME_XI_TO, () => {
                XiToControl.instance.UnloadAllSubScene();
                CurrentCasino = (XiToControl.instance);
                try {
                    if (callback != null)
                    {
                        callback.Invoke();
                    }
                    for (int i = 0; i < ListMsg.Count; i++)
                    {
                        ProcessHandler.getInstance().processMessage(ListCMDID[i], ListMsg[i]);
                    }
                    ListCMDID.Clear();
                    ListMsg.Clear();
                } catch (Exception e) {
                    Debug.LogException(e);
                }
            });
            break;
            #endregion
        }
    }