Separate defense build branches from enemy lanes

This commit is contained in:
2026-09-23 18:32:02 +09:00
parent c94cbda1e6
commit 926b3f6c5d
4 changed files with 105 additions and 22 deletions
@@ -43,14 +43,15 @@ namespace BumpCombat.Constants
new(9f, 0f),
new(9f, 0f),
};
[Tooltip("Build-only branches sit outside the enemy travel lanes.")]
public Vector2[] BuildPadPositions =
{
new(-3.25f, 3.25f),
new(3.25f, -3.25f),
new(-3.25f, -3.25f),
new(3.25f, 3.25f),
new(0f, 3.25f),
new(0f, -3.25f),
new(-3.25f, 4.9f),
new(3.25f, -4.9f),
new(-3.25f, -4.9f),
new(3.25f, 4.9f),
new(0f, 4.9f),
new(0f, -4.9f),
};
[Tooltip("Two ordered waypoints per lane, indexed by lane * 2 + waypoint.")]
public Vector2[] WaypointPositions =
@@ -964,6 +964,19 @@ namespace BumpCombat.Defense
CreateLaneLine(lane, portal, tuning.GetWaypointPosition(lane, 0));
CreateLaneLine(lane, tuning.GetWaypointPosition(lane, 0), tuning.GetWaypointPosition(lane, 1));
CreateLaneLine(lane, tuning.GetWaypointPosition(lane, 1), basePosition);
int[] padOrder = lane == 0
? new[] { 3, 4, 0 } : new[] { 1, 5, 2 };
Vector2 branchCorner = new(
basePosition.x, tuning.GetBuildPadPosition(padOrder[0]).y);
CreateLaneLine(lane, basePosition, branchCorner, true, 1);
Vector2 branchPoint = branchCorner;
for (int i = 0; i < padOrder.Length; i++)
{
Vector2 padPosition = tuning.GetBuildPadPosition(padOrder[i]);
CreateLaneLine(lane, branchPoint, padPosition, true, i + 2);
branchPoint = padPosition;
}
CreateShape(
$"Portal {lane + 1}",
portal,
@@ -999,7 +1012,8 @@ namespace BumpCombat.Defense
3);
CreateWorldLabel(
$"Build Pad {pad + 1} Label",
position + Vector2.down * 0.95f,
position + (position.y >= tuning.ArenaCenter.y
? Vector2.down : Vector2.up) * 0.95f,
"PAD " + (pad + 1));
}
}
@@ -1060,21 +1074,29 @@ namespace BumpCombat.Defense
+ upgrade;
}
private void CreateLaneLine(int lane, Vector2 from, Vector2 to)
private void CreateLaneLine(
int lane, Vector2 from, Vector2 to,
bool padBranch = false, int segment = 0)
{
GameObject lineObject = new($"Lane {lane + 1} Segment");
string name = padBranch
? $"Pad Branch {lane + 1} Segment {segment}"
: $"Lane {lane + 1} Segment";
GameObject lineObject = new(name);
lineObject.transform.SetParent(worldRoot.transform, false);
LineRenderer line = lineObject.AddComponent<LineRenderer>();
line.useWorldSpace = true;
line.positionCount = 2;
line.SetPosition(0, from);
line.SetPosition(1, to);
line.startWidth = 0.08f;
line.endWidth = 0.08f;
line.startColor = new Color32(108, 151, 177, 210);
line.endColor = new Color32(108, 151, 177, 210);
line.startWidth = padBranch ? 0.12f : 0.08f;
line.endWidth = line.startWidth;
Color32 color = padBranch
? new Color32(91, 206, 160, 225)
: new Color32(108, 151, 177, 210);
line.startColor = color;
line.endColor = color;
line.material = new Material(Shader.Find("Sprites/Default"));
line.sortingOrder = 1;
line.sortingOrder = padBranch ? 2 : 1;
}
private GameObject CreateShape(