void Start() { anim = GetComponent <Animator>(); centro = new Vector2((int)Screen.width / 2, (int)Screen.height / 2); GameObject aux = BusquedaHijos.buscarHijoPorTag(gameObject, "Weapon"); arma = aux != null?aux.GetComponent <Arma>() : null; puedoAtacar = false; puedoRecoger = false; objetivo = null; armaArecoger = null; }
void Awake() { if (!EsEntrenador) { player = GameObject.FindGameObjectWithTag("Player"); } else { player = BusquedaHijos.buscarHijoPorTag(transform.parent.gameObject, "Player"); } playerHealth = player.GetComponent <PlayerHealth> (); //enemyHealth = GetComponent<EnemyHealth>(); anim = GetComponent <Animator> (); }
void Awake() { if (!EsEntrenador) { player = GameObject.FindGameObjectWithTag("Player").transform; } else { player = BusquedaHijos.buscarHijoPorTag(transform.parent.gameObject, "Player").transform; } playerHealth = player.GetComponent <PlayerHealth> (); enemyHealth = GetComponent <EnemyHealth> (); nav = GetComponent <UnityEngine.AI.NavMeshAgent> (); }
void Start() { anim = GetComponent <Animator>(); contador = 0; GameObject aux = BusquedaHijos.buscarHijoPorTag(gameObject, "Weapon"); arma = aux != null?aux.GetComponent <Arma>() : null; ppOriginales = puntosDePatrulla != null ? puntosDePatrulla : null; ruta = new List <Nodo>(); puntoActual = new Nodo(); puntoActual.worldPosition = transform.position; ojos = GetComponentInChildren <Visualizacion>(); //ojos.setAlcanceVisual(alcanceVisual); }
// Use this for initialization void Start() { Agente = GetComponent <UnityEngine.AI.NavMeshAgent>(); if (EsEntrenador) { player = BusquedaHijos.buscarHijoPorTag(transform.parent.parent.gameObject, "Player").GetComponent <PlayerHealth>(); } else { player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHealth>(); } colisionador = gameObject.GetComponent <CapsuleCollider>(); companionEvolutivo = GameObject.FindGameObjectWithTag("Companion").GetComponent <CompanionEvolutivo>(); //Debug.Log("" + disparador.GetInstanceID()); //Invoke("movimientoAleatorioV2", 1.0f); //Invoke("disparoNoApuntadoAleatorio", 2.0f); }
void Start() { ambientes = GameObject.FindGameObjectWithTag("Ambiente"); for (int i = 0; i < ambientes.transform.childCount; i++) { companionEvolutivo = BusquedaHijos.buscarHijoPorTag(ambientes.transform.GetChild(i).gameObject, "Companion").GetComponent <CompanionEvolutivo>(); //Debug.Log("numero inviduo: "+ numeroIndividuo); GenomaNEAT aux = poblacion[numeroIndividuo]; companionEvolutivo.individuo = numeroIndividuo; companionEvolutivo.setRed(aux); tiempoDePrueba = tiempoPruebaOriginal; numeroIndividuo++; AmbienteEvolutivo ambienteLocal = ambientes.transform.GetChild(i).GetComponent <AmbienteEvolutivo>(); ambienteLocal.tiempoPruebaOriginal = tiempoPruebaOriginal; ambienteLocal.tiempoDePrueba = tiempoPruebaOriginal; ambienteLocal.listo = true; } companionEvolutivo = GameObject.FindGameObjectWithTag("Companion").GetComponent <CompanionEvolutivo>(); }
void Start() { companion = BusquedaHijos.buscarHijoPorTag(gameObject, "Companion").GetComponent <CompanionEvolutivo>(); saludJugador = BusquedaHijos.buscarHijoPorTag(gameObject, "Player").GetComponent <PlayerHealth>(); evolutivo = GameObject.FindGameObjectWithTag("Evolutivo").GetComponent <AlgoritmoEvolutivo>(); }
void Update() { UIManager.generacion = numeroGeneracion; UIManager.individuo = numeroIndividuo + 1; UIManager.especie = numeroEspecie; if (companionEvolutivo == null && numeroIndividuo < tamanioPoblacion && ambientes == null)///si el de cada ambiente /*companionEvolutivo = GameObject.FindGameObjectWithTag("Companion").GetComponent<CompanionEvolutivo>(); * companionEvolutivo.setRed(poblacion[numeroIndividuo]); * companionEvolutivo.setNumeroIndividuo(numeroIndividuo); * // companionEvolutivo.GenerarRed(maximoNeuronas);*/ { ambientes = GameObject.FindGameObjectWithTag("Ambiente"); for (int i = 0; i < ambientes.transform.childCount; i++) { companionEvolutivo = BusquedaHijos.buscarHijoPorTag(ambientes.transform.GetChild(i).gameObject, "Companion").GetComponent <CompanionEvolutivo>(); // Debug.Log("numero inviduo: " + numeroIndividuo); GenomaNEAT aux = poblacion[numeroIndividuo]; companionEvolutivo.individuo = numeroIndividuo; companionEvolutivo.setRed(aux); tiempoDePrueba = tiempoPruebaOriginal; numeroIndividuo++; AmbienteEvolutivo ambienteLocal = ambientes.transform.GetChild(i).GetComponent <AmbienteEvolutivo>(); ambienteLocal.tiempoPruebaOriginal = tiempoPruebaOriginal; ambienteLocal.tiempoDePrueba = tiempoPruebaOriginal; ambienteLocal.listo = true; } companionEvolutivo = GameObject.FindGameObjectWithTag("Companion").GetComponent <CompanionEvolutivo>(); } if (numeroIndividuo >= tamanioPoblacion && ambientes.GetComponent <Gimnasio>().Termino()) { //Debug.Log("Siguiente paso"); calificar(); seleccion(); List <GenomaNEAT> nuevaPoblacion = new List <GenomaNEAT>(); foreach (List <GenomaNEAT> especie in especies) { nuevaPoblacion.Add(cruceEspecie(especie)); } while (nuevaPoblacion.Count < tamanioPoblacion) { int seleccion = Random.Range(0, especies.Count - 1); //Debug.Log("Especies: " + especies.Count + " Seleccion: " + seleccion); nuevaPoblacion.Add(cruceEspecie(especies[seleccion])); } especies = new List <List <GenomaNEAT> >(); foreach (GenomaNEAT hijo in nuevaPoblacion) { aniadirAEspecies(hijo); } numeroGeneracion++; numeroIndividuo = 0; Debug.Log(estadoPoblacion()); poblacion = nuevaPoblacion; //aniadirAEspecies(todos) // ambientes.GetComponent<Gimnasio>().RecargarTodo(); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); // Debug.Log("Siguiente paso 2"); } }
void FixedUpdate() { if (!murio()) { Rotar(); float input_x = Input.GetAxisRaw("Horizontal"); //Se captura movimiento horizontal float input_y = Input.GetAxisRaw("Vertical"); //Se captura movimiento vertical bool isWalking = (Mathf.Abs(input_x) + Mathf.Abs(input_y)) > 0; //condicion directa anim.SetBool("isWalking", isWalking); //le paso al animator el booleano if (isWalking) { //¿Esta Caminando? anim.SetFloat("x", input_x); //Le paso al animator el nuevo estado de la variable x anim.SetFloat("y", input_y); input_x *= 3; input_y *= 3; Vector3 v = new Vector3(input_x, input_y, 0).normalized *Time.deltaTime; //se normaliza por el delta de tiempo para que el movimiento vaya acorde al tiempo de la escena v = v * velocidad; //Para poder encontrar personajes con diferentes velocidades transform.position += v; //Se altera la posicion del personaje } if (arma != null) {//si tiene arma arma.reposicionar(); if (arma.IsBobyToBody()) { if (Input.GetButtonDown("Fire1")) { arma.ataque(); } } else { if (Input.GetButton("Fire1")) { arma.ataque(); ComprobrarVisulizacion(); } } if (Input.GetButtonUp("Fire2"))//soltar el arma { arma.gameObject.transform.SetParent(null); arma = null; } } else { if (Input.GetButtonDown("Fire1")) { Invoke("ataque", 1f); //Ataque cuerpo acuerpo } if (Input.GetButtonUp("Fire1")) { //anim.SetBool("Attack", false); } if (Input.GetButtonUp("Fire2")) {//recoger arma if (puedoRecoger) { armaArecoger.transform.SetParent(transform); arma = BusquedaHijos.buscarHijoPorTag(gameObject, "Weapon").GetComponent <Arma>(); arma.reposicionar(); // RelativeJoint2D union = new RelativeJoint2D(); } } } } }