連結箱の作成と衝突判定のサンプルコード(一部抜粋) (独自クラス含むのでこのままでは動きません) −−−−− ○フィールド // 連結箱の宣言(衝突判定用) BoundingBox boundingBoxes; −−−−− ○初期化 // 連結箱の作成(衝突判定用) this.boundingBoxes = this.castleList[0].BoundingBox; for (int i = 1; i < this.castleList.Count; i++) { this.boundingBoxes = BoundingBox.CreateMerged(this.boundingBoxes, this.castleList[i].BoundingBox); } −−−−− ○衝突判定 // 球が箱に含まれているかチェックする(衝突判定) public Castle CheckContains(BoundingSphere boundingSphere) { // 戻り値の宣言 Castle ret = null; // 連結箱と球は衝突するか? if (this.boundingBoxes.Contains(boundingSphere) != ContainmentType.Disjoint) { // 拠点毎に衝突判定を行い、衝突対象をチェックする foreach (Castle castle in this.castleList) { // 箱と球は衝突するか? ContainmentType ct = castle.BoundingBox.Contains(boundingSphere); if (ct != ContainmentType.Disjoint) { // 戻り値を設定する ret = castle; // ループを抜ける break; } } } // 戻り値を返却する return ret; }