예제 #1
0
    /// <summary>カードを選択する</summary>
    IEnumerator CardChoice()
    {
        int        ObjIndex = 0;
        bool       EndFlag = false, Select = true;
        List <int> ChangeCardIndex = new List <int>();

        if (gamePhase == GamePhase.Change)
        {
            ChangeButton.SetActive(true); SelectFrame.SetActive(true);
        }
        if (gamePhase == GamePhase.Select)
        {
            ShowButton.SetActive(true); SelectFrame.SetActive(true);
        }
        Vector3 FrameScale = SelectFrame.transform.localScale;

        while (!EndFlag)
        {
            if (Select)
            {
                SelectFrame.transform.position   = player.PlayerZone[ObjIndex].transform.position;
                SelectFrame.transform.localScale = FrameScale;
            }
            else
            {
                if (gamePhase == GamePhase.Change)
                {
                    SelectFrame.transform.position   = ChangeButton.transform.position;
                    SelectFrame.transform.localScale = new Vector3(50, 30, 1);
                }
                if (gamePhase == GamePhase.Select)
                {
                    SelectFrame.transform.position   = ShowButton.transform.position;
                    SelectFrame.transform.localScale = new Vector3(50, 30, 1);
                }
            }

            if (Input.GetKeyDown(KeyCode.LeftArrow) ||
                GetAxlsInput.X_Minus)
            {
                ObjIndex--; if (ObjIndex < 0)
                {
                    ObjIndex = 6;
                }
            }
            if (Input.GetKeyDown(KeyCode.RightArrow) ||
                GetAxlsInput.X_Plus)
            {
                ObjIndex++; if (ObjIndex > 6)
                {
                    ObjIndex = 0;
                }
            }
            if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.DownArrow) ||
                GetAxlsInput.Y_Minus || GetAxlsInput.Y_Plus)
            {
                Select = !Select;
            }
            if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.JoystickButton1))
            {
                if (Select)
                {
                    int Index = ChangeCardIndex.IndexOf(ObjIndex);
                    if (Index == -1)
                    {
                        if (gamePhase == GamePhase.Select)
                        {
                            if (ChangeCardIndex.Count < 5)
                            {
                                CardUp(ChangeCardIndex, ObjIndex);
                            }
                        }
                        else
                        {
                            CardUp(ChangeCardIndex, ObjIndex);
                        }
                    }
                    else
                    {
                        SE[0].PlayOneShot(SE[0].clip);
                        ChangeCardIndex.Remove(ObjIndex);
                        player.PlayerCard[ObjIndex].transform.DOMove(player.PlayerZone[ObjIndex].transform.position, 0.5f);
                    }
                }
                else
                {
                    switch (gamePhase)
                    {
                    case GamePhase.Change:
                        EndFlag = true;
                        break;

                    case GamePhase.Select:
                        if (ChangeCardIndex.Count == 5)
                        {
                            EndFlag = true; TextFalse();
                        }
                        else
                        if (coroutine == null)
                        {
                            coroutine = StartCoroutine(TextPou("5枚選択してください"));
                        }
                        break;
                    }
                }
            }
            yield return(null);
        }
        SelectFrame.transform.localScale = FrameScale;
        if (gamePhase == GamePhase.Change)
        {
            ChangeButton.SetActive(false); SelectFrame.SetActive(false);
        }
        if (gamePhase == GamePhase.Select)
        {
            ShowButton.SetActive(false); SelectFrame.SetActive(false);
        }
        ChangeCard(ChangeCardIndex);
    }