public void CloseGanZi() { if (state != DiceMachineState.GAIZI_OPEND && state != DiceMachineState.THROWED_DICE) { return; } state = DiceMachineState.GAIZI_CLOSING; gaiziMat.DOColor(closeGaiZiColor, 1f); mjGame.StartCoroutine(ActionOpenOrCloseGaiZi(1, 1f)); }
public void OpenGanZi() { if (state != DiceMachineState.START_RUN && state != DiceMachineState.GAIZI_CLOSED) { return; } state = DiceMachineState.GAIZI_OPENING; diceTransform.gameObject.SetActive(true); // qiDongQiDictBoxTransform.gameObject.SetActive(true); gaiziMat.DOColor(openGaiZiColor, 1f); mjGame.StartCoroutine(ActionOpenOrCloseGaiZi(0, 1f)); }
IEnumerator ActionEndRun(float waitTime) { yield return(new WaitForSeconds(waitTime)); state = DiceMachineState.END_RUN; diceTransform.gameObject.SetActive(false); OffFengWei(curtOnFengWei); cdsTimer.SetCurtTime(0); timerNumSpriteRenderer[0].sprite = blueNums[0]; timerNumSpriteRenderer[1].sprite = blueNums[0]; timerNumTransform[0].gameObject.SetActive(false); timerNumTransform[1].gameObject.SetActive(false); }
IEnumerator ActionOpenOrCloseGaiZi(int type, float waitTime) { yield return(new WaitForSeconds(waitTime)); if (type == 0) { state = DiceMachineState.GAIZI_OPEND; } else { state = DiceMachineState.GAIZI_CLOSED; diceTransform.gameObject.SetActive(false); // qiDongQiDictBoxTransform.gameObject.SetActive(false); } }
/// <summary> /// 掷骰子动作 /// </summary> /// <returns></returns> IEnumerator ActionThrowDice(int dice1Point, int dice2Point) { AudioClip clip = mjMachine.GetEffectAudio((int)AudioIdx.AUDIO_EFFECT_DICE); AudioSource.PlayClipAtPoint(clip, qiDongQiDictBoxTransform.position); float waitTime = diceAnim.GetClip("ReadyZhuanDice").length / diceAnim["ReadyZhuanDice"].speed; diceAnim.Play("ReadyZhuanDice"); yield return(new WaitForSeconds(waitTime)); diceAnim["LoopZhuanDice"].speed = 4f; waitTime = diceAnim.GetClip("LoopZhuanDice").length / diceAnim["LoopZhuanDice"].speed; diceAnim.Play("LoopZhuanDice"); yield return(new WaitForSeconds(waitTime * 4)); diceAnim["LoopZhuanDice"].speed = 1.5f; waitTime = diceAnim.GetClip("LoopZhuanDice").length / diceAnim["LoopZhuanDice"].speed; diceAnim.Play("LoopZhuanDice"); yield return(new WaitForSeconds(waitTime * 2)); diceAnim["SlowSpeedZhuanDice"].speed = 1f; waitTime = diceAnim.GetClip("SlowSpeedZhuanDice").length / diceAnim["SlowSpeedZhuanDice"].speed; diceAnim.Play("SlowSpeedZhuanDice"); yield return(new WaitForSeconds(waitTime)); diceAnim["LastAdjustDice"].speed = 0.6f; diceAnim.Play("LastAdjustDice"); waitTime = diceAnim.GetClip("LastAdjustDice").length / diceAnim["LastAdjustDice"].speed; float x1 = Random.Range(-0.006f, 0.006f); float y1 = Random.Range(-0.006f, 0.006f); float x2 = Random.Range(-0.006f, 0.006f); float y2 = Random.Range(-0.006f, 0.006f); dice1Transform.DOLocalMove(new Vector3(x1, y1, 0), waitTime).SetRelative(); dice1Transform.DOLocalRotate(dicePointByEulerAngles[dice1Point], waitTime); dice2Transform.DOLocalMove(new Vector3(x2, y2, 0), waitTime).SetRelative(); dice2Transform.DOLocalRotate(dicePointByEulerAngles[dice2Point], waitTime); yield return(new WaitForSeconds(1f)); state = DiceMachineState.THROWED_DICE; }
/// <summary> /// 掷骰子 /// </summary> public void ThrowDice(int dice1Point, int dice2Point) { if (state != DiceMachineState.GAIZI_OPEND) { return; } state = DiceMachineState.THROWING_DICE; dice1Point = Mathf.Min(dice1Point, 6); dice1Point = Mathf.Max(dice1Point, 1); dice2Point = Mathf.Min(dice2Point, 6); dice2Point = Mathf.Max(dice2Point, 1); mjGame.StartCoroutine(ActionThrowDice(dice1Point, dice2Point)); }
public void EndRun(bool isDirect = false) { if (state == DiceMachineState.END_RUNNING || state == DiceMachineState.END_RUN) { return; } float waitTime = 1f; if (isDirect) { waitTime = 0.01f; } state = DiceMachineState.END_RUNNING; gaiziMat.DOColor(closeGaiZiColor, waitTime); mjGame.StartCoroutine(ActionEndRun(waitTime)); }
public void StartRun(int dice1Point = -1, int dice2Point = -1) { if (state != DiceMachineState.END_RUN) { return; } if (dice1Point <= -1) { dice1Point = Random.Range(1, 7); } if (dice2Point <= -1) { dice2Point = Random.Range(1, 7); } dicePoint[0] = dice1Point; dicePoint[1] = dice2Point; state = DiceMachineState.START_RUN; }
public void Update() { switch (state) { case DiceMachineState.START_RUN: OpenGanZi(); break; case DiceMachineState.GAIZI_OPEND: ThrowDice(dicePoint[0], dicePoint[1]); break; case DiceMachineState.THROWED_DICE: CloseGanZi(); break; case DiceMachineState.GAIZI_CLOSED: StartTime(); state = DiceMachineState.TIMING; timerNumTransform[0].gameObject.SetActive(true); timerNumTransform[1].gameObject.SetActive(true); break; case DiceMachineState.TIMING: { int tm = cdsTimer.Timing(); int[] nums = cdsTimer.GetGetCurtTimeNums(); timerNumSpriteRenderer[0].sprite = blueNums[nums[0]]; timerNumSpriteRenderer[1].sprite = blueNums[nums[1]]; if (tm == 0) { state = DiceMachineState.TIMER_END; } } break; } }