public void TargetBattle(NetworkConnection target, int CardSetNum, int EnemyCardNum) { GameObject[] obj = GameObject.FindGameObjectsWithTag("CardSet"); CardSet cardSet = null; CardSet EnemyCardSet = null; // 重なるカードを検索 foreach (GameObject cardset in obj) { // 検索出来たら処理をする if (cardset.GetComponent <CardSet>().GameManager.tag == this.tag) { if (cardset.GetComponent <CardSet>().CardNum == CardSetNum) { // 検索結果を一時格納 cardSet = cardset.GetComponent <CardSet>(); // 無駄にループさせない break; } } } // 重なるカードを検索 foreach (GameObject cardset in obj) { // 検索出来たら処理をする if (cardset.GetComponent <CardSet>().GameManager.tag == this.tag) { if (cardset.GetComponent <CardSet>().CardNum == EnemyCardNum) { // 検索結果を一時格納 EnemyCardSet = cardset.GetComponent <CardSet>(); // 無駄にループさせない break; } } } cardSet.MoveOverlap(EnemyCardSet.transform); }