public void StopGame() { Time.timeScale = 1; isPause = false; StopAllCoroutines(); button.ReturnAll(true); func.gameObject.SetActive(true); anim.Play("Stay", 0); Level(true); trans = true; }
private IEnumerator MovesHandlerQuene() { yield return(new WaitWhile(() => switchLst)); //button.DestroyPrefab(true); for (int a = 0; a < quene.GetLength(0); a++) { button.CreatePrefab(quene[a, 1], quene[a, 0]); } for (i = 0; i <= quene.GetLength(0); i++) { if (isActive) { movename = "Other"; Vector3 currentPosRun = anim.transform.position; if (quene[movenum, 1] == card[startPos.x, startPos.y] || quene[movenum, 1] == 0 || quene[movenum, 0] == 4) { movename = IntToMove(quene[movenum, 0], false); if (movename == "Left" || movename == "Right") { currentPosLR = Quaternion.Euler(anim.transform.rotation.eulerAngles); } else { var newpos = LeftRight(currentDirection); positionToRun = new Vector3(currentPosRun.x + newpos.x, currentPosRun.y, currentPosRun.z + newpos.y); } } CheckMoveType(ref quene); movenum += 1; if (movename != "Other" && movename != "Scratch") { yield return(new WaitUntil(() => anim.GetCurrentAnimatorStateInfo(0).IsName(movename))); yield return(new WaitWhile(() => anim.GetCurrentAnimatorStateInfo(0).IsName(movename))); if (movename == "Left") { anim.transform.rotation = currentPosLR * Quaternion.Euler(0, -90, 0); } else if (movename == "Right") { anim.transform.rotation = currentPosLR * Quaternion.Euler(0, 90, 0); } else { anim.transform.position = Vector3.MoveTowards(currentPosRun, positionToRun, 2); } } if (movename == "Scratch") { yield return(new WaitForSeconds(0.5f)); } if (movename == "Other") { yield return(new WaitForSeconds(0.5f)); } if (switchLst) { isDel = true; } else { button.DestroyPrefab(false, isDel); } } else { if (winner) { yield return(new WaitForSeconds(0.5f)); i = 0; try{ loader.MapNext(currentMap); button.ReturnAll(); func.gameObject.SetActive(true); button.ButtonLoad(false); func.FuncLoad(false); input.ReStart(); } catch (FileNotFoundException e) { Debug.Log(e); } Level(); yield break; } else if (looser) { anim.Play("Fall"); yield return(new WaitUntil(() => anim.GetCurrentAnimatorStateInfo(0).IsName("Fall"))); yield return(new WaitWhile(() => anim.GetCurrentAnimatorStateInfo(0).IsName("Fall"))); Level(); button.ReturnAll(); func.gameObject.SetActive(true); yield break; } } if (switchLst) { yield return(new WaitForSeconds(0.5f)); switchLst = false; yield break; } } Debug.Log("You Lose!!!"); yield return(new WaitForSeconds(0.7f)); Level(); button.ReturnAll(); func.gameObject.SetActive(true); yield break; }