//------------------------------------ public static void criaGajo_Producao(int i, float radius) { if(anchors_Production.Count>0) { int aux = Random.Range(0, anchors_Production.Count); Vector3 position = v3GetValidCoordinate(anchors_Production[aux].transform.position, radius); //CRIA CITIZEN aux = Random.Range(0, listaTemplates_Adults_Production.Count); GameObject template = listaTemplates_Adults_Production[aux]; GameObject go = (GameObject)Instantiate(template, position, Quaternion.identity); go.transform.gameObject.name += i; GajoCitizen g = go.AddComponent<GajoCitizen>(); g.init(qtGajosSinceBeginning++, null); listaGajos.Add(g); //CRIA FOLLOWER if (Random.Range(0, 100.0f) > 97.5f)//02.5% chances { aux = Random.Range(0, listaTemplates_Adults_Production.Count); template = listaTemplates_Adults_Production[aux]; if (template != null) { GameObject go2 = (GameObject)Instantiate(template, position + Vector3.right, Quaternion.identity); GajoFollower gaf = go2.AddComponent<GajoFollower>(); gaf.init(g, GajoFollower.WalkingMode.ADULT); go2.SetActive(true); i++; } else Debug.LogError("Follower:Citizen template is null!"); } else //CRIA CRIANCA if (listaTemplates_Children_Production.Count > 0) { aux = Random.Range(0, listaTemplates_Children_Production.Count); template = listaTemplates_Children_Production[aux]; if (template != null) { if (Random.Range(0, 100.0f) > 95)// 5 % chances { GameObject go1 = (GameObject)Instantiate(template, position + Vector3.right, Quaternion.identity); GajoFollower g1 = go1.AddComponent<GajoFollower>(); g1.init(g, GajoFollower.WalkingMode.CHILD); i++; } } else Debug.LogError("Children template is null!"); } }else { Debug.LogError("Please add at least one anchor to the scene, to define where characters should appear"); } }
public static void createGajo(int[] dna) { //Boneco// int aux = Random.Range(0, listaTemplates_Adults_Production.Count); GameObject prefab = listaTemplates_Adults_Production[aux]; aux = Random.Range(0, anchors_Production.Count); Vector3 position = v3GetValidCoordinate(anchors_Production[aux].transform.position, 30); GameObject go = (GameObject)Instantiate(prefab, position, Quaternion.identity); go.transform.gameObject.name += listaGajos.Count - 1; GajoCitizen g = go.AddComponent<GajoCitizen>(); g.init(qtGajosSinceBeginning++, dna); listaGajos.Add(g); }