public Transform CreatePrefab(EnumMouvement.MouvementEnum mvt, EnumWeapon.WeaponEnum weapon, TeamScript team) { if (!CasePrefab.ContainsKey(mvt)) { Transform[] transfos = Resources.LoadAll("Character/" + mvt.ToString(), typeof(Transform)) .Cast <Transform>() .ToArray(); if (transfos == null) { Debug.Log("tried to instantates prefabs " + "Character/" + mvt.ToString() + ". but they does not exist"); return(null); } CasePrefab.Add(mvt, transfos); } int rndCase = UnityEngine.Random.Range(0, CasePrefab[mvt].Length); Transform characterConfigured = Instantiate(CasePrefab[mvt][rndCase]) as Transform; characterConfigured.gameObject.AddComponent(Type.GetType("CharacterScript")); characterConfigured.gameObject.GetComponent <CharacterScript>().enumWeapon = weapon; characterConfigured.gameObject.GetComponent <CharacterScript>().enumMouvement = mvt; characterConfigured.gameObject.GetComponent <CharacterScript>().team = team; characterConfigured.gameObject.AddComponent <MeshCollider>(); characterConfigured.gameObject.GetComponent <MeshCollider>().convex = true; characterConfigured.gameObject.GetComponent <MeshCollider>().isTrigger = true; if (team.teamNumber == 1) { characterConfigured.gameObject.GetComponent <Renderer>().material.color = Color.black; } if (team.teamNumber == 2) { characterConfigured.gameObject.GetComponent <Renderer>().material.color = Color.white; } return(characterConfigured); }
public object SetupMouvement(EnumMouvement.MouvementEnum mvt) { switch (mvt) { case EnumMouvement.MouvementEnum.Armored: return(new Armored()); case EnumMouvement.MouvementEnum.Cavalry: return(new Cavalry()); case EnumMouvement.MouvementEnum.Flyier: return(new Flyier()); case EnumMouvement.MouvementEnum.Infantry: return(new Infantry()); default: return(null); } }