// Use this for initialization private void Start() { Soldier s = (Soldier)PersonCarlos.Create(PersonType.Soldier); Civilian c = (Civilian)PersonCarlos.Create(PersonType.Civilian); Civilian dd = (Civilian)Civilian.Create(PersonType.Civilian); Soldier s2 = (Soldier)PersonCarlos.Create(PersonType.Soldier); //Person s1 = Person.Create(PersonType.Soldier); ///Person c1 = Person.Create(PersonType.Civilian); PersonCarlos[] persons = new PersonCarlos[] { s, c, dd, s2 }; for (int i = 0; i < persons.Length; i++) { //persons[i].Run(); } }
public static PersonCarlos Create(PersonType personType) { PersonCarlos p = null; switch (personType) { case PersonType.Soldier: p = (PersonCarlos)Resources.Load("Soldier", typeof(PersonCarlos)); break; case PersonType.Civilian: p = (PersonCarlos)Resources.Load("Civilian", typeof(PersonCarlos)); break; default: p = (PersonCarlos)Resources.Load("Civilian", typeof(PersonCarlos)); break; } p = (PersonCarlos)Instantiate(p); return(p); }