//Incharge of spawning avalible animats void Update() { if (remaingAnimats > 0 && Time.time > nextSpawnTime) { nextSpawnTime = Time.time + currentWave.spawnDelay; AnimatAI spawnedNPC = Instantiate(animat, transform.position + new Vector3(Random.Range(2, 8), 1, Random.Range(2, 8)), Quaternion.identity) as AnimatAI; spawnedNPC.AtributeSetup(AnimatBaseDna[remaingAnimats - 1]); spawnedNPC.OnDeath += onAnimatDeath; spawnedNPC.transform.parent = transform; currentAnimats.Add(spawnedNPC); remaingAnimats--; aliveAnimats++; } }
//Docks a selected animat if the nest is full start reproduction public void Dock(AnimatAI AnimatToDock) { if (currentAnimats.Contains(AnimatToDock) && NestFull != true) { AnimatToDock.gameObject.SetActive(false); dockedAnimats.Add(AnimatToDock); if (dockedAnimats.Count == currentAnimats.Count) { NestFull = true; Debug.Log("Nest full"); if (SimControls.dayCount % 1 == 0 && dockedAnimats.Count >= 2) { pendingGenes = Reproduce(); } else { AnimatBaseDna = null; Debug.Log("Spawner Depleted"); } } } }
// PickFruit function // Takes a target // If valid consumable and the associated function yeilds true, return true public int[] Consume(Transform target) { AnimatStats = GetComponent<AnimatAI>(); int[] reasourceGain; if (target.GetComponentInParent<PrimaryProducer>() == true) { reasourceGain = target.GetComponentInParent<PrimaryProducer>().SheadFruit(); if (reasourceGain != null) { return reasourceGain; } } if (target.GetComponent<Terrain>() == true) { Terrain targetTerrain = target.GetComponent<Terrain>(); if (targetTerrain.Drink() == true) { return new int[] { 10, 0 }; } if (targetTerrain.HasReasource() == true) { targetTerrain.Graze(); return new int[] { 0, 10 }; } } if (target.GetComponentInParent<AnimatEssence>() == true && AnimatStats != null) { reasourceGain = target.GetComponentInParent<AnimatEssence>().Consume(AnimatStats.ReasourceDeficite()); if (reasourceGain != null) { return reasourceGain; } } return null; }
// PickFruit function // Takes a target // If valid consumable and the associated function yeilds true, return true public int[] Consume(Transform target) { AnimatStats = GetComponent <AnimatAI>(); int[] reasourceGain; if (target.GetComponentInParent <PrimaryProducer>() == true) { reasourceGain = target.GetComponentInParent <PrimaryProducer>().SheadFruit(); if (reasourceGain != null) { return(reasourceGain); } } if (target.GetComponent <Terrain>() == true) { Terrain targetTerrain = target.GetComponent <Terrain>(); if (targetTerrain.Drink() == true) { return(new int[] { 10, 0 }); } if (targetTerrain.HasReasource() == true) { targetTerrain.Graze(); return(new int[] { 0, 10 }); } } if (target.GetComponentInParent <AnimatEssence>() == true && AnimatStats != null) { reasourceGain = target.GetComponentInParent <AnimatEssence>().Consume(AnimatStats.ReasourceDeficite()); if (reasourceGain != null) { return(reasourceGain); } } return(null); }
//Component Initilization void Start () { Decision = GetComponent<AnimatAI>(); heightMultiplyer = 0.25f; groundDir = new Vector3(0, -heightMultiplyer); }
//Component Initilization void Start() { Decision = GetComponent <AnimatAI>(); heightMultiplyer = 0.25f; groundDir = new Vector3(0, -heightMultiplyer); }