void Awake() { critterCtrl = GetComponent<CritterCtrl>(); if (antenaL == null) throw new Exception("antenaL not set"); if (antenaR == null) throw new Exception("antenaL not set"); }
void Awake() { critter = GetComponent <CritterCtrl>(); if (torzo == null) { throw new Exception("Sprite Renderer <Torzo> not set"); } }
void OnEaten(GameObject eater) { CritterCtrl critter = eater.GetComponentInParent <CritterCtrl>(); if (critter != null) { critter.Feed(feedAmount); gameObject.SetActive(false); } }
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(); }
void Awake() { critterCtrl = GetComponent <CritterCtrl>(); if (antenaL == null) { throw new Exception("antenaL not set"); } if (antenaR == null) { throw new Exception("antenaL not set"); } }
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; } }
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"); }