예제 #1
0
 /*
  * NewPhase: se encarga de cambiar la fase del agente.
  */
 public void NewPhase()
 {
     if (agent != null)
     {
         GameObject obj      = Instantiate(agent, new Vector2(this.transform.position.x, this.transform.position.y), this.transform.rotation);
         BaseAgent  objAgent = obj.GetComponent <BaseAgent>();
         if (baseAgent != null)
         {
             objAgent.Init(dna, perfectDna, worstDna, baseAgent.hunger);
             if (isTarget)
             {
                 obj.GetComponent <Clickeable>().Evolve();
             }
             baseAgent.DeadAction();
         }
         else
         {
             objAgent.Init(dna, perfectDna, worstDna, 1);
             if (isTarget)
             {
                 obj.GetComponent <Clickeable>().Evolve();
             }
             Destroy(gameObject);
         }
         obj.GetComponent <LifeCycle>().InitCycle(dna, timeOfLife, worstDna, perfectDna);
     }
 }
예제 #2
0
    /*
     * SpawnFly: método encargado de hacer aparecer moscas fuera del agua con un ADN determinado por
     * el mejor y el peor ADN de moscas.
     */
    private void SpawnFly()
    {
        List <float> flyDna;

        flyDna = new List <float>();
        flyDna.Add(Random.Range(minFlyVel, maxFlyVel));
        flyDna.Add(Random.Range(minFlyAcceleration, maxFlyAcceleration));
        flyDna.Add(Random.Range(minFlyPhys, maxFlyPhys));
        flyDna.Add(Random.Range(minFlyOffspring, maxFlyOffspring));
        flyDna.Add(Random.Range(minFlyEggLayingTime, maxFlyEggLayingTime));
        flyDna.Add(Random.Range(minFlyGrowingTime, maxFlyGrowingTime));
        flyDna.Add(Random.Range(minFlyHatchingTime, maxFlyHatchingTime));
        flyDna.Add(Random.Range(minFlyNutritionalValue, maxFlyNutritionalValue));
        flyDna.Add(Random.Range(minFlyLifespan, maxFlyLifespan));
        flyDna.Add(Random.Range(minFlyPossibilityOfSuccess, maxFlyPossibilityOfSuccess));
        flyDna.Add(Random.Range(minFlyMutationRate, maxFlyMutationRate));
        Vector2   randomPos = new Vector2(((Random.value < 0.5f)?(-1):(1)) * Random.Range(22, 40), Random.Range(-22, 20));
        BaseAgent fly       = Instantiate(moscaPrefab, randomPos, Quaternion.identity).GetComponent <BaseAgent>();

        fly.Init(flyDna, perfectFlyDna, worstFlyDna, 1);
    }