Exemple #1
0
    private IEnumerator MovesHandlerQuene()
    {
        yield return(new WaitWhile(() => switchLst));

        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, 0, 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);
                        anim.transform.position = new Vector3(currentPosRun.x, 0, currentPosRun.z);
                    }
                    else if (movename == "Right")
                    {
                        anim.transform.rotation = currentPosLR * Quaternion.Euler(0, 90, 0);
                        anim.transform.position = new Vector3(currentPosRun.x, 0, currentPosRun.z);
                    }
                    else
                    {
                        anim.transform.position = Vector3.MoveTowards(currentPosRun, positionToRun, 3);
                    }
                }
                else if (movename == "Scratch")
                {
                    yield return(new WaitForSeconds(0.1f));
                }
                if (switchLst)
                {
                    isDel = true;
                }
                else
                {
                    yield return(new WaitWhile(() => button.new_speed));

                    button.DestroyPrefab();
                    yield return(new WaitWhile(() => button.fade));
                }
                if (winner)
                {
                    sounding(4);
                    loader.OnMapUpdate(null, PointDes(targets));
                    yield return(new WaitForSeconds(0.5f));

                    i = 0;
                    try{
                        loader.MapNext(currentMap);
                        button.ReturnAll();
                        func.gameObject.SetActive(true);
                        button.ButtonLoad(false);
                        func.FuncLoad(false);
                        anim.Play("LookArrow", 0);
                    }
                    catch (FileNotFoundException e) {
#if UNITY_EDITOR
                        Debug.Log(e);
#endif
                    }
                    Level();
                    yield break;
                }
                else if (looser)
                {
                    mus_play = false;
                    anim.Play("Fall");
                    yield return(new WaitUntil(() => anim.GetCurrentAnimatorStateInfo(0).IsName("Fall")));

                    yield return(new WaitWhile(() => anim.GetCurrentAnimatorStateInfo(0).IsName("Fall")));

                    Level(true);
                    button.ReturnAll(true);
                    func.gameObject.SetActive(true);
                    yield break;
                }
                else if (isDestroy)
                {
                    sounding(4);
                    loader.OnMapUpdate(null, PointDes(targets));
                    isDestroy = false;
                }
                if (mus_play)
                {
                    sounding(quene[movenum - 1, 1]);
                }
            }
            if (switchLst)
            {
                switchLst = false;
                StartCoroutine(MovesHandler());
                yield break;
            }
        }
        yield return(new WaitForSeconds(0.7f));

        Level(true);
        button.ReturnAll(true);
        func.gameObject.SetActive(true);
        yield break;
    }
Exemple #2
0
    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;
    }