private void SetFormation(NPCInfo newLeader) { foreach (NPCInfo inf in NPCInfos) { inf.SetLeader(false); } if (generalBehavior == NPC.BehaviourType.Wander) { newLeader.SetLeader(true); newLeader.GetGameObject().GetComponent <NPC>().setFormation(newLeader.GetGameObject(), Vector3.zero); SetBestNPCForOffset(newLeader.GetGameObject(), LeftLine, RightLine); } else if (generalBehavior == NPC.BehaviourType.Track) { newLeader.SetLeader(true); newLeader.GetGameObject().GetComponent <NPC>().setFormation(newLeader.GetGameObject(), Vector3.zero); SetBestNPCForOffset(newLeader.GetGameObject(), LeftTrackV, RightTrackV); } else if (generalBehavior == NPC.BehaviourType.Attack) { newLeader.SetLeader(true); newLeader.GetGameObject().GetComponent <NPC>().setFormation(newLeader.GetGameObject(), Vector3.zero); SetBestNPCForOffset(newLeader.GetGameObject(), LeftAttackV, RightAttackV); } }
void Start() { GameObject[] NPCs = GameObject.FindGameObjectsWithTag("NPC"); foreach (GameObject obj in NPCs) { NPCInfo temp = new NPCInfo(); temp.SetGameObject(obj); temp.SetLeader(false); temp.SetBehaviour(NPC.BehaviourType.Wander); NPCInfos.Add(temp); } generalBehavior = NPC.BehaviourType.Wander; SetFormation(GetMiddleNPC()); }