Ejemplo n.º 1
0
        protected IEnumerator SpawnFish()
        {
            if (Globals.MissionDevelopmentMode)
            {
                yield break;
            }

            mSpawningFish = true;
            Vector3 critterPosition = Position;

            for (int i = 0; i < NumFishToSpawn; i++)
            {
                Critter critter = null;
                critterPosition   = Position;
                critterPosition.x = critterPosition.x + UnityEngine.Random.Range(-Radius, Radius);
                critterPosition.z = critterPosition.z + UnityEngine.Random.Range(-Radius, Radius);
                if (Critters.Get.SpawnCritter(State.NameOfFish, critterPosition, out critter))
                {
                    //make sure the fish have to stay on the same plane
                    critter.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
                    critter.UsePlayerTargetHeight = false;
                    critter.TargetHeight          = WaterLevel;
                    critter.Den = this;
                    SpawnedFish.Add(critter);
                }
                yield return(null);
            }
            enabled       = true;
            mSpawningFish = false;
            yield break;
        }
 public void TraitsCrossover()
 {
     offspring.GetComponent <Critter>().critterTraitsDict = new Dictionary <Trait, float>();                                 //create the list
     foreach (Trait t in System.Enum.GetValues(typeof(Trait)))                                                               //go through each trait
     {
         float rand = (Random.Range(0, 100));                                                                                //generate random number
         if (rand < 100 - mutationRate / 2)                                                                                  //if it is in the mother's range
         {
             offspring.GetComponent <Critter>().critterTraitsDict[t] = mother.GetComponent <Critter>().critterTraitsDict[t]; //get trait value from mother
         }
         else if (rand >= 100 - mutationRate / 2 && rand < 100 - mutationRate)                                               //if it's in the father's range
         {
             offspring.GetComponent <Critter>().critterTraitsDict[t] = father.GetComponent <Critter>().critterTraitsDict[t]; //get trat value from father
         }
         else if (rand >= 100 - mutationRate && rand < 100)                                                                  //if it's in the mutation range
         {
             //generate a random value and assign it to the critter
             if (t != Trait.ViewAngle)
             {
                 offspring.GetComponent <Critter>().critterTraitsDict[t] = Random.Range(0, 10);
             }
             else
             {
                 offspring.GetComponent <Critter>().critterTraitsDict[t] = Random.Range(0, 360);
             }
         }
     }
 }
Ejemplo n.º 3
0
 public void setTarget(Critter target)
 {
     this.target        = target;
     targetGO           = target.gameObject;
     lastTargetPosition = target.transform.position;
     targetAgent        = target.GetComponent <NavMeshAgent>();
     target.BulletIncoming(this);
 }
Ejemplo n.º 4
0
    public void Clone(Critter originalCritter, Hex habitat)
    {
        name = "Bob " + num; num++;
        GameObject newCreature = originalCritter.gameObject;
        EvolutionList originList = originalCritter.GetComponent<EvolutionList>();

        GameObject creature = Instantiate(newCreature, newCreature.transform.position, Quaternion.identity) as GameObject;
        critter = creature.GetComponent<Critter>();

        creature.name = name;
        critter.SetName (name);
        critter.SetNumber(critterCount);
        critter.CloneStats(originalCritter);

        baseFoodValue = (size * size) * 10;
        critter.SetBaseFoodValue(baseFoodValue);
        critter.SetTokenSprite(SelectSprite());
        critter.SetTokenColor(originalCritter.GetTokenColor());
        critter.GenerateDiet();
        critter.GenerateLocomotion();
        critter.SetIsPlayer(false);

        critter.ResetAllXP();

        critter.adultPopulations.Clear();
        critter.cubPopulations.Clear();
        critter.babyPopulations.Clear();
        critter.ClearTokenList();
        critter.habitats.Clear();

        CreateCritterLists(critterCount);
        AddToLocalCritterList(critter, habitat);

        critter.adultPopulations.Add(.5f * startPop);
        critter.babyPopulations.Add(.2f * startPop);
        critter.cubPopulations.Add(.1f * startPop);

        critter.GenerateTokens();

        creature.GetComponent<EvolutionList>().ClearChildren();
        originList.AddNewChild(critter, TurnTimer.currentTurn);

        critter.SetSplinterEvoStart();
        critter.InitializePopsList();

        critterCount++;
    }
Ejemplo n.º 5
0
    int index = 0;                        // cuenta la posicion de los item en el arreglo

    void Awake()
    {
        //selector = new System.Random(System.DateTime.Now.Millisecond);

        if (item.GetComponent <IPool>() == null) // si el item no tiene la interfaz IPool no funcionara
        {
            Debug.LogError("No hay interface IPool En el objeto");
            return;
        }
        items   = new IPool[currentCritters];     // pone la cantidad de item disponibles en la piscina
        objects = new Critter[currentCritters];   // pone la cantidad de gameobjects
        for (int i = 0; i < currentCritters; i++) // aca se hace la creacion
        {
            objects[i] = Instantiate(item, transform.position, Quaternion.identity);
            objects[i].transform.parent = transform;

            items[i] = objects[i].GetComponent <IPool>();
            items[i].Instantiate(); //esto se activa en el critter
        }
    }