public bool BiomeHasFood(BiomeMemory _biome, Biology _bio, float dailyFoodConsumption, float dailyWaterConsumption) { if (_bio.dietType == Biology.DietType.Carnivore) { if (dailyFoodConsumption < (_biome.meatMass - _biome.meatConsumptionMass) && dailyWaterConsumption < (_biome.waterMass - _biome.waterConsumption)) { return(true); } else { return(false); } } else { if (dailyFoodConsumption < (_biome.foliageMass - _biome.foliageConsumptionMass) && dailyWaterConsumption < (_biome.waterMass - _biome.waterConsumption)) { return(true); } else { return(false); } } }
// Start is called before the first frame update void Start() { biomeMemory = GetComponent <BiomeMemory>(); maxDistance = SceneSetupData.instance.maxSunDistance; minDistance = SceneSetupData.instance.minSunDistance; maxTemperature = SceneSetupData.instance.maxBiomeTemperture; }
void ContinueMigrating(BiomeMemory _biome, IHavePrefTemperature _tempStats) { BiomeCoordination _biomeCo = new BiomeCoordination(); Vector3 nextBiome = _biomeCo.NextBiome(_biome, _tempStats, WorldEnvironmentData.instance.SunPositionZ(), transform.position.z, mask); _memory.isMigrating = true; _memory.isWandering = false; _nav.migrationDestination = nextBiome; }
public void CheckBiome(BiomeMemory _biome) { IHavePrefTemperature _temperatureStats = GetComponent <IHavePrefTemperature>(); CreatureEvaluateBiome _evBiome = new CreatureEvaluateBiome(); if (_temperatureStats != null) { if (_evBiome.BiomeHasSuitableTemperature(_temperatureStats.PrefTemp, _temperatureStats.TempDifTolerance, _biome.temperature)) { Debug.Log("CorrectTemp"); IHaveFood _foodStat = GetComponent <IHaveFood>(); IHaveWater _waterStat = GetComponent <IHaveWater>(); if (_foodStat != null) { if (_evBiome.BiomeHasFood(_biome, _bio, _foodStat.MaxFood, _waterStat.MaxWater)) { //Biome has food Debug.Log("BiomeHasFood"); _memory.isMigrating = false; _memory.isWandering = true; } else { ContinueMigrating(_biome, _temperatureStats); Debug.Log("Biome Does not have food"); } } else { Debug.Log("foodstats is null"); } } else { ContinueMigrating(_biome, _temperatureStats); Debug.Log("WrongTemp"); } } }
void ClickOnObject() { RaycastHit hit; Ray ray = GetComponent <Camera>().ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { IAmCreature _creature = hit.transform.GetComponent <IAmCreature>(); if (_creature != null) { CreatureStatus _stats = hit.transform.GetComponent <CreatureStatus>(); BiomeMemory _curBiome = hit.transform.GetComponent <CreatureMemory>().CurBiome; IHavePrefTemperature _tempStats = hit.transform.GetComponent <IHavePrefTemperature>(); if (_stats != null) { _statsUI.UpdateStatUI(_stats, _curBiome, _tempStats); } _motor.SetFollowTarget(hit.transform); } } }
public Vector3 NextBiome(BiomeMemory _biome, IHavePrefTemperature _temperatureStats, float sunZpos, float creatureZpos, LayerMask mask) { Vector3 sunDir; float tempDir = 0; if (_biome.temperature > _temperatureStats.PrefTemp) { tempDir = -1; } else { tempDir = 1; } if (sunZpos > creatureZpos) { sunDir = Vector3.forward; } else { sunDir = Vector3.back; } sunDir.z *= tempDir; //Need to check if any connected biomes are == sunDir BiomeDataStruct _biomeData = _biome._biomeData; int i = 0; Vector3 horizontalBiome = Vector3.zero; Vector3 verticalBiome = Vector3.zero; bool nextBiomeVert = false; foreach (Vector3 _biomeDir in _biomeData.ConnectedBiomes) { if (_biomeDir == sunDir) { verticalBiome = _biomeDir; nextBiomeVert = true; } if (_biomeDir == Vector3.right || _biomeDir == -Vector3.right) { horizontalBiome = _biomeDir; } i++; } Vector3 direction = Vector3.zero; if (nextBiomeVert) { direction = verticalBiome; } else { direction = horizontalBiome; } float distance = _biomeData.BiomeWidth.x; Vector3 nextBiomePosition = _biomeData.Position + (distance * direction); nextBiomePosition.y += 200; RaycastHit hit; if (Physics.Raycast(nextBiomePosition, Vector3.down, out hit, 500, mask)) { nextBiomePosition = hit.point; } FindDestination _findDestination = new FindDestination(); Vector3 nextPosition = _findDestination.FindDestinationWithinRadius(nextBiomePosition, 30); return(nextPosition); }
// Start is called before the first frame update void Start() { _memory = GetComponent <BiomeMemory>(); }
// Start is called before the first frame update void Start() { _memory = GetComponent <BiomeMemory>(); rend = ground.GetComponent <Renderer>(); }