コード例 #1
0
    public HttpResult BaseResultSocket(WWW www)
    {
        HttpResult result = new HttpResult();

        if (www.error != null)
        {
            EginTools.Log("Http Failed: " + www.error);
            PlatformGameDefine.playform.swithGameHostUrl();                             //切换游戏IP
        }
        else
        {
            string tempResultStr = www.text.Trim();
            EginTools.Log("base socket:::" + tempResultStr);

            JSONObject resultObj = new JSONObject(tempResultStr);

            if (resultObj)
            {
                result.resultObject = resultObj;
                result.resultType   = HttpResult.ResultType.Sucess;
            }
            else
            {
                Debug.Log("解析出错了---HttpConnect.cs -- 60");
            }
        }
        return(result);
    }
コード例 #2
0
    public HttpResult BaseResultSocket2(WWW www)
    {
        HttpResult result = new HttpResult();

        if (www.error != null)
        {
            EginTools.Log("Http Failed: " + www.error);
            PlatformGameDefine.playform.swithGameHostUrl();             //切换游戏IP
        }
        else
        {
            string tempResultStr = www.text.Trim();
            EginTools.Log(tempResultStr);

            if ("ok".Equals(tempResultStr))
            {
                result.resultType = HttpResult.ResultType.Sucess;
            }
            else
            {
                result.resultObject = ZPLocalization.Instance.Get("HttpConnectError");
            }
        }
        return(result);
    }
コード例 #3
0
ファイル: TBTWPlayerCtrl.cs プロジェクト: linml/Assets
    public void SetScore(int score)
    {
        UISprite[] sprites = cardScoreObj.GetComponentsInChildren <UISprite>();
        if (cardScoreBg)
        {
            cardScoreBg.width = 557;
        }
        else
        {
            foreach (UISprite sprite in sprites)
            {
                Destroy(sprite.gameObject);
            }
        }
        if (sprites.Length > 1)
        {
            foreach (UISprite sprite in sprites)
            {
                if (cardScoreBg)
                {
                    if (sprite.gameObject != cardScoreBg.gameObject)
                    {
                        Destroy(sprite.gameObject);
                    }
                }
                else
                {
                    Destroy(sprite.gameObject);
                }
            }
        }
        if (cardScoreBg)
        {
            if (score == -1)
            {
                //cardScoreObj.SetActive(false);
                cardScoreBg.spriteName = "score_board";
                EginTools.AddNumberSpritesCenter(jettonPrefab, cardScoreObj.transform, UserChip.ToString(), "plus_", .8f);
            }
            else
            {
                //cardScoreObj.SetActive(true);

                if (score >= 1000000 || score <= -1000000)
                {
                    cardScoreBg.width = 557;
                }
                if (score >= 0)
                {
                    cardScoreBg.spriteName = "benjia";
                    EginTools.AddNumberSpritesCenter(jettonPrefab, cardScoreObj.transform, "+" + score, "plus_", .8f);
                }
                else if (score < 0)
                {
                    cardScoreBg.spriteName = "benjia_minus";
                    EginTools.AddNumberSpritesCenter(jettonPrefab, cardScoreObj.transform, score.ToString(), "minus_", .8f);
                }
            }
        }
    }
コード例 #4
0
    private IEnumerator requestPhoneCode(string mobile)
    {
        Dictionary <string, string> headers = new Dictionary <string, string>();

        headers.Add("Cookie", session);

        WWWForm form2 = new WWWForm();

        form2.AddField("Cookie", session);
        form2.AddField("type", "1");
        form2.AddField("mobile", mobile);
        long   ms2    = EginTools.nowMinis();
        long   mms2   = ms2 + EginTools.localBeiJingTime;
        string ccode2 = EginTools.encrypTime(mms2.ToString());

        form2.AddField("client_code", ccode2);

        WWW w2 = new WWW(serverURL + "unity/htddz/send_phone_code/", form2.data, headers);

        yield return(w2);

        if (w2.error == null)
        {
            Debug.LogError(w2.text);
            JSONObject json = new JSONObject(w2.text);
            //Debug.LogError( System.Text.RegularExpressions.Regex.Unescape(json["body"].str) );
            EginProgressHUD.Instance.ShowPromptHUD(System.Text.RegularExpressions.Regex.Unescape(json["body"].str));
        }
        else
        {
            EginProgressHUD.Instance.ShowPromptHUD(w2.error);
        }
    }
コード例 #5
0
 // Update is called once per frame
 void Update()
 {
     if ((Time.time - _currTime) >= 1)
     {
         if (_num > 0)
         {
             _num--;
             UpdateHUD(_num);
             if (isShakeStyle)
             {
                 transform.Find("timebackground").gameObject.GetComponent <UISprite>().alpha = 0;
                 spriteL.alpha = 0;
                 spriteR.alpha = 0;
             }
             if (_num <= 5 && soundCount != null)
             {
                 EginTools.PlayEffect(soundCount);
                 //NGUITools.PlaySound(soundCount);
                 if (isShakeStyle)
                 {
                     transform.Find("timebackground").gameObject.GetComponent <UISprite>().alpha = 1;
                     spriteL.alpha = 1;
                     spriteR.alpha = 1;
                     iTween.ShakeRotation(transform.Find("timebackground").gameObject, iTween.Hash("time", 0.8f, "z", 30.0f, "easetype", iTween.EaseType.linear));
                 }
             }
         }
     }
 }
コード例 #6
0
ファイル: TBTWPlayerCtrl.cs プロジェクト: linml/Assets
    /// <summary>
    /// 发牌(带动画效果,需要在编辑器里将扑克牌的Active设为false)
    /// </summary>
    /// <returns>The deal.</returns>
    /// <param name="toShow">If set to <c>true</c> to show.</param>
    /// <param name="infos">Infos.</param>
    public void SetDeal(bool toShow, List <JSONObject> infos)
    {
        if (!toShow)
        {
            cardsTrans.gameObject.SetActive(false);
        }
        else
        {
            //bosonA.SetActive(true);
            float x = parentX + 2 * _cardInterval;
            //cardsTrans.gameObject.SetActive(true);

            for (int i = 0; i < cardsArray.Length; i++)
            {
                if (null != soundSend)
                {
                    EginTools.PlayEffect(soundSend);
                }
                // cardsTrans.localPosition = new Vector3(x - _cardInterval / 2 * i, parentY, parentZ);
                //cardsArray[i].gameObject.SetActive(true);

                if (null != infos && infos.Count > 0)
                {
                    cardsArray[i].spriteName = _cardPre + infos[i].ToString();
                }
                //yield return new WaitForSeconds(.2f);
            }
        }
    }
コード例 #7
0
ファイル: FootInfo_TBTW.cs プロジェクト: linml/Assets
 public void UpdateIntomoney(string intoMoney)
 {
     if (!string.IsNullOrEmpty(intoMoney))
     {
         labelBagmoney.text = "" + EginTools.NumberAddComma(intoMoney);
     }
 }
コード例 #8
0
 private void invokeCD()
 {
     if (cd == 0)
     {
         CancelInvoke("invokeCD");
         if (PlatformGameDefine.game.GameTypeIDs == "9")            //日赛
         {
             for (int i = 0; i < 6; i++)
             {
                 dailyCountDownLbs[i].text = "0";
             }
         }
         else
         {
             countDownLb.text = "0";
         }
     }
     else
     {
         if (PlatformGameDefine.game.GameTypeIDs == "9")            //日赛
         {
             string fixTime = EginTools.miao2TimeStr(cd, true, true).Replace(":", "");
             char[] charAry = fixTime.ToCharArray();
             for (int i = 0; i < 6; i++)
             {
                 dailyCountDownLbs[i].text = charAry[i].ToString();
             }
         }
         else
         {
             countDownLb.text = EginTools.miao2TimeStr(cd);
         }
         cd--;
     }
 }
コード例 #9
0
    // Update is called once per frame
    void Update()
    {
        if ((Time.time - _currTime) >= 1)
        {
            if (_num > 0)
            {
                _num--;
                UpdateHUD(_num, 11);

                if (_num <= 5 && soundCount != null)
                {
                    gameObject.GetComponent <UISprite>().spriteName = "timerBgRed";
                    EginTools.PlayEffect(soundCount);
                    if (_num == 0 && timeUpCallback != null)
                    {
                        timeUpCallback();
                    }
                }
                else
                {
                    gameObject.GetComponent <UISprite>().spriteName = "timerBgGreen";
                }
            }
        }
    }
コード例 #10
0
    public WWW HttpRequestWithSession(string url, WWWForm form)
    {
        EginTools.Log(url);

        string    cookie         = (EginUser.Instance.session != null)?EginUser.Instance.session:"";
        Hashtable requestHeaders = new Hashtable();

        requestHeaders.Add("Cookie", cookie);


        Dictionary <string, string> headers = new Dictionary <string, string>();

        headers.Add("Cookie", cookie);

        if (form == null)
        {
            form = new WWWForm();
        }
        form.AddField("Cookie", cookie);

        if (form != null)
        {
            long   ms    = EginTools.nowMinis();
            long   mms   = ms + EginTools.localBeiJingTime;
            string ccode = EginTools.encrypTime(mms.ToString());

            form.AddField("client_code", ccode);
        }

        WWW www = new WWW(url, form.data, headers);

        return(www);
    }
コード例 #11
0
    public WWW HttpRequestAli(string url)
    {
        EginTools.Log(url);

        WWW www = new WWW(url);

        return(www);
    }
コード例 #12
0
    protected void UpdateBankRecord(JSONObject obj)
    {
        /*
         * {"page":{"total":总记录数,"pagecount":总页数,"pageindex":第几页,"pagesize":每页条数}
         * ,"data":[{"action_time":操作时间,"action_type":交易类别,"action_money":交易额
         * ,"start_money":起始钱数,"end_money":结束钱数,"remark":备注
         * ,"user_id":通常是自己的id,"to_user_id":对方id,"to_user_nickname":对方昵称},...]}
         */
        //{"body": {"data": [
        //{"action_time": "2016-04-10 20:06:29", "start_money": 801105, "action_money": 1000, "user_id": 889198535, "to_user_nickname": "", "remark": "游戏内存款", "end_money": 802105, "action_type": "存款", "to_user_id": ""},
        //{"action_time": "2016-04-10 19:46:39", "start_money": 800105, "action_money": 1000, "user_id": 889198535, "to_user_nickname": "", "remark": "游戏内存款", "end_money": 801105, "action_type": "存款", "to_user_id": ""},
        //{"action_time": "2016-04-10 19:46:34", "start_money": 800104, "action_money": 1, "user_id": 889198535, "to_user_nickname": "", "remark": "游戏内存款", "end_money": 800105, "action_type": "存款", "to_user_id": ""},
        //{"action_time": "2016-04-10 19:45:45", "start_money": 799993, "action_money": 111, "user_id": 889198535, "to_user_nickname": "", "remark": "游戏内存款", "end_money": 800104, "action_type": "存款", "to_user_id": ""},
        //{"action_time": "2016-04-10 17:15:03", "start_money": 799992, "action_money": 1, "user_id": 889198535, "to_user_nickname": "", "remark": "游戏内存款", "end_money": 799993, "action_type": "存款", "to_user_id": ""}
        //], "page": {"pageindex": 1, "total": 45, "pagesize": 5, "pagecount": 9}}, "tag": "bankrecord", "type": "account"}
        recordPage       = (int)obj["page"]["pageindex"].n;
        maxRecordPage    = (int)obj["page"]["pagecount"].n;
        kRecordPage.text = recordPage + "/" + maxRecordPage;

        EginTools.ClearChildren(vRecords);
        List <JSONObject> recordInfoList = obj["data"].list;
        int i = 0;

        foreach (JSONObject recordInfo in recordInfoList)
        {
            if (recordInfo.type == JSONObject.Type.NULL)
            {
                break;
            }

            GameObject cell = (GameObject)Instantiate(recordPrefab);
            cell.transform.parent        = vRecords;
            cell.transform.localPosition = new Vector3(0, i * -100, 0);
            cell.transform.localScale    = Vector3.one;

            string actionTime = recordInfo["action_time"].str;
            if (actionTime.Length > 10)
            {
                actionTime = actionTime.Substring(0, 10);
            }
            ((UILabel)cell.transform.Find("Label_Time").GetComponent(typeof(UILabel))).text = actionTime;
            if (PlatformGameDefine.playform.IsSocketLobby)
            {
                ((UILabel)cell.transform.Find("Label_Type").GetComponent(typeof(UILabel))).text  = Regex.Unescape(recordInfo["action_type"].str);
                ((UILabel)cell.transform.Find("Label_Money").GetComponent(typeof(UILabel))).text = recordInfo["action_money"].n + "";
                ((UILabel)cell.transform.Find("Label_Start").GetComponent(typeof(UILabel))).text = recordInfo["start_money"].n + "";
                ((UILabel)cell.transform.Find("Label_End").GetComponent(typeof(UILabel))).text   = recordInfo["end_money"].n + "";
            }
            else
            {
                ((UILabel)cell.transform.Find("Label_Type").GetComponent(typeof(UILabel))).text  = recordInfo["action_type"].str;
                ((UILabel)cell.transform.Find("Label_Money").GetComponent(typeof(UILabel))).text = recordInfo["action_money"].str;
                ((UILabel)cell.transform.Find("Label_Start").GetComponent(typeof(UILabel))).text = recordInfo["start_money"].str;
                ((UILabel)cell.transform.Find("Label_End").GetComponent(typeof(UILabel))).text   = recordInfo["end_money"].str;
            }
            i++;
        }
    }
コード例 #13
0
//	public void reliveOk()
//	{
//
//	}
//
//	public void reliveCancel()
//	{
//
//	}

    private void repeatingCD()
    {
        if (cd <= 0)
        {
            CancelInvoke("repeatingCD");
            timeout();
        }
        cdTimeLb.text = EginTools.miao2TimeStr(cd, true, true).Substring(3);
        cd--;
    }
コード例 #14
0
 private void cdInvoke()
 {
     if (curTime <= 0)
     {
         curTime = 0;
         CancelInvoke("cdInvoke");
     }
     cdTimeLb.text = "比赛开始倒计时: [e3371b]" + EginTools.miao2TimeStr(curTime, true, true) + "[-]";
     curTime      -= 1;
 }
コード例 #15
0
ファイル: TBTWPlayerCtrl.cs プロジェクト: linml/Assets
    public void SetPlayerInfo(int avatar, string nickname, string intomoney, string level)
    {
        userAvatar.spriteName = "avatar_" + avatar;
        userNickname.text     = nickname;
        userIntomoney.text    = "¥ " + EginTools.NumberAddComma(intomoney);

        kDetailNickname.text = nickname;
        kDetailLevel.text    = level;
        kDetailBagmoney.text = intomoney;
    }
コード例 #16
0
 private void finalCDInvoke()
 {
     if (finalTimeStart <= 0)
     {
         finalTimeStart = 0;
         CancelInvoke("finalCDInvoke");
         isFinalVS = true;
     }
     countDownFinal.text = EginTools.miao2TimeStr(finalTimeStart, true, true);
     finalTimeStart     -= 1;
 }
コード例 #17
0
    void OnClickGift()
    {
        string errorInfo = "";

        if (kGiftID.value.Length == 0)
        {
            errorInfo = ZPLocalization.Instance.Get("GiftID");
        }
        else if (kGiftMoney.value.Length == 0)
        {
            errorInfo = ZPLocalization.Instance.Get("GiftMoney");
        }
        else if (!isLogin && kBankPassword.value.Length == 0 && kPhoneCode.value.Length == 0)
        {
            errorInfo = ZPLocalization.Instance.Get("GiftPassword");
        }

        if (errorInfo.Length > 0)
        {
            EginProgressHUD.Instance.ShowPromptHUD(errorInfo);
        }
        else
        {
//			EginProgressHUD.Instance.ShowWaitHUD(ZPLocalization.Instance.Get("HttpConnectWait"));
            if (nickName.Length == 0)
            {
                EginProgressHUD.Instance.ShowPromptHUD("用户ID不存在");
            }
            else
            {
                string moneyStr   = kGiftMoney.value;
                string moneyZhStr = EginTools.numToCnNum(moneyStr);
//				if (moneyStr.Length > 8) {
//					moneyZhStr = moneyStr.Substring(0, moneyStr.Length - 8);
//					moneyZhStr += ZPLocalization.Instance.Get("GiftNumberZH_1");
//					moneyZhStr += moneyStr.Substring(moneyStr.Length - 8, 4);
//					moneyZhStr += ZPLocalization.Instance.Get("GiftNumberZH_0");
//					moneyZhStr += moneyStr.Substring(moneyStr.Length - 4, 4);
//				}else if (moneyStr.Length > 4) {
//					moneyZhStr = moneyStr.Substring(0, moneyStr.Length - 4);
//					moneyZhStr += ZPLocalization.Instance.Get("GiftNumberZH_0");
//					moneyZhStr += moneyStr.Substring(moneyStr.Length - 4, 4);
//				}else {
//					moneyZhStr = moneyStr;
//				}
                kConfirmID.text       = kGiftID.value;
                kConfirmMoney.text    = kGiftMoney.value;
                kConfirmMoneyZh.text  = moneyZhStr;
                kConfirmNickname.text = nickName;
                vConfirm.SetActive(true);
            }
        }
    }
コード例 #18
0
 private void invokeScorePlus()
 {
     if (scorePlusTime <= 0)
     {
         scorePlusTime = 0;
         CancelInvoke("invokeScorePlus");
         int nowScore = int.Parse(scoreLb.text);
         scoreLb.text = nowScore * 2 + "";
     }
     countDownMul.text = EginTools.miao2TimeStr(scorePlusTime, true, true);
     scorePlusTime    -= 1;
 }
コード例 #19
0
    public void UserReady()
    {
        //向服务器发送消息(开始游戏)
        JSONObject startJson = new JSONObject();

        startJson.AddField("type", "tbtw");
        startJson.AddField("tag", "start");
        base.SendPackageWithJson(startJson);

        EginTools.PlayEffect(soundStart);

        btnBegin.SetActive(false);
    }
コード例 #20
0
ファイル: TBTWPlayerCtrl.cs プロジェクト: linml/Assets
 public void UpdateIntoMoney(string intomoney)
 {
     if (userIntomoney == null)
     {
         GameObject.Find("Label_Bagmoney").GetComponent <UILabel>().text =
             EginTools.NumberAddComma(intomoney);
     }
     else
     {
         userIntomoney.text = "¥ " + EginTools.NumberAddComma(intomoney);
     }
     //		userIntomoney = userIntomoney == null ? GameObject.Find ("Label_Bagmoney").GetComponent<UILabel>() : userIntomoney;
     //		userIntomoney.text = "¥ " + EginTools.NumberAddComma(intomoney);
 }
コード例 #21
0
    // Update is called once per frame
    void Update()
    {
        if ((Time.time - _currTime) >= 1)
        {
            if (_num > 0)
            {
                _num--;
                UpdateHUD(_num);

                if (_num <= 5 && soundCount != null)
                {
//					NGUITools.PlaySound(soundCount);
                    EginTools.PlayEffect(soundCount);
                }
            }
        }
    }
コード例 #22
0
    void ProcessOk(JSONObject messageObj)
    {
        JSONObject body = messageObj["body"];
        string     uid  = body["uid"].ToString();

        if (uid != EginUser.Instance.uid)
        {
            GameObject.Find(_nnPlayerName + uid).GetComponent <TBTWPlayerCtrl>().SetShow(true);
        }
        else
        {
            List <JSONObject> cards = body["cards"].list;
            int cardType            = (int)body["type"].n;
            userPlayerCtrl.SetCardTypeUser(cards, cardType);
        }

        EginTools.PlayEffect(soundTanover);
    }
コード例 #23
0
    IEnumerator refreshYanImg()
    {
        WWW www2 = HttpConnect.Instance.HttpRequest(ConnectDefine.YAN_ZHENG_URL, null);

        yield return(www2);

        HttpResult result2 = HttpConnect.Instance.BaseResult(www2);
        string     yanUrl;

        if (HttpResult.ResultType.Sucess == result2.resultType)
        {
            JSONObject resultObj2 = new JSONObject(result2.resultObject.ToString());
            yanUrl             = ConnectDefine.HostURL + resultObj2["imageurl"].str;
            captcha_hiddentext = resultObj2["hiddentext"].str;
            EginTools.Log("yanUrl:" + yanUrl);

            WWW www = new WWW(yanUrl);
            yield return(www);

            UITexture uiT = kYanImg.GetComponent <UITexture>();
            uiT.mainTexture = www.texture;

            errNum  = 0;
            isClick = true;
        }
        else
        {
            errNum++;
            if (!result2.isSwitchHost)
            {
                PlatformGameDefine.playform.swithWebHostUrl();
            }
            if (errNum < 4)
            {
                StartCoroutine(refreshYanImg());
            }
            else
            {
                isClick = true;
            }
        }
    }
コード例 #24
0
    public WWW HttpRequest(string url, WWWForm form)
    {
        EginTools.Log(url);

        if (form == null)
        {
            form = new WWWForm();
        }

        if (form != null)
        {
            long   ms    = EginTools.nowMinis();
            long   mms   = ms + EginTools.localBeiJingTime;
            string ccode = EginTools.encrypTime(mms.ToString());
            form.AddField("client_code", ccode);
        }


        WWW www = (form == null) ? new WWW(url) : new WWW(url, form);

        return(www);
    }
コード例 #25
0
    /* ------ Register ------ */
    public HttpResult RegisterResult(WWW www)
    {
        HttpResult result = new HttpResult();

        if (www.error != null)
        {
            EginTools.Log("Http Failed: " + www.error);
        }
        else
        {
            string tempResultStr = www.text.Trim();
            EginTools.Log(tempResultStr);

            if ("ok".Equals(tempResultStr))
            {
                result.resultType = HttpResult.ResultType.Sucess;
            }
            else if (tempResultStr.Length > 0)
            {
                JSONObject resultObj = new JSONObject(tempResultStr);
                if (resultObj.type == JSONObject.Type.NULL)
                {
                    result.resultObject = Regex.Unescape(tempResultStr);
                }
                else
                {
                    result.resultObject = Regex.Unescape(resultObj["error"].str);
                }
            }
            else
            {
                result.resultObject = ZPLocalization.Instance.Get("HttpConnectError");
            }
        }
        return(result);
    }
コード例 #26
0
    private IEnumerator DoCheckBaiduTime()
    {
        if (m_CurTimeOutCount >= mTimeUrl.Length * 2)//超时重连只进行1次
        {
            EginTools.localBeiJingTime = 0;
            yield break;
        }



        using (WWW www = HttpConnect.Instance.HttpRequestAli(mTimeUrl[m_CurTimeOutCount / 2]))
        {
            bool isTimeOut = false;
            yield return(StartCoroutine(CheckTimeOut(www, () => isTimeOut = true)));

            if (isTimeOut)
            {
                m_CurTimeOutCount++;
                StartCoroutine(DoCheckBaiduTime());
                yield break;
            }

            yield return(www);

            Debug.Log("加载网络时间");
            if (www.error != null)
            {
                EginTools.Log("加载网络时间出错: " + www.error);
                EginTools.localBeiJingTime = 0;
            }
            else
            {
                string tempResultStr = www.text.Trim();
                Debug.Log("网络时间数据打印====>" + tempResultStr);

                long time = 0;
                //第一个和第二个时间网站的数据处理
                if (m_CurTimeOutCount / 2 == 0 || m_CurTimeOutCount / 2 == 1)
                {
                    try
                    {
                        int firstIndex  = tempResultStr.IndexOf("new Date().getTime();", 0);
                        int secondIndex = tempResultStr.IndexOf("s=document.URL", firstIndex);

                        string childStr = tempResultStr.Substring(firstIndex + 21, secondIndex - firstIndex - 21);

                        //Debug.Log("截取的数据====>" + childStr);
                        //  nyear=2016;nmonth=5;nday=12;nwday=4;nhrs=16;nmin=0;nsec=47;
                        int firstTinmeIndex  = 0;
                        int secondTinmeIndex = 0;
                        firstTinmeIndex  = childStr.IndexOf("nyear=", firstTinmeIndex);
                        secondTinmeIndex = childStr.IndexOf(";", firstTinmeIndex);
                        int year = int.Parse(childStr.Substring(firstTinmeIndex + 6, secondTinmeIndex - firstTinmeIndex - 6));

                        firstTinmeIndex  = childStr.IndexOf("nmonth=", firstTinmeIndex);
                        secondTinmeIndex = childStr.IndexOf(";", firstTinmeIndex);
                        int month = int.Parse(childStr.Substring(firstTinmeIndex + 7, secondTinmeIndex - firstTinmeIndex - 7));

                        firstTinmeIndex  = childStr.IndexOf("nday=", firstTinmeIndex);
                        secondTinmeIndex = childStr.IndexOf(";", firstTinmeIndex);
                        int day = int.Parse(childStr.Substring(firstTinmeIndex + 5, secondTinmeIndex - firstTinmeIndex - 5));

                        firstTinmeIndex  = childStr.IndexOf("nhrs=", firstTinmeIndex);
                        secondTinmeIndex = childStr.IndexOf(";", firstTinmeIndex);
                        int hour = int.Parse(childStr.Substring(firstTinmeIndex + 5, secondTinmeIndex - firstTinmeIndex - 5));

                        firstTinmeIndex  = childStr.IndexOf("nmin=", firstTinmeIndex);
                        secondTinmeIndex = childStr.IndexOf(";", firstTinmeIndex);
                        int minute = int.Parse(childStr.Substring(firstTinmeIndex + 5, secondTinmeIndex - firstTinmeIndex - 5));

                        firstTinmeIndex  = childStr.IndexOf("nsec=", firstTinmeIndex);
                        secondTinmeIndex = childStr.IndexOf(";", firstTinmeIndex);
                        int second = int.Parse(childStr.Substring(firstTinmeIndex + 5, secondTinmeIndex - firstTinmeIndex - 5));

                        Debug.Log(year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second);
                        DateTime        tempTime = new DateTime(year, month, day, hour, minute, second);
                        System.DateTime d1       = new System.DateTime(1970, 1, 1);
                        System.TimeSpan ts       = new System.TimeSpan(tempTime.ToUniversalTime().Ticks - d1.Ticks);
                        time = (long)ts.TotalMilliseconds;
                    }
                    catch
                    {
                        Debug.Log("错误====" + m_CurTimeOutCount);
                        m_CurTimeOutCount++;
                        StartCoroutine(DoCheckBaiduTime());
                        yield break;
                    }
                }
                long ms = EginTools.nowMinis(); //返回 1970 年 1 月 1 日至今的毫秒数
                EginTools.localBeiJingTime = time - ms;

                Debug.Log(time + "EginTools.localBeiJingTime====>" + EginTools.localBeiJingTime);
            }
        }
    }
コード例 #27
0
    private IEnumerator requestAward(string mobile, string code)
    {
        Dictionary <string, string> headers = new Dictionary <string, string>();

        headers.Add("Cookie", session);

        WWWForm form2 = new WWWForm();

        form2.AddField("Cookie", session);
        form2.AddField("type", "1");
        form2.AddField("mobile", mobile);
        form2.AddField("phonecode", code);
        long   ms2    = EginTools.nowMinis();
        long   mms2   = ms2 + EginTools.localBeiJingTime;
        string ccode2 = EginTools.encrypTime(mms2.ToString());

        form2.AddField("client_code", ccode2);
        form2.AddField("roomid", "1095");

        WWW w2 = new WWW(serverURL + "unity/htddz/reward_jd_card/", form2.data, headers);

        yield return(w2);

        if (w2.error == null)
        {
            Debug.LogError(w2.text);
            JSONObject json = new JSONObject(w2.text);
            if (json["result"].str == "ok")
            {
                if (awardInfo == null)
                {
                    EginProgressHUD.Instance.ShowPromptHUD("没有排名信息");
                    yield return(0);
                }
                if (awardInfo["add_coin"].n > 0)
                {
                    bonusLb.text = awardInfo["add_coin"].n + "元宝";
                }
                string awardCard = "";
                if (awardInfo["item_id"].n >= 121 && awardInfo["item_id"].n <= 125)
                {
                    string bonusStr = bonusLb.text;

                    if (awardInfo["item_id"].n == 121)
                    {
                        awardCard = "300元京东卡";
                    }
                    else if (awardInfo["item_id"].n == 122)
                    {
                        awardCard = "200元京东卡";
                    }
                    else if (awardInfo["item_id"].n == 123)
                    {
                        awardCard = "100元京东卡";
                    }
                    else if (awardInfo["item_id"].n == 124)
                    {
                        awardCard = "50元京东卡";
                    }
                    else if (awardInfo["item_id"].n == 125)
                    {
                        awardCard = "30元京东卡";
                    }
                    bonusStr    += ("\n" + awardCard);
                    bonusLb.text = bonusStr;
                    collectFlagObj.SetActive(true);
                }
                if (awardInfo["rank"].n <= 20)
                {
                    EginProgressHUD.Instance.ShowPromptHUD("你获得第" + awardInfo["rank"].n + "名,赢得" + awardCard + "! 卡密已发送到手机,请查收");
                }
                toggleAwardBtn(false);
            }
            else
            {
                EginProgressHUD.Instance.ShowPromptHUD(System.Text.RegularExpressions.Regex.Unescape(json["body"].str));
            }
        }
        else
        {
            EginProgressHUD.Instance.ShowPromptHUD(w2.error);
        }
    }
コード例 #28
0
    private IEnumerator requestRankInfo(bool isPopup = false)
    {
        Dictionary <string, string> headers = new Dictionary <string, string>();

        headers.Add("Cookie", session);

        WWWForm form2 = new WWWForm();

        form2.AddField("Cookie", session);
        long   ms2    = EginTools.nowMinis();
        long   mms2   = ms2 + EginTools.localBeiJingTime;
        string ccode2 = EginTools.encrypTime(mms2.ToString());

        form2.AddField("client_code", ccode2);
        form2.AddField("roomid", "1095");

        WWW w2 = new WWW(serverURL + "unity/htddz/user_rank_info/", form2.data, headers);

        yield return(w2);

        if (w2.error == null)
        {
            Debug.LogError(w2.text);
            JSONObject json1 = new JSONObject(w2.text);
            JSONObject json  = json1["body"];

            /*{
             * "result": "ok",
             * "body": {
             *      "rank": 1, # 排名
             *      "uid": 1, # 玩家uid
             *      "name": "test", # 玩家名字
             *      "ave_score": 8000, # 场积分
             *      "update_time": "2016-12-13 14:10:00", # 获得时间
             *      "round": 25, # 当前第几局
             *      "win_round": 25, # 胜几场
             *      "fail_round": 0, # 负几场
             *      "add_coin": 0, # 获得金币
             *      "item_id": 121, # 获得京东卡item_id
             *      "is_reward": 1, # 是否领奖 0否 1是
             * }*/
//			Debug.LogError( System.Text.RegularExpressions.Regex.Unescape(json["body"].str) );
            //JDCard id : 121 to 125  = rank 1 to 5
            if (json1["result"].str == "ok")
            {
                awardInfo = json1["body"];
                //{"result":"ok","body":{"update_time": "2016-12-21 15:00:49", "uid": 299023, "ave_score": 345, "rank": 1,
                //"fail_round": 2, "item_id": 121, "name": "sygame13", "is_reward": 0, "win_round": 2, "add_coin": 0, "round": 4}}
                if (json["is_reward"].n == 1)
                {
                    if (json["add_coin"].n > 0)
                    {
                        bonusLb.text = json["add_coin"].n + "元宝";
                    }
                    if (json["item_id"].n >= 121 && json["item_id"].n <= 125)
                    {
                        string bonusStr = bonusLb.text;
                        if (json["item_id"].n == 121)
                        {
                            bonusStr += "\n 300元京东卡";
                        }
                        else if (json["item_id"].n == 122)
                        {
                            bonusStr += "\n 200元京东卡";
                        }
                        else if (json["item_id"].n == 123)
                        {
                            bonusStr += "\n 100元京东卡";
                        }
                        else if (json["item_id"].n == 124)
                        {
                            bonusStr += "\n 50元京东卡";
                        }
                        else if (json["item_id"].n == 125)
                        {
                            bonusStr += "\n 30元京东卡";
                        }
                        bonusLb.text = bonusStr;
                        collectFlagObj.SetActive(true);
                    }
                    toggleAwardBtn(false);
                }
                else
                {
                    if (json["rank"].n <= 50)
                    {
                        toggleAwardBtn(true);
                    }
                    else
                    {
                        toggleAwardBtn(false);
                    }
                    if (isPopup)
                    {
                        showAward();
                    }
                }
            }
            else
            {
                toggleAwardBtn(false);
                Debug.LogError(System.Text.RegularExpressions.Regex.Unescape(json1["body"].str));
//				EginProgressHUD.Instance.ShowPromptHUD(System.Text.RegularExpressions.Regex.Unescape(json["body"].str));
            }
        }
        else
        {
            EginProgressHUD.Instance.ShowPromptHUD(w2.error);
        }
    }
コード例 #29
0
    IEnumerator ProcessEnd(JSONObject messageObj)
    {
        //去掉下注额
        foreach (GameObject player in _playingPlayerList)
        {
            if (player != userPlayerObj)
            {
                player.GetComponent <TBTWPlayerCtrl>().SetShow(false);
            }
        }

        if (msgWaitNext.activeSelf)
        {
            msgWaitNext.SetActive(false);
        }

        _playingPlayerList.Clear();


        JSONObject        body  = messageObj["body"];
        List <JSONObject> infos = body["infos"].list;

        //玩家扑克牌信息
        foreach (JSONObject info in infos)
        {
            List <JSONObject> jos   = info.list;
            string            uid   = jos[0].ToString();
            TBTWPlayerCtrl    ctrl  = GameObject.Find(_nnPlayerName + uid).GetComponent <TBTWPlayerCtrl>();
            List <JSONObject> cards = jos[1].list;
            //牌型
            int cardType = (int)jos[2].n;
            //得分
            int score = (int)jos[3].n;

            //明牌
            if (uid != EginUser.Instance.uid)
            {
                ctrl.SetCardTypeOther(cards, cardType);
            }
            else
            {
                if (btnShow.activeSelf)
                {
                    btnShow.SetActive(false);
                    ctrl.SetCardTypeUser(cards, cardType);
                }
                if (cardType == 10)
                {
                    EginTools.PlayEffect(soundNiuniu);
                }
                if (score > 0)
                {
                    EginTools.PlayEffect(soundWin);
                }
                else if (score < 0)
                {
                    EginTools.PlayEffect(soundFail);
                }
            }
            //更新bagmoney
            //			ctrl.UpdateIntoMoney(score);
            ctrl.SetScore(score);
        }


        //去掉所有等待中玩家的”等待中“, 显示开始换桌按钮
        foreach (GameObject player in _waitPlayerList)
        {
            if (player != userPlayerObj)
            {
                player.GetComponent <TBTWPlayerCtrl>().SetWait(false);
            }
        }
        _waitPlayerList.Clear();


        if (_late)
        {
            EginTools.PlayEffect(soundEnd);
            _late = false;
        }
        else
        {
            btnBegin.transform.localPosition = new Vector3(350, 0, 0);
        }

        if (SettingInfo.Instance.autoNext == true || SettingInfo.Instance.deposit == true)
        {
            yield return(new WaitForSeconds(2));

            UserReady();
        }
        else
        {
            btnBegin.SetActive(true);
        }

        int t = (int)body["t"].n;

        TBTWCount.Instance.UpdateHUD(t);

        _isPlaying = false;
    }
コード例 #30
0
    /// <summary>
    /// Processes the deal.(带发牌动画)
    /// </summary>
    /// <returns>The deal.</returns>
    /// <param name="messageObj">Message object.</param>
    IEnumerator ProcessDeal(JSONObject messageObj)
    {
        //游戏已经开始
        _isPlaying = true;
        foreach (GameObject player in _readyPlayerList)
        {
            if (!_playingPlayerList.Contains(player))
            {
                Debug.Log(player.name);
                _playingPlayerList.Add(player);
            }
        }
        _readyPlayerList.Clear();

        StartCoroutine(TimeAnimation());
        //清除未被清除的牌
        foreach (GameObject player in _playingPlayerList)
        {
            if (player != null && player != userPlayerObj)
            {
                TBTWPlayerCtrl ctrl = player.GetComponent <TBTWPlayerCtrl>();
                //StartCoroutine(ctrl.SetDeal(false, null));
                ctrl.SetDeal(false, null);
                ctrl.SetCardTypeOther(null, 0);
                ctrl.SetScore(-1);
            }
        }
        //去掉“准备”
        foreach (GameObject player in _playingPlayerList)
        {
            if (player != null)
            {
                player.GetComponent <TBTWPlayerCtrl>().SetReady(false);
            }
        }
        //去掉筹码显示
        foreach (GameObject player in _playingPlayerList)
        {
            if (player != null)
            {
                player.GetComponent <TBTWPlayerCtrl>().SetBet(0);
            }
        }
        EginTools.PlayEffect(soundXiazhu);

        JSONObject        body  = messageObj["body"];
        List <JSONObject> cards = body["cards"].list;
        int chip = (int)body["chip"].n;
        int t    = (int)body["t"].n;

        TBTWCount.Instance.UpdateHUD(t);
        //下注
        foreach (GameObject player in _playingPlayerList)
        {
            if (player != null)
            {
                TBTWPlayerCtrl ctrl = player.GetComponent <TBTWPlayerCtrl>();

                ctrl.SetBet(chip);
                ctrl.SetUserChip(chip);
            }
        }

        //发牌
        foreach (GameObject player in _playingPlayerList)
        {
            if (player != null)
            {
                TBTWPlayerCtrl ctrl = player.GetComponent <TBTWPlayerCtrl>();
                ctrl.SetBet(chip);
                ctrl.SetUserChip(chip);
                if (player == userPlayerObj)
                {
                    //StartCoroutine(ctrl.SetDeal(true, cards));
                    ctrl.SetDeal(true, cards);
                }
                else
                {
                    //StartCoroutine(ctrl.SetDeal(true, null));
                    ctrl.SetDeal(true, null);
                }
            }
        }

        yield return(new WaitForSeconds(2.5f));

        //非late进入时才显示摊牌按钮
        if (!_late)
        {
            if (SettingInfo.Instance.deposit == true)
            {
                yield return(new WaitForSeconds((_playingPlayerList.Count * 0.5f)));

                UserShow();
            }
        }
    }