Esempio n. 1
0
    public void cardSetOriPos()
    {
        int cnt = destList.Count;

        for (int i = 0; i < cnt; i++)
        {
            moveDestList mdl = destList[i];
            GameObject.Find(mdl.name).transform.Find("UI").localPosition = Vector3.zero;
            destList.Remove(mdl);

            cnt = destList.Count;
        }
    }
Esempio n. 2
0
    public void OnPointEnter(GameObject card)
    {
        if (!turn)
        {
            optionBox.SetActive(false);
        }

        transform.GetComponent <AudioSource>().clip = Resources.Load <AudioClip>("SoundTrack/show");
        transform.GetComponent <AudioSource>().Play();

        if (!card.GetComponent <CardOP>().isTouchAble || (card.transform.Find("UI") == null))
        {
            return;
        }
        if (card.name[5] == '0')
        {
            return;
        }
        // 카드 클릭 금지 활성화
        card.GetComponent <CardOP>().isTouchAble = false;
        // 이외 큐에 있던 모든 카드 back활성화
        moveDestList mdl;

        for (int i = 0; i < destList.Count; i++)
        {
            mdl         = destList[i];
            mdl.back    = true;
            destList[i] = mdl;
        }

        // 전시 장소
        Vector3 ExhPos = Vector3.zero;

        if (card.name[0] == 'm')
        {
            ExhPos = new Vector3(Screen.width / 2, 300, 0);
        }
        else if (card.name[0] == 'c')
        {
            ExhPos = new Vector3(Screen.width / 2, Screen.height - 300, 0);
        }

        mdl = new moveDestList();

        mdl.name = card.name;
        mdl.dest = card.transform.Find("UI").TransformDirection(ExhPos);
        mdl.back = false;

        destList.Add(mdl);
    }
Esempio n. 3
0
    void FixedUpdate()
    {
        // 시작 되었을 때 또는 재정렬 시 카드를 세팅 합니다
        if (mstartSettingCard || cstartSettingCard)
        {
            cardBoardSort();
            for (int i = 0; i < mdrawCardNum - 1; i++)
            {
                GameObject mcard = GameObject.Find("mCard" + (i + 1));
                if (mcard && mcard.GetComponent <CardOP>().isDropCard)
                {
                    continue;
                }

                if (!mcard)
                {
                    mcard = GameObject.Find("mCard0");
                    mcard = Instantiate(mcard);

                    Destroy(mcard.transform.Find("UI").gameObject);

                    mcard.name = "mCard" + (i + 1);
                    mcard.transform.SetParent(GameObject.Find("MCardList").transform);
                    mcard.GetComponent <RectTransform>().localPosition = new Vector3(300, -130, 0);
                    mcard.GetComponent <RectTransform>().localScale    = new Vector3(cardSize, cardSize, 0);

                    if (GameObject.Find(exchange) != null)
                    {
                        // 교환 할 카드 UI가져오기
                        GameObject excard = GameObject.Find(exchange);

                        excard = excard.transform.Find("UI").gameObject;
                        // 부모를 바꾸고
                        excard.transform.SetParent(mcard.transform);

                        //excard.GetComponent<RectTransform>().localPosition = Vector3.zero;
                        moveDestList mdl = new moveDestList();

                        mdl.back = true;
                        mdl.dest = Vector3.zero;
                        mdl.name = mcard.name;

                        destList.Add(mdl);

                        Destroy(GameObject.Find(exchange));
                        exchange = null;
                    }
                }

                // 빈 공간이 있을 시
                if (mcard.transform.Find("UI") == null)
                {
                    Destroy(mcard);

                    break;
                }

                // 카드 정렬 부분
                Vector3 mori = mcard.GetComponent <RectTransform>().localPosition;
                mcard.GetComponent <RectTransform>().localPosition = Vector3.Lerp(mori, new Vector3(-180 + (i * ((maxDrawCardNum - mdrawCardNum) * 5.5f)), -30), 0.1f);

                // 카드 정렬
                if ((mcard.GetComponent <RectTransform>().localPosition - mori).magnitude < sortBoundMag)
                {
                    getCardPos = -180 + (i * (35 + (maxDrawCardNum - mdrawCardNum) * 5)) + ((maxDrawCardNum - mdrawCardNum) * 10);

                    if (i == mdrawCardNum - 1)
                    {
                        mstartSettingCard = false;
                    }
                }
            }

            for (int i = 0; i < cdrawCardNum - 1; i++)
            {
                GameObject ccard = GameObject.Find("cCard" + (i + 1));

                if (ccard && ccard.GetComponent <CardOP>().isDropCard)
                {
                    continue;
                }

                if (!ccard)
                {
                    ccard      = GameObject.Find("cCard0");
                    ccard      = Instantiate(ccard);
                    ccard.name = "cCard" + (i + 1);
                    Destroy(ccard.transform.Find("UI").gameObject);

                    ccard.name = "cCard" + (i + 1);
                    ccard.transform.SetParent(GameObject.Find("CCardList").transform);
                    ccard.GetComponent <RectTransform>().localPosition = new Vector3(300, 130, 0);
                    ccard.GetComponent <RectTransform>().localScale    = new Vector3(cardSize, cardSize, 0);

                    //ccard.transform.Find("UI").GetComponent<RectTransform>().position = Vector3.zero;

                    if (exchange != null)
                    {
                        // 교환 할 카드 UI가져오기
                        GameObject exboard = GameObject.Find(exchange);
                        GameObject excard  = exboard.transform.Find("UI").gameObject;
                        // 부모를 바꾸고
                        excard.transform.SetParent(ccard.transform);

                        //excard.GetComponent<RectTransform>().localPosition = Vector3.zero;
                        moveDestList mdl = new moveDestList();

                        mdl.back = true;
                        mdl.dest = Vector3.zero;
                        mdl.name = ccard.name;

                        destList.Add(mdl);
                        Destroy(exboard);

                        exchange = null;
                    }
                }

                // 빈 공간이 있을 시
                if (ccard.transform.Find("UI") == null)
                {
                    Destroy(ccard);
                    break;
                }

                Vector3 cori = ccard.GetComponent <RectTransform>().localPosition;

                ccard.GetComponent <RectTransform>().localPosition = Vector3.Lerp(cori, new Vector3(-180 + (i * ((maxDrawCardNum - cdrawCardNum) * 5.5f)), 30), 0.1f);

                // 카드 정렬 부분
                if ((ccard.GetComponent <RectTransform>().localPosition - cori).magnitude < sortBoundMag)
                {
                    getCardPos = -180 + (i * (35 + (maxDrawCardNum - cdrawCardNum) * 5)) + ((maxDrawCardNum - cdrawCardNum) * 10);

                    if (i == cdrawCardNum - 1)
                    {
                        cstartSettingCard = false;
                    }
                }
            }
        }

        // 카드 무브먼트 큐 제어
        if (pleaseMovePos)
        {
            for (int i = 0; i < destList.Count; i++)
            {
                moveDestList mdl = destList[i];

                GameObject card = GameObject.Find(mdl.name);
                // card보드만 있고 카드UI는 제거 되었을 시 큐에서 제거
                if (card != null && card.transform.Find("UI") == null)
                {
                    destList.Remove(destList[i]);
                    continue;
                }

                // 카드를 가운대로 exhibition
                if (!mdl.back && (card.name != noticeNewCard))
                {
                    Vector3 ori = card.transform.Find("UI").position;
                    card.transform.Find("UI").position = Vector3.Lerp(ori, (mdl.dest), 0.25f);
                }

                // returnCard
                else
                {
                    Vector3 ori = card.transform.Find("UI").localPosition;
                    card.transform.Find("UI").localPosition = Vector3.Lerp(ori, Vector3.zero, 0.25f);

                    noticeNewCard = "";
                }

                if ((card.transform.Find("UI").localPosition).magnitude < sortBoundMag)
                {
                    card.GetComponent <CardOP>().isTouchAble = true;
                    destList.Remove(mdl);
                    // 리스트에서 삭제
                }
            }
        }

        // 카드 클릭 시 상대편에게 카드를 넘깁니다.
        // 카드를 상대편의 드로우로 위치를 옮기고 그 위치로 카드 이미지를 lerp
        if (clickedCard)
        {
            GameObject card = GameObject.Find(exchange);
            // <warning> exchange가 나중에 null이 되면 다음의 알고리즘 바꿔주세요

            if (card)
            {
                Vector3 ori = card.transform.Find("UI").localPosition;
                card.transform.Find("UI").localPosition = Vector3.Lerp(ori, Vector3.zero, 0.25f);

                if ((card.transform.Find("UI").localPosition).magnitude < sortBoundMag)
                {
                    card.GetComponent <CardOP>().isTouchAble = true;
                    clickedCard = false;
                    // 리스트에서 삭제
                }
            }
        }
    }