private void GenerateSquad() { // Small catch for errors, should never trigger however if (!bGenerationSucces) { Debug.Log("Error reached while generating squad"); return; } Debug.Log("No error found, have a nice day"); // Creates initial game object to house everything, as well as script GameObject NewSquad = new GameObject(newSquad_ID); squad_Masterscript newScript = NewSquad.AddComponent <squad_Masterscript>(); newScript.InitSquad(newSquad_ID, newSquad_PatrolLoop); GameObject squadChars = new GameObject("Squad Characters"); squadChars.transform.SetParent(NewSquad.transform); GameObject squadLocs = new GameObject("Patrol Points"); squadLocs.transform.SetParent(NewSquad.transform); // Loop for creaitng each character for (int i = 0; i < newSquad_Size; i++) { // Instantiates characters GameObject newChar; newChar = GameObject.Instantiate(newSquad_Units[i].gameObject); newChar.transform.SetParent(squadChars.transform); // Sets faction to match the squad newChar.GetComponent <char_Masterscript>().ChangeFaction(newSquad_Faction); newChar.GetComponent <char_Masterscript>().characterSquad = newScript; // Adds character to the Squad's roster newScript.AddSquadMember(newChar.GetComponent <char_Masterscript>()); } // Loop for creating each Patrol Point for (int i = 0; i < newSquad_PatrolSize; i++) { // Creates empty objects GameObject newPatrol = new GameObject(i.ToString()); newPatrol.transform.SetParent(squadLocs.transform); newScript.AddPatrolPoint(newPatrol.transform); } }
public void SetSquad(squad_Masterscript newSquad) { characterSquad = newSquad; }