Skip to content

Commit

Permalink
Army Generator
Browse files Browse the repository at this point in the history
  • Loading branch information
AdronTech committed Jan 21, 2017
1 parent 44ef051 commit d644181
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
Binary file modified GGJ17/Assets/Prefab/King.prefab
Binary file not shown.
Binary file modified GGJ17/Assets/Scene/Marky.unity
Binary file not shown.
22 changes: 9 additions & 13 deletions GGJ17/Assets/Script/KingBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ void Awake () {
my = GetComponent<MyPhysics>();
army = new List<MyPhysics>();

for (int i = 0; i < size; i++)
{
newSoldier();
}
StartCoroutine(generateArmy());

}

private void newSoldier()
Expand All @@ -42,18 +40,16 @@ private void newSoldier()
if (cb != null)
cb.targets = army;

// update other list
foreach(MyPhysics other in army)
}

IEnumerator generateArmy()
{
for (int i = 0; i < size; i++)
{
SeperationBehaviour other_sb = other.GetComponent<SeperationBehaviour>();
if (other_sb != null)
other_sb.targets.Add(solPhysics);
newSoldier();

CohesionBehaviour other_cb = other.GetComponent<CohesionBehaviour>();
if (other_cb != null)
other_cb.targets.Add(solPhysics);
yield return new WaitForSeconds(0.1f);
}
}


}

0 comments on commit d644181

Please sign in to comment.