void OnWin() { if (IsWin) { if (DGameData.Instance.WinMoney > 0) { //1分1分的从赢的分数加到用户分数 DGameData.Instance.WinMoney -= 10; DGameData.Instance.Fraction += 10; wining.SetActive(true); } else { wining.SetActive(false); DGameData.Instance.IsBiBei = false; DGameData.Instance.str_result = new string[6]; DGameData.Instance.IsWinEffect = false; if (DGameData.Instance.BiType == 2) { DGameData.Instance.BiType = 0; } else { Invoke("OnCardStart", 0.5f); } for (int i = 0; i < 10; i++) { OddListObj[i].SetActive(true); } winEffectIng.SetActive(false); IsWin = false; IsBiBei = false; DGameData.Instance.IsWin = false; WinButton.SetActive(false); StartButton.SetActive(true); FillButton.SetActive(true); BanBiButton.SetActive(false); BiButton.SetActive(false); ShuangBiButton.SetActive(false); SmallButton.SetActive(true); BigButton.SetActive(true); DGameData.Instance.HoldData = new string[5]; } } }
IEnumerator SendBiBei(string url) { UnityWebRequest www = UnityWebRequest.Get(url); Debug.Log(url); yield return(www.Send()); try { if (www.error == null && www.isDone) { if (www.responseCode == 200) { JsonData jd = JsonMapper.ToObject(www.downloadHandler.text); IsBiBei = true; DGameData.Instance.BiType = 2; Debug.Log("执行3"); FillButton.SetActive(false); BiButton.SetActive(false); BanBiButton.SetActive(false); ShuangBiButton.SetActive(false); SmallButton.SetActive(true); BigButton.SetActive(true); StartButton.SetActive(false); WinButton.SetActive(true); DGameData.Instance.IsColumnBoard = true; for (int i = 0; i < 6; i++) { DGameData.Instance.str_result[i] = jd["result"][i].ToString(); Debug.Log("右边的牌为第" + (i + 1) + "张:" + DGameData.Instance.str_result[i]); } } } } catch { Debug.Log("Json解析错误"); DGameData.Instance.IsNetworkError = true; } }
void OnUI() { switch (DGameData.Instance.FlopNum) { case 1: PromptText.GetComponent <Text>().text = "<color=#FFFF00>押 注 </color>或 <color=#458b00>开 始</color>"; break; case 2: PromptText.GetComponent <Text>().text = "<color=#458b00>保 留 </color>或 <color=#458b00>开 牌</color>"; break; case 3: if (DGameData.Instance.WinMoney != 0) { PromptText.GetComponent <Text>().text = "<color=#458b00>得 分 </color>或 <color=#458b00>比 倍</color>"; } else { PromptText.GetComponent <Text>().text = "<color=#458b00>保 留 </color>或 <color=#458b00>开 牌</color>"; } break; } if (isQuitPanel) { QuitPanel.SetActive(true); } else { QuitPanel.SetActive(false); } if (isStopPanel) { StopPanel.SetActive(true); } else { StopPanel.SetActive(false); } if (isUpDownPanel) { UpDownPanel.SetActive(true); } else { UpDownPanel.SetActive(false); } if (isRecordPanel) { RecordPanel.SetActive(true); } else { RecordPanel.SetActive(false); } if (isRankingPanel) { RankingPanel.SetActive(true); } else { RankingPanel.SetActive(false); } for (int i = 0; i < 10; i++) { if (DGameData.Instance.ChargeNum != 0) { OddList[i].text = (DGameData.Instance.OddList[i] * DGameData.Instance.ChargeNum).ToString(); } else { OddList[i].text = DGameData.Instance.OddList[i].ToString(); } } AllScore.text = LoginInfo.Instance().mylogindata.ALLScroce; Fraction.text = DGameData.Instance.Fraction.ToString(); Fraction2.text = DGameData.Instance.Fraction.ToString(); WinMoney.text = DGameData.Instance.WinMoney.ToString(); BET.text = DGameData.Instance.ChargeNum.ToString(); if (DGameData.Instance.IsWin) { if (DGameData.Instance.BiType == 2) { FillButton.SetActive(true); } else { SmallButton.SetActive(false); BigButton.SetActive(false); FillButton.SetActive(false); BiButton.SetActive(true); BanBiButton.SetActive(true); ShuangBiButton.SetActive(true); } StartButton.SetActive(false); WinButton.SetActive(true); } else { WinButton.SetActive(false); StartButton.SetActive(true); FillButton.SetActive(true); SmallButton.SetActive(true); BigButton.SetActive(true); BiButton.SetActive(false); BanBiButton.SetActive(false); ShuangBiButton.SetActive(false); } }
private void Update() { OnUI(); WinEffect(); OnWin(); if (DGameData.Instance.IsNetworkError) { DGameData.Instance.IsAutomatic = false; NetworkPrompt.SetActive(true); } if (DGameData.Instance.IsFlopCard) { OnFlop(ref CardNum); } if (isCardStart) { isCardStart = false; for (int i = 0; i < 5; i++) { boards[i].sprite = reverseBoard[0]; HOLD[i].SetActive(false); } DGameData.Instance.FlopNum = 1; if (DGameData.Instance.IsAutomatic == false) { DGameData.Instance.BiType = 0; } DGameData.Instance.IsStart = false; } if (DGameData.Instance.IsFlopCard == false) { for (int i = 0; i < 5; i++) { if (DGameData.Instance.HoldData[i] == (i + 1).ToString()) { HOLD[i].SetActive(true); } else { HOLD[i].SetActive(false); } } } switch (DGameData.Instance.BiType) { case 0: for (int i = 0; i < 10; i++) { OddListObj[i].SetActive(true); } DGameData.Instance.HoldData = new string[5]; DGameData.Instance.IsWinEffect = false; for (int i = 0; i < 5; i++) { boards[i].GetComponent <Image>().sprite = reverseBoard[0]; } DGameData.Instance.ChargeNum = 0; DGameData.Instance.FlopNum = 1; Board_Game.SetActive(true); Board_Contrast.SetActive(false); SmallButton.GetComponent <Image>().sprite = SmallButtonSprite[2]; BigButton.GetComponent <Image>().sprite = BigButtonSprite[2]; FillButton.GetComponent <Image>().sprite = FillButtonSprite[0]; break; case 1: //正常模式 Board_Game.SetActive(true); Board_Contrast.SetActive(false); SmallButton.GetComponent <Image>().sprite = SmallButtonSprite[2]; BigButton.GetComponent <Image>().sprite = BigButtonSprite[2]; FillButton.GetComponent <Image>().sprite = FillButtonSprite[0]; break; case 2: //比倍模式 if (DGameData.Instance.IsBiBei) { SmallButton.SetActive(false); BigButton.SetActive(false); FillButton.SetActive(false); BiButton.SetActive(true); BanBiButton.SetActive(true); ShuangBiButton.SetActive(true); } else { Board_Contrast.SetActive(true); Board_Game.SetActive(false); SmallButton.GetComponent <Image>().sprite = SmallButtonSprite[0]; BigButton.GetComponent <Image>().sprite = BigButtonSprite[0]; FillButton.GetComponent <Image>().sprite = FillButtonSprite[2]; } break; } if (DGameData.Instance.IsAutomatic) { AutomaticButton.GetComponent <Image>().sprite = AutomaticSprite[1]; if (StartButton.activeSelf) { if (DGameData.Instance.IsFlopCard == false && IsWin == false && DGameData.Instance.IsStart == false) { Button_Start(); } } if (WinButton.activeSelf) { if (DGameData.Instance.IsFlopCard == false && IsWin == false) { OnWinButton(); } } } else { AutomaticButton.GetComponent <Image>().sprite = AutomaticSprite[0]; } if (DGameData.Instance.IsColumnBoard) { BiBeiPrompt.SetActive(false); DGameData.Instance.IsColumnBoard = false; int a = 0; for (int i = 0; i < columnBoard.Length; i++) { a = ColumnBoard_Num(i); columnBoard[i].sprite = boardGroup[a]; } } if (DGameData.Instance.IsFlopColumnBoard) { BiFlopTime += Time.deltaTime; if (BiFlopTime > 0.06) { BiFlopTime = 0; guessingBoard.sprite = reverseBoard[BiFlopNum]; BiFlopNum++; } if (BiFlopNum >= reverseBoard.Length) { Audio.clip = Clip[1]; Audio.Play(); Debug.Log("得出比倍结果"); BiFlopNum = 0; DGameData.Instance.IsFlopColumnBoard = false; guessingBoard.sprite = boardGroup[GuessingBoard_Num()]; BiBeiPrompt.SetActive(true); if (DGameData.Instance.WinMoney == 0) { Audio.clip = Clip[3]; Audio.Play(); BiBeiPrompt.GetComponent <Image>().sprite = BiBeiSprite[1]; Invoke("OnStart", 1.5f); } else { Audio.clip = Clip[2]; Audio.Play(); BiBeiPrompt.GetComponent <Image>().sprite = BiBeiSprite[0]; } } } }