示例#1
0
    public void ButtonLoad(bool isFirst)
    {
        if (!isFirst)
        {
            for (int i = 1; i < 16; i++)
            {
                button_list[i].gameObject.SetActive(false);
            }
            UpDatetion();
        }

        Map loadedMap = loader.GetMap();

        colors = loadedMap.colors;
        if (colors != null)
        {
            foreach (int i in colors)
            {
                AddAction(ref moves, i);
            }
        }
        movesf1 = MapLoader.OneDToTwoDArray(loadedMap.movesf1, 2);
        if (Savegame.sv.moves1 == null)
        {
            Savegame.sv.moves1 = new int[movesf1.GetLength(0), movesf1.GetLength(1)];
        }
        ChooseAction(ref movesf1);
        func_num.Add(movesf1.GetLength(0));
        if (loadedMap.movesf2 != null)
        {
            movesf2 = MapLoader.OneDToTwoDArray(loadedMap.movesf2, 2);
            if (Savegame.sv.moves2 == null)
            {
                Savegame.sv.moves2 = new int[movesf2.GetLength(0), movesf2.GetLength(1)];
            }
            ChooseAction(ref movesf2);
            func_num.Add(movesf2.GetLength(0));
        }
        if (loadedMap.movesf3 != null)
        {
            movesf3 = MapLoader.OneDToTwoDArray(loadedMap.movesf3, 2);
            if (Savegame.sv.moves3 == null)
            {
                Savegame.sv.moves3 = new int[movesf3.GetLength(0), movesf3.GetLength(1)];
            }
            ChooseAction(ref movesf3);
            func_num.Add(movesf3.GetLength(0));
        }
        if (loadedMap.movesf4 != null)
        {
            movesf4 = MapLoader.OneDToTwoDArray(loadedMap.movesf4, 2);
            if (Savegame.sv.moves4 == null)
            {
                Savegame.sv.moves4 = new int[movesf4.GetLength(0), movesf4.GetLength(1)];
            }
            ChooseAction(ref movesf4);
            func_num.Add(movesf4.GetLength(0));
        }
        if (loadedMap.movesf5 != null)
        {
            movesf5 = MapLoader.OneDToTwoDArray(loadedMap.movesf5, 2);
            if (Savegame.sv.moves5 == null)
            {
                Savegame.sv.moves5 = new int[movesf5.GetLength(0), movesf5.GetLength(1)];
            }
            ChooseAction(ref movesf5);
            func_num.Add(movesf5.GetLength(0));
        }
        foreach (int i in moves)
        {
            button_list[i].gameObject.SetActive(true);
        }
        Btnplay.ReStart();
        if (Savegame.sv.movesf1 != null && Savegame.sv.movesf1.Length > 0)
        {
            Savegame.sv.moves1 = MapLoader.OneDToTwoDArray(Savegame.sv.movesf1, 2);
            for (int i = 0; i < Savegame.sv.moves1.GetLength(0); i++)
            {
                InputField.button_list[i].image.color = ColorIndeed(Savegame.sv.moves1[i, 1]);
                Btnplay.func[0].input_arr[i].color    = Savegame.sv.moves1[i, 1];
                Btnplay.func[0].input_arr[i].direct   = Savegame.sv.moves1[i, 0];
                if (Savegame.sv.moves1[i, 0] != 0)
                {
                    action_chose(Savegame.sv.moves1[i, 0] - 1, i);
                }
            }
        }
        if (Savegame.sv.movesf2 != null && Savegame.sv.movesf2.Length > 0)
        {
            Savegame.sv.moves2 = MapLoader.OneDToTwoDArray(Savegame.sv.movesf2, 2);
            for (int i = 0; i < Savegame.sv.moves2.GetLength(0); i++)
            {
                Btnplay.func[1].input_arr[i].color  = Savegame.sv.moves2[i, 1];
                Btnplay.func[1].input_arr[i].direct = Savegame.sv.moves2[i, 0];
            }
        }
        if (Savegame.sv.movesf3 != null && Savegame.sv.movesf3.Length > 0)
        {
            Savegame.sv.moves3 = MapLoader.OneDToTwoDArray(Savegame.sv.movesf3, 2);
            for (int i = 0; i < Savegame.sv.moves3.GetLength(0); i++)
            {
                Btnplay.func[2].input_arr[i].color  = Savegame.sv.moves3[i, 1];
                Btnplay.func[2].input_arr[i].direct = Savegame.sv.moves3[i, 0];
            }
        }
        if (Savegame.sv.movesf4 != null && Savegame.sv.movesf4.Length > 0)
        {
            Savegame.sv.moves4 = MapLoader.OneDToTwoDArray(Savegame.sv.movesf4, 2);
            for (int i = 0; i < Savegame.sv.moves4.GetLength(0); i++)
            {
                Btnplay.func[3].input_arr[i].color  = Savegame.sv.moves4[i, 1];
                Btnplay.func[3].input_arr[i].direct = Savegame.sv.moves4[i, 0];
            }
        }
        if (Savegame.sv.movesf5 != null && Savegame.sv.movesf5.Length > 0)
        {
            Savegame.sv.moves5 = MapLoader.OneDToTwoDArray(Savegame.sv.movesf5, 2);
            for (int i = 0; i < Savegame.sv.moves5.GetLength(0); i++)
            {
                Btnplay.func[4].input_arr[i].color  = Savegame.sv.moves5[i, 1];
                Btnplay.func[4].input_arr[i].direct = Savegame.sv.moves5[i, 0];
            }
        }
    }
示例#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;
    }