Beispiel #1
0
    /// <summary>
    /// ドローのコルーチン処理.
    /// </summary>
    /// <returns>The cards.</returns>
    /// <param name="drawnum">Drawnum.</param>
    IEnumerator DrawCards(int drawnum)
    {
        //ステートをチェンジ
        turn.Chenge_Draw_Turn ();

        playerd = FindObjectOfType<Player>();

        float xVec = cardInstantiateVector.x;
        float yVec = cardInstantiateVector.y;
        float zVec = cardInstantiateVector.z;

        //初期化
        sendCardNum.Clear ();
        sendCardMark.Clear ();
        sendCardObj.Clear ();

        for (int h = 0; h < drawnum; h++) {
            //ランダムに取り出す
            int cardnum = Random.Range (0, fieldCardNum.Count);

            //カードの生成
            GameObject card = (GameObject)Instantiate (fieldCardObj [cardnum], new Vector3(xVec + h,yVec,zVec), Quaternion.identity);
            card.name = "Card:" + h;
            card.tag = "PlayerCard";
            card.transform.parent = PlayerParent.transform;

            //キラカードの選定
            int score = 0;
            int kira = Random.Range (0, 10);
            if(kira < 3){
                card.GetComponent<CardInfo> ().isKira = true;
                score += 5;
            }else{
                card.GetComponent<CardInfo>().StopParticleSystem();
            }

            Animator panim = card.GetComponent<Animator> ();
            panim.SetBool ("CardAnim", true);
            sendCardObj.Add (card);

            //効果音の再生
            audioSource.PlayOneShot (audioClip);

            //カード情報の取得
            int mark = card.GetComponent<CardInfo> ().Mark;
            int cardn = card.GetComponent<CardInfo>().Number;

            //A->14変換
            if(cardn==1){
                score += 14;
            }else{
                score += cardn;
            }

            //カードのリストに加える
            sendCardMark.Add (mark);
            sendCardNum.Add (cardn);

            sendCardScore.Add (score);

            //場のカードから引いたカードを削除
            fieldCardObj.RemoveAt (cardnum);
            fieldCardNum.RemoveAt (cardnum);
            fieldCardMark.RemoveAt (cardnum);

            yield return new WaitForSeconds(0.5f);
        }

        //リストを渡す
        playerd.drawCard (sendCardNum, sendCardMark, sendCardObj,sendCardScore);

        //一時保存用のリストを初期化
        sendCardNum.Clear ();
        sendCardMark.Clear ();
        sendCardObj.Clear ();
        sendCardScore.Clear();

        enemyd = FindObjectOfType<Enemy>();

        //CPUのドロー
        for (int h = 0; h < drawnum; h++) {
            //ランダムに取り出す
            int cardnum = Random.Range (0, fieldCardNum.Count);

            //カードの生成
            GameObject card = (GameObject)Instantiate (fieldCardObj [cardnum], new Vector3(xVec + h,yVec + 3.2f,zVec), Quaternion.identity);
            card.name = "Card:" + h;
            card.transform.parent = CpuParent.transform;
            card.tag = "CpuCard";
            sendCardObj.Add (card);

            //キラカードの選定
            int score = 0;
            int kira = Random.Range (0, 10);
            if(kira == 2){
                card.GetComponent<CardInfo> ().isKira = true;
                score += 5;
            }else{
                card.GetComponent<CardInfo>().StopParticleSystem();
            }

            //効果音の再生
            audioSource.PlayOneShot (audioClip);

            //カード情報の取得
            int mark = card.GetComponent<CardInfo> ().Mark;
            int cardn = card.GetComponent<CardInfo>().Number;

            if(cardn==1){
                score += 14;
            }else{
                score += cardn;
            }

            //カードのリストに加える
            sendCardMark.Add (mark);
            sendCardNum.Add (cardn);
            sendCardScore.Add(score);

            //場のカードから引いたカードを削除
            fieldCardObj.RemoveAt (cardnum);
            fieldCardNum.RemoveAt (cardnum);
            fieldCardMark.RemoveAt (cardnum);

            yield return new WaitForSeconds(0.3f);
        }

        //リストを渡す
        enemyd.drawCardEnemy (sendCardNum, sendCardMark, sendCardObj,sendCardScore);

        //ステートをチェンジ
        turn.Chenge_player_Turn ();
        yield break;
    }