/// <summary> /// プレイヤー&CPUのカードの変更コルーチン /// </summary> /// <returns>The card.</returns> /// <param name="player">If set to <c>true</c> player.</param> IEnumerator ChengeCard(bool player) { int listn = 0; int looping; if(player == true){ int count = playerd.handCardList.Count; looping = 0; for(int i = 0;i<count;i++){ Vector3 cardVector = playerd.handCardList [i - looping].transform.position; bool IsTouched = playerd.handCardList [i - looping].GetComponent<CardInfo> ().touched; //Destroy (playerd.handCardList [i]); if(IsTouched==false){ if(cardVector.x==-2.0){ listn = 0; }else if(cardVector.x==-1.0){ listn = 1; }else if(cardVector.x==0){ listn = 2; }else if(cardVector.x==1.0){ listn = 3; }else if(cardVector.x==2.0){ listn = 4; } //削除 Destroy (playerd.handCardList [listn - looping]); playerd.removeListp (listn - looping); //生成 int cardnum = Random.Range (0, fieldCardObj.Count); GameObject card = (GameObject)Instantiate (fieldCardObj[cardnum], cardVector, Quaternion.identity); card.name = ""+listn; card.tag="PlayerCard"; card.transform.parent = PlayerParent.transform; //キラカードの選定 int score = 0; int kira = Random.Range (0, 15); if(kira < 6){ card.GetComponent<CardInfo> ().isKira = true; score += 5; }else{ card.GetComponent<CardInfo>().StopParticleSystem(); } Animator panim = card.GetComponent<Animator> (); panim.SetBool ("CardAnim", true); audioSource.PlayOneShot (audioClip); int mark = card.GetComponent<CardInfo> ().Mark; int cardn = card.GetComponent<CardInfo> ().Number; if(cardn==1){ score += 14; }else{ score += cardn; } playerd.handCardMark.RemoveAt(listn - looping); playerd.handCardNum.RemoveAt(listn - looping); playerd.handCardScore.RemoveAt(listn - looping); playerd.addListp (card); playerd.handCardMark.Add (mark); playerd.handCardNum.Add (cardn); playerd.handCardScore.Add (score); fieldCardObj.RemoveAt (cardnum); looping++; yield return new WaitForSeconds(0.5f); } } //ここから敵のチェンジの処理 //変数の初期化 listn = 0; looping = 0; enemyd = FindObjectOfType<Enemy>(); count = enemyd.EnemyCardNum.Count; //タッチさせるためにスイッチで処理を分ける switch(enemyd.ThinkAI()){ case 0: //チェンジしない foreach (GameObject obj in enemyd.EnemyCardObject) { obj.SendMessage ("TouchCardCpu"); } ChengeAndOpenCPUcards (); break; case 1: //スリーカード残し keyvalue = 0; index = 0; foreach(int i in enemyd.EnemyCardNum){ List<int> cardList = enemyd.EnemyCardNum.Select (c => c).Where (s => s == i || s == 0).ToList (); if (cardList.Count == 3) { keyvalue = i; } } foreach(int i in enemyd.EnemyCardNum){ if(i == keyvalue){ enemyd.EnemyCardObject [index].SendMessage ("TouchCardCpu"); } index++; } ChengeAndOpenCPUcards (); break; case 2: //ワンペア残し keyvalue = 0; index = 0; foreach(int i in enemyd.EnemyCardNum){ List<int> cardList = enemyd.EnemyCardNum.Select (c => c).Where (s => s == i || s == 0).ToList (); if (cardList.Count == 2) { keyvalue = i; } } foreach(int i in enemyd.EnemyCardNum){ if(i == keyvalue){ enemyd.EnemyCardObject [index].SendMessage ("TouchCardCpu"); } index++; } ChengeAndOpenCPUcards (); break; case 3: //ツーペア残し keyvalue = 0; index = 0; int keyvaluetwo = 0; foreach(int i in enemyd.EnemyCardNum){ List<int> cardList = enemyd.EnemyCardNum.Select (c => c).Where (s => s == i || s == 0).ToList (); if (cardList.Count == 2) { keyvalue = i; } } foreach(int i in enemyd.EnemyCardNum){ List<int> cardList = enemyd.EnemyCardNum.Select (c => c).Where (s => s == i && s != keyvalue).ToList (); if (cardList.Count == 2) { keyvaluetwo = i; } } foreach(int i in enemyd.EnemyCardNum){ if(i == keyvalue || i == keyvaluetwo){ enemyd.EnemyCardObject [index].SendMessage ("TouchCardCpu"); } index++; } ChengeAndOpenCPUcards (); break; case 4: //スペードのフラッシュ狙い3 index = 0; foreach(int i in enemyd.EnemyCardMark){ if(i == 3){ enemyd.EnemyCardObject [index].SendMessage ("TouchCardCpu"); } index++; } ChengeAndOpenCPUcards (); break; case 5: //ハートのフラッシュ狙い4 index = 0; foreach(int i in enemyd.EnemyCardMark){ if(i == 4){ enemyd.EnemyCardObject [index].SendMessage ("TouchCardCpu"); } index++; } ChengeAndOpenCPUcards (); break; case 6: //ダイアのフラッシュ狙い2 index = 0; foreach(int i in enemyd.EnemyCardMark){ if(i == 2){ enemyd.EnemyCardObject [index].SendMessage ("TouchCardCpu"); } index++; } ChengeAndOpenCPUcards (); break; case 7: //クローバーのフラッシュ狙い1 index = 0; foreach(int i in enemyd.EnemyCardMark){ if(i == 1){ enemyd.EnemyCardObject [index].SendMessage ("TouchCardCpu"); } index++; } ChengeAndOpenCPUcards (); break; case 8: //ジョーカー残し index = 0; foreach(int i in enemyd.EnemyCardMark){ if(i == 0){ enemyd.EnemyCardObject [index].SendMessage ("TouchCardCpu"); } index++; } ChengeAndOpenCPUcards (); break; case 9: //全チェンジ ChengeAndOpenCPUcards (); break; } } yield break; }