Show us what you came up with so far. I don’t know what solution are you expecting, but I’m assuming you’re just looking for ideas.
But basically you need some class to hold your squad members:
public class Squad
Inside that class:
you could use a list of your squadrons/soldiers/warriors
public List<Soldier> members = new List<Soldier>();
you could have a GameObject that will act as the Squad in the game
so in your constructor you could pass in a list of squadrons
so then you parent them to that game object, so that when the object move, the children
will move with it.
an enum to represent your formation
public Formation formation;
Where Formation is something like:
public enum Formation { Square, Rect, Triangle, Circle, etc... }
couple methods, like:
public void ChangeFormation(Formation newFormation)
{
// make a switch statement on the new formation
caes Formation.Square:
// do something to change their setup to a square shape
// something like messing with their transforms, start by taking the no. squadrons you
// have in your squad, for ex 4, so you loop over 4 times get each squadron and
// position him with a specific offset... it would be easier if you made a function
// that deals with your 1d list as 2d, or use a 2d list (I prefer the former method),
// that way you loop over its
// rows and cols and position each soldier...
}
perhaps something like:
public void Notify_UnitDown(string unitName)
{
// find out who got killed, loop over your list and check names
// take him out of your squad
// you could then perform some checks to see what the squad's current formation is
// and what their next formation should be, you must pre-set this bevaviour by
// yourself. like if they were 4 and 1 got killed, maybe you would want the remaining
// 3 to stand in line?
}
Then you got your squad moving:
public void MoveTo(Vector3 newPos)
{
// you need to find a way to choose a leader to your squad, so that you could choose
// him to move, and make the others move with the same direction and the same distance
// for n % 2 != 0 squads, like 5 members or 3, you could pick the one in the middle
// compute the dist between him and the newPos, get the direction, move him and
// his other teammates according to that dist and direction...
}
I think you can select your whole squad by attaching a collider to it, and when the player clicks on it you highlight all squadrons or something…
void OnMouseClick()
{
foreach(var member in members)
member.Select(); // just highlight him, show some hud, healthbar, name, etc
}
Hope that kinda helped, you can’t really expect something better, because you must come up with something by yourself and shouldn’t depend on others from the start. Good luck.
[EDIT]: Just came across this.