public void SetupHero(GameObject HeroObject, string name) { HeroDescriptionClass desc = FindHeroDescByName(name); if (desc != null) { SetupHero(HeroObject, desc); } }
/* * public GameObject GetHeroByName(string name) { * foreach (GameObject hero in HeroesBaseList) { * if (string.Equals(hero.GetComponent<Hero> ().Name, name)) { * Debug.Log ("Found hero named " + name); * return Instantiate(hero); * } * } * Debug.Log ("Cant find hero named " + name); * return null; * } */ public GameObject GetHeroByName(string name) { HeroDescriptionClass desc = FindHeroDescByName(name); if (desc != null) { Debug.Log("Found hero named " + name); GameObject newHero = SpawnNewHero(); SetupHero(newHero, desc); return(newHero); } Debug.Log("Cant find hero named " + name); return(null); }
public void SetupHero(GameObject HeroObject, HeroDescriptionClass desc) { if (desc != null) { Pawn PawnComp = HeroObject.GetComponent <Pawn> (); Hero HeroComp = HeroObject.GetComponent <Hero> (); HeroComp.Name = desc.Name; HeroComp.HeroColor = desc.HeroColor; HeroComp.CardsPool = desc.CardsPool; HeroComp.Description = desc.Description; PawnComp.Name = desc.Name; PawnComp.Desc = desc.Description; PawnComp.SetConfig(desc.AttackConfig, false); PawnComp.Character.GetComponent <SpriteRenderer> ().sprite = desc.Character; PawnComp.CardID = desc.CardID; } }