Ejemplo n.º 1
0
    public IEnumerator DownApk(string url)
    {
        WWW www = new WWW(url);

        do
        {
            yield return(null);

            LoadingNode.OpenLoadingNode(LoadingType.Progress, "正在下载最新资源包...", www.progress);
        } while (!www.isDone);

        if (www.size > 0)
        {
            string filePath = Application.persistentDataPath + "/APK";
            if (!Directory.Exists(filePath))
            {
                Directory.CreateDirectory(filePath);
            }
            File.WriteAllBytes(filePath + "/version.apk", www.bytes);
            SDKManager.Instance.Install(filePath + "/version.apk");
        }
        else
        {
            SetTimeout.add(2f, () =>
            {
                LoadingNode.CloseLoadingNode();
            });
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 小结算
    /// </summary>
    /// <param name="msg"></param>
    private void OnSettlement(MessageData msg)
    {
        litSemResponse data = msg.Read <litSemResponse>();

        CardsInfoStruct[] playerCardsDatas = MJGameModel.Inst.allPlayersCardsInfoStruct;
        bool isNoWinner = true;//是否是流局

        for (int i = 0; i < playerCardsDatas.Length; i++)
        {
            if (playerCardsDatas[i] != null && playerCardsDatas[i].huList != null && playerCardsDatas[i].huList.Count > 0)
            {
                isNoWinner = false;
                break;
            }
        }
        if (isNoWinner) //流局
        {
            mGameUI.ServerNoWinner();
        }
        #region 小结算数据处理
        MJGameSettlementInfo mSettlData = new MJGameSettlementInfo();
        MJGameModel.Inst.mLitSem   = data;
        mSettlData.isEnd           = true;
        mSettlData.isHu            = !isNoWinner;
        mSettlData.settleContainer = new List <MJGameSettlementPlayerInfo>();
        for (int i = 0; i < data.litSemList.Count; i++)
        {
            MJGameSettlementPlayerInfo oneSettlementPlayerInfo = new MJGameSettlementPlayerInfo();
            int seatID = data.litSemList[i].seatId;
            PlayerInfoStruct onePData = MJGameModel.Inst.mRoomPlayers[seatID];              //玩家信息
            CardsInfoStruct  cdata    = MJGameModel.Inst.allPlayersCardsInfoStruct[seatID]; //牌信息
            oneSettlementPlayerInfo.seatId   = seatID;
            oneSettlementPlayerInfo.userId   = onePData.uId;
            oneSettlementPlayerInfo.nickName = onePData.nickName;
            oneSettlementPlayerInfo.score    = data.litSemList[i].currScore;
            oneSettlementPlayerInfo.headUrl  = onePData.headUrl;
            oneSettlementPlayerInfo.shoupai  = data.litSemList[i].handList;
            oneSettlementPlayerInfo.peng     = cdata.pengList;
            oneSettlementPlayerInfo.gang     = cdata.gangList;
            oneSettlementPlayerInfo.huPai    = cdata.huList;
            oneSettlementPlayerInfo.huOrder  = data.litSemList[i].huOrder;
            oneSettlementPlayerInfo.huDes    = data.litSemList[i].huIntro;
            mSettlData.settleContainer.Add(oneSettlementPlayerInfo);
        }
        #endregion

        MJGameModel.Inst.mSettlData = mSettlData;
        MJGameModel.Inst.mState     = eMJRoomStatus.GAMEOVER;
        MJGameModel.Inst.mStartGameData.roomInfo.roomState = eRoomState.GAMEOVER;//改变房间状态
        SetTimeout.add(1, ChangHandsCardsShow);

        SetTimeout.add(5, ShowSmallSettle);

        //清理离开游戏的玩家
        if (mGameUI != null)
        {
            mGameUI.SetAllPlayerOutLine();
        }
    }
Ejemplo n.º 3
0
    void Start()
    {
#if UNITY_ANDROID
        SendMsg(INIT_SQ_SDK, gameObject.name);//初始化SDK,设置回调物体
        //SendMsg("InitPay", "3015488239");//初始化支付
#elif UNITY_IPHONE
        SetTimeout.add(600, OnTimeToGetLocation, false, false);
#endif
    }
Ejemplo n.º 4
0
    //public void Create()
    //{
    //    for (int i = 0; i < 10; i++)
    //    {
    //        MaJangResultMj mj = Instantiate(mjPrefab, handParent);
    //        mj.gameObject.SetActive(true);
    //        //mj.Init(handList[i].mjNo.ToString());
    //        mj.transform.SetParent(handParent);
    //    }
    //    gameObject.SetActive(true);

    //    handParent.SetParent(horizontal);
    //    //SetTimeout.add(0.2f, () =>
    //    //{
    //    //    handParent.gameObject.SetActive(false);
    //    //    horizontal.gameObject.SetActive(false);
    //    //    handParent.gameObject.SetActive(true);
    //    //    horizontal.gameObject.SetActive(true);
    //    //});
    //}

    void OnEnable()
    {
        SetTimeout.add(0.1f, () =>
        {
            handParent.gameObject.SetActive(false);
            horizontal.gameObject.SetActive(false);
            handParent.gameObject.SetActive(true);
            horizontal.gameObject.SetActive(true);
        });
    }
Ejemplo n.º 5
0
    /// <summary>
    /// 推送结算
    /// </summary>
    public static void G2C_Result(DdzJieSuanResp result)
    {
        LandlordsModel.Instance.IsInFight = false;
        DdzJieSuanInfo juesuanInfo = result.jieSuanInfo;

        //yield return new WaitForSecondsRealtime(0.1f);
        LandlordsModel.Instance.ResultModel.zd  = result.jieSuanInfo.zdbs;
        LandlordsModel.Instance.ResultModel.jdz = result.jieSuanInfo.dzbs;
        LandlordsModel.Instance.ResultModel.ct  = result.jieSuanInfo.ct ? 2 : 0;
        LandlordsModel.Instance.ResultModel.fct = result.jieSuanInfo.fc ? 2 : 0;
        for (int i = 0; i < juesuanInfo.playerInfo.Count; i++)
        {
            DdzJSPlayerInfo playerIcom = juesuanInfo.playerInfo[i];
            LandlordsModel.Instance.ResultModel.Add(playerIcom);
            if (playerIcom.income > 0)
            {
                LandlordsModel.Instance.CurWinerIds.Add(playerIcom.userId);
            }

            if (LandlordsModel.Instance.RoomModel.CurRoomInfo.IsMatch)
            {
                LandlordsModel.Instance.RoomPlayerHands.Find(p => p.playerInfo.uid == juesuanInfo.playerInfo[i].userId.ToString()).MatchScore += juesuanInfo.playerInfo[i].income;
            }
            else if (LandlordsModel.Instance.RoomModel.CurRoomInfo.RoomType == RoomType.RoomCard)
            {
                LandlordsModel.Instance.RoomPlayerHands.Find(p => p.playerInfo.uid == juesuanInfo.playerInfo[i].userId.ToString()).playerInfo.score += juesuanInfo.playerInfo[i].income;
            }
            else
            {
                LandlordsModel.Instance.RoomPlayerHands.Find(p => p.playerInfo.uid == juesuanInfo.playerInfo[i].userId.ToString()).playerInfo.money = juesuanInfo.playerInfo[i].coin;
            }
        }
        LandlordsModel.Instance.ResultModel.curJs = result.jieSuanInfo.currJs;
        LandlordsModel.Instance.ResultModel.allJs = result.jieSuanInfo.totalJs;

        float delay = 0;

        if (LandlordsModel.Instance.RoomModel.CurRoomInfo.RoomType != RoomType.Match)
        {
            delay = 1.5f;
        }
        else
        {
            delay = 0;
        }
        SetTimeout.add(delay, () =>
        {
            CheckIsChuntianOrReverse(juesuanInfo);
            //总显示
            LandlordsPage.Instance.GameOver();
        });
    }
Ejemplo n.º 6
0
    public override void RoundEnter(bool isCanNoPlay)
    {
        base.RoundEnter(isCanNoPlay);
        switch (OrderController.Instance.CurInterationType)
        {
        case InterationType.CallLandlords:
            clock.Init(LandlordsPage.wait_CallLandlordsTime, 10, 5, null, true);
            break;

        case InterationType.QiangLandlords:
            clock.Init(LandlordsPage.wait_QiangTime, 10, 5, null, true);
            break;

        case InterationType.CallFen:
            clock.Init(LandlordsPage.wait_CallFenTime, 10, 5, () => AutoCallLandlord(), true);
            break;

        case InterationType.PopCard:
            if (LandlordsModel.Instance.IsTuoGuan)
            {
                //如果是托管状态
                return;
            }
            List <Card> cards = CardRules.DelayDiscardCard(UserInfoModel.userInfo.userId.ToString());
            if (CheckIsLastCanAutoPop())
            {
                SetTimeout.add(1.5f, () =>
                {
                    AutoPop();
                });
                return;
            }
            if (cards.Count == 0)
            {
                clock.Init(LandlordsPage.wait_canNotPopTime, 4, 5, () => AutoPop(), true);
            }
            else
            {
                clock.Init(LandlordsPage.wait_PopTime, 10, 5, () => AutoPop(), true);
            }
            break;

        default:
            break;
        }
    }
Ejemplo n.º 7
0
    /// <summary>
    /// 显示网络提示
    /// </summary>
    public void ShowNetTips()
    {
        GameManager.Instance.CancelHeartBreath();
        NetProcess.ReleaseAllConnect();
        Global.Inst.GetController <NetLoadingController>().ShowLoading(true);
        SetTimeout.remove(ReConnet);
        if (Time.realtimeSinceStartup - mLastReconnetTime > 5)//重连间隔要大于5秒
        {
            SQDebug.Log("直接重连");

            ReConnet();
        }
        else
        {
            float time = 5 + mLastReconnetTime - Time.realtimeSinceStartup;
            SQDebug.Log("等" + time + "秒重连");
            SetTimeout.add(time, ReConnet);
        }
    }
Ejemplo n.º 8
0
    public void CheckVersion(CallBack onVersionUpdateFinish)
    {
        _onVersionUpdateFinish = onVersionUpdateFinish;
        LoadingNode.OpenLoadingNode(LoadingType.Progress, "正在检测是否有新版本...", 0);
#if UNITY_EDITOR
        LoadingNode.OpenLoadingNode(LoadingType.Progress, "正在检测是否有新版本...", 1);
        SetTimeout.add(1, () =>
        {
            LoadingNode.CloseLoadingNode();
            if (_onVersionUpdateFinish != null)
            {
                _onVersionUpdateFinish();
                _onVersionUpdateFinish = null;
            }
        });
        //StartCoroutine(BigVersionUpdate(true));
#elif UNITY_ANDROID
        StartCoroutine(BigVersionUpdate(true));
#elif UNITY_IPHONE
        onVersionUpdateFinish();
        //StartCoroutine(BigVersionUpdate());
#endif
    }
Ejemplo n.º 9
0
    public IEnumerator BigVersionUpdate(bool isTip)
    {
        WWW www = new WWW(ConstantUtils.urlVersionConfigPath);

        yield return(www);

        if (string.IsNullOrEmpty(www.error))
        {
            JsonData jds    = JsonMapper.ToObject(www.text.Trim());
            string   apkUrl = "";

#if UNITY_ANDROID
            serverVersion = jds["android_severVersion"].ToString();
            apkUrl        = jds["android_apkUrl"].ToString();
            UserInfoModel.userInfo.downUrl = jds["android_webDownApkUrl"].ToString();
#elif UNITY_IPHONE
            serverVersion = jds["ios_curVersion"].ToString();
            apkUrl        = jds["ios_apkUrl"].ToString();
            UserInfoModel.userInfo.downUrl = jds["ios_webDownApkUrl"].ToString();
#elif UNITY_EDITOR
            serverVersion = jds["android_curVersion"].ToString();
            apkUrl        = jds["android_apkUrl"].ToString();
            UserInfoModel.userInfo.downUrl = jds["android_webDownApkUrl"].ToString();
#endif
            if (VersionManager.Instance.MastUpdate())
            {
                CallBack call = () =>
                {
#if UNITY_ANDROID
                    StartCoroutine(DownloadAPK(apkUrl));
#elif UNITY_IPHONE
                    Application.OpenURL(apkUrl);
                    //IOSCall.Instance.OpenUrl (url);
#endif
                };
                if (isTip)
                {
                    TipManager.Instance.OpenTip(TipType.AlertTip, "检测到版本有更新,请更新!", 0, () =>
                    {
                        call();
                    });
                }
                else
                {
                    call();
                }
            }
            else
            {//如果不需要更新
                if (File.Exists(Application.persistentDataPath + "/APK" + "/version.apk"))
                {
                    File.Delete(Application.persistentDataPath + "/APK" + "/version.apk");
                }

                SetTimeout.add(2f, () =>
                {
                    LoadingNode.CloseLoadingNode();
                });
            }
        }
    }
Ejemplo n.º 10
0
 public void Init(MaJangPlayer player)
 {
     mPlayer = player;
     if (itemName)
     {
         itemName.text = player.nickName.text;
     }
     if (score)
     {
         score.text = player.win.ToString();
     }
     #region 吃 碰 杠
     List <MaJangModel[]> altList = player.lightMjList;
     if (altList.Count > 0)
     {
         for (int i = 0; i < altList.Count; i++)
         {
             MaJangModel[] mjModel = altList[i];
             GameObject    mjAlt   = Instantiate(altPrefab, horizontal);
             mjAlt.SetActive(true);
             for (int j = 0; j < mjAlt.transform.childCount; j++)
             {
                 if (mjModel.Length > j)
                 {
                     mjAlt.transform.GetChild(j).GetComponent <MaJangResultMj>().Init(mjModel[j].mjNo.ToString());
                 }
                 else
                 {
                     mjAlt.transform.GetChild(j).gameObject.SetActive(false);
                 }
             }
             mjAlt.transform.SetParent(horizontal);
         }
     }
     #endregion
     #region 手牌
     List <MaJangModel> handList = player.handMjList;
     int handCount = player.win > 0 ? handList.Count - 1 : handList.Count;
     for (int i = 0; i < handCount; i++)
     {
         MaJangResultMj mj = Instantiate(mjPrefab, handParent);
         mj.gameObject.SetActive(true);
         mj.Init(handList[i].mjNo.ToString());
         mj.transform.SetParent(handParent);
     }
     handParent.gameObject.SetActive(false);
     handParent.GetComponent <HorizontalLayoutGroup>().enabled = false;
     handParent.GetComponent <HorizontalLayoutGroup>().enabled = true;
     handParent.SetParent(horizontal);
     if (player.win > 0)
     {
         MaJangModel last = player.handMjList[handList.Count - 1];
         mjPrefab.Init(last.mjNo.ToString());
         mjPrefab.transform.SetParent(horizontal);
     }
     else
     {
         mjPrefab.gameObject.SetActive(false);
     }
     #endregion
     gameObject.SetActive(true);
     horizontal.GetComponent <HorizontalLayoutGroup>().enabled = false;
     horizontal.GetComponent <HorizontalLayoutGroup>().enabled = true;
     SetTimeout.add(0.1f, () =>
     {
         handParent.gameObject.SetActive(false);
         horizontal.gameObject.SetActive(false);
         handParent.gameObject.SetActive(true);
         horizontal.gameObject.SetActive(true);
     });
 }