void Awake()
    {
        critterCtrl = GetComponent<CritterCtrl>();

        if (antenaL == null) throw new Exception("antenaL not set");
        if (antenaR == null) throw new Exception("antenaL not set");
    }
예제 #2
0
 void Awake()
 {
     critter = GetComponent <CritterCtrl>();
     if (torzo == null)
     {
         throw new Exception("Sprite Renderer <Torzo> not set");
     }
 }
예제 #3
0
    void OnEaten(GameObject eater)
    {
        CritterCtrl critter = eater.GetComponentInParent <CritterCtrl>();

        if (critter != null)
        {
            critter.Feed(feedAmount);
            gameObject.SetActive(false);
        }
    }
예제 #4
0
    protected override void EndGeneration()
    {
        Generation currentGeneration = generations.Last.Value;

        foreach (GameObject critter in critters)
        {
            CritterCtrl       ctrl = critter.GetComponent <CritterCtrl>();
            CritterANNControl ann  = critter.GetComponent <CritterANNControl>();
            currentGeneration.AddPhenotype(ann.neuralNetwork.ws, ctrl.LifeSpan() - ctrl.naturalLifeSpan());
        }

        base.EndGeneration();
    }
예제 #5
0
    void Awake()
    {
        critterCtrl = GetComponent <CritterCtrl>();

        if (antenaL == null)
        {
            throw new Exception("antenaL not set");
        }
        if (antenaR == null)
        {
            throw new Exception("antenaL not set");
        }
    }
예제 #6
0
    void SpawnCritters()
    {
        crittersParent = new GameObject("Critters");
        crittersParent.transform.SetParent(transform);

        critters = new GameObject[crittersAmount];

        for (int i = 0; i < crittersAmount; i++)
        {
            GameObject critter = (GameObject)Instantiate(critterPrefab);
            critter.transform.SetParent(crittersParent.transform);
            critters[i] = critter;

            CritterSensors critterSensors = critter.GetComponent <CritterSensors>();
            critterSensors.scene = this;

            CritterCtrl critterCtrl = critter.GetComponent <CritterCtrl>();
            critterCtrl.OnDied += CritteriDed;
        }
    }
예제 #7
0
    void ResetCritters()
    {
        Bounds stageBounds = stageArea.bounds;

        foreach (GameObject critter in critters)
        {
            Vector3 position = new Vector3(
                UnityEngine.Random.Range(stageBounds.min.x, stageBounds.max.x),
                UnityEngine.Random.Range(stageBounds.min.y, stageBounds.max.y),
                0
                );

            Quaternion rotation = Quaternion.AngleAxis(UnityEngine.Random.Range(0, 360), Vector3.forward);

            critter.transform.position = position;
            critter.transform.rotation = rotation;

            CritterCtrl critterCtrl = critter.GetComponent <CritterCtrl>();
            critterCtrl.Initialize();

            crittersAlive++;
        }
    }
 void Awake()
 {
     critter = GetComponent<CritterCtrl>();
     if (torzo == null) throw new Exception("Sprite Renderer <Torzo> not set");
 }