private static void CollectCollisionInLayer(LayerInfoOnEditor layer) { // レイヤー単位で内容に対して衝突判定を行う。 var collisionGroupId = 0; var firstBox = layer.layerInfo.boxes[0]; firstBox.collisionGroupId = collisionGroupId; // ここでは使用しない右下余白パラメータ float a = 0; var beforeBoxRect = TagTree.GetChildViewRectFromParentRectTrans(layer.collisionBaseSize.x, layer.collisionBaseSize.y, layer.layerInfo.boxes[0].rect, out a, out a); for (var i = 1; i < layer.layerInfo.boxes.Length; i++) { var box = layer.layerInfo.boxes[i]; var rect = TagTree.GetChildViewRectFromParentRectTrans(layer.collisionBaseSize.x, layer.collisionBaseSize.y, box.rect, out a, out a); var isHorOverlap = HorizontalOverlaps(beforeBoxRect, rect); // 最低でも横方向の重なりがあるので、同一グループとしてまとめる。 if (isHorOverlap) { box.collisionGroupId = collisionGroupId; beforeBoxRect = WrapRect(beforeBoxRect, rect); } else { collisionGroupId++; box.collisionGroupId = collisionGroupId; beforeBoxRect = rect; } } }
private static void CollectCollisionInLayer(LayerInfoOnEditor layer) { var collisionGroupId = 0; layer.layerInfo.boxes[0].collisionGroupId = collisionGroupId; var beforeBoxRect = TagTree.GetChildViewRectFromParentRectTrans(layer.collisionBaseSize.x, layer.collisionBaseSize.y, layer.layerInfo.boxes[0].rect); for (var i = 1; i < layer.layerInfo.boxes.Length; i++) { var box = layer.layerInfo.boxes[i]; var rect = TagTree.GetChildViewRectFromParentRectTrans(layer.collisionBaseSize.x, layer.collisionBaseSize.y, box.rect); // 重なっておらず、横方向での重なりがなく、縦に重なる部分がある場合、別のグループとして設定する。 if (beforeBoxRect.Overlaps(rect) || HorizontalOverlaps(beforeBoxRect, rect)) { box.collisionGroupId = collisionGroupId; beforeBoxRect = CombinedRect(beforeBoxRect, rect); } else { collisionGroupId++; box.collisionGroupId = collisionGroupId; beforeBoxRect = rect; } } }