/// <summary> /// Instantiates goals around the base of the arena /// </summary> /// <param name="number">How many goas shoudl be instantiated</param> /// <param name="positions">Indices of goals to actually be instantiated</param> /// <param name="radius">Radius of the arena</param> /// <param name="center">XYZ coordinates of the perfect center of the area</param> /// <returns></returns> public List <GoalController> InstantiateGoalsCircumference(int number, int[] positions = null, float radius = 15, Vector3 center = default(Vector3)) { //validations if (positions != null) { if (positions.Max() > number - 1) { Debug.Log("Cannot instantiate goals on positions higher than number of goals"); return(null); } } else { positions = Enumerable.Range(0, number).ToArray(); } Objects.Clear(); foreach (var i in positions) { var goal = Instantiate(GoalPrefab, default(Vector3), default(Quaternion)); if (goal == null) { continue; } goal.transform.SetParent(gameObject.transform); var goalController = goal.GetComponent <GoalController>(); Objects.Add(goalController); } MoveObjectsCircumference(number, positions, radius, center); return(Objects.Cast <GoalController>().ToList()); }
public List <MarkController> InstantiateObjectsOnCircleCircumference(int number, int[] positions = null, float radius = 20, Vector3 center = default(Vector3), string MarkType = "") { //validations if (positions != null) { if (positions.Max() > number - 1) { Debug.Log("Cannot instantiate goals on positions higher than number of goals"); return(null); } } else { positions = Enumerable.Range(0, number).ToArray(); } Objects.Clear(); foreach (var i in positions) { GameObject mark = Instantiate(MarkPrefab, new Vector3(0, 0, 0), new Quaternion(0, 0, 0, 0)) as GameObject; if (mark != null) { mark.transform.SetParent(gameObject.transform); mark.SetActive(true); MarkController markController = mark.GetComponent <MarkController>(); Objects.Add(markController); if (!string.IsNullOrEmpty(MarkType)) { markController.SetType(MarkType); } } else { Debug.Log("Couldnt instantiate for some reason!"); return(null); } } MoveObjectsCircumference(number, positions, radius, center); return(Objects.Cast <MarkController>().ToList()); }