public void SelectNewColony(int index) { _activeColony = _colonies[index]; //UI stuff to swap colony UI UpdateEncounter(_activeColony); _regionUIHandler.UpdateRegionUI(_activeColony); }
private void Start() { //Updates ui SecondsToSurvive = SecondsToSurvive; CurrentDNA = CurrentDNA; CurrentHoney = CurrentHoney; //initial colony is the first one _activeColony = _colonies[0]; SelectNewColony(0); StartCoroutine(TimeLoss()); StartCoroutine(HoneyLoss()); StartCoroutine(DNAGain()); StartCoroutine(GenerateRegion()); //Starting regions for (int i = 0; i < _startingRegions; ++i) { int temperature = Random.Range(-1, 2); int predator = Random.Range(0, 2); int radiusAroundCenter = 3; float randX = (_gridDimensions.x / 2) + Random.Range(-radiusAroundCenter, radiusAroundCenter - 1); float randY = (_gridDimensions.y / 2) + Random.Range(-radiusAroundCenter, radiusAroundCenter - 1); Vector2 coords = new Vector2(randX, randY); CreateRegion(coords, temperature, predator); } }
//TODO: Energy Formulas private float energyCost(Region rNum, beeColony colonyNum) { float timeDif = 0f; timeDif = timeTaken(rNum, colonyNum); return(HiveManager.Instance.HoneyLossPerInterval * timeDif * 2); }
//TODO: Honey formulas public int totalHoneyGathered(Region rNum, beeColony colonyNum) { int honeyAmount = 500; //TODO: grab value from hive int predatorInfluence = 20; int energyInfluence = 2; float energyVal = energyGather(honeyAmount, rNum, colonyNum); return(Mathf.CeilToInt((rNum.PredatorLevel * predatorInfluence) + (energyVal * energyInfluence))); }
public void InitializeGroup(beeColony c = null, Region r = null, float energyDrainRate = 0, float tickRate = 0) { _currentColony = c; _currentRegion = r; if (c && r) { _curColonyEnergy = Formulas.Instance.energyGather(HiveManager.Instance.CurrentHoney, _currentRegion, _currentColony); _curColBeeCount = c.numBees; } _energyDrainRate = energyDrainRate; ENCOUNTER_TICK_RATE = tickRate; }
//TODO: Predator & Temperature formulas public void killBees(Region rNum, beeColony colonyNum) { int tempBees = 0; for (int i = 0; i < colonyNum.numBees - 1; ++i) { if (Random.Range(0, 7 + colonyNum.AntiPredator) < rNum.PredatorLevel) { tempBees++; } } colonyNum.numBees -= tempBees; }
/// <summary> /// Get's total energy used for gathering while at a region. /// Travel Costs included /// </summary> /// <param name="honeyTotal"></param> /// <param name="rNum"></param> /// <param name="colonyNum"></param> /// <returns></returns> public float energyGather(int honeyTotal, Region rNum, beeColony colonyNum) { float energyOffset = 0f; energyOffset = energyCost(rNum, colonyNum); if ((honeyTotal / 4) - energyOffset <= 0) { return(0); } else { return((honeyTotal / 4) - energyOffset + colonyNum.EnergyUpgrade); } }
/// <summary> /// Updates the region UI /// </summary> /// <param name="r"></param> /// <param name="c"></param> public void UpdateRegionUI(beeColony c, Region r = null) { if (!r && !_currentRegion) { return; } if (r) { _currentRegion = r; } UpdateTemperature(_currentRegion); UpdatePredator(_currentRegion); _regionRemainingHoney.text = _currentRegion.RemainingHoneyCapacity.ToString(); _distanceToHive.text = _currentRegion.HiveDistance.ToString("F1") + " mi."; _regionRisk.text = Formulas.Instance.showPotential(_currentRegion, c).ToString() + "%"; }
public void PopulateInfo(beeColony c, Region r) { if (c != null) { _currentColony = c; } if (r != null) { _currentRegion = r; } Debug.Log(_currentColony + " | " + _currentRegion); if (_currentColony && _currentRegion) { //Update UI stuff here } }
public void UpdateEncounter(beeColony c) { _encountersHandler.PopulateInfo(c, null); }
//Time helper formula private float timeTaken(Region rNum, beeColony colonyNum) { return(rNum.HiveDistance / colonyNum.Speed); }
public float showPotential(Region rNum, beeColony colonyNum) { return(tInfluence(rNum, colonyNum) * 100); //returns % value of potential honey gain, can multiply later to view how much gain there actually is }
public float tInfluence(Region rNum, beeColony colonyNum) { float tValue = Mathf.Abs(rNum.Temperature + colonyNum.TemperatureResistance); return((20 - tValue) / 20); }
public void _updateColonyUI(beeColony currentColony) { _numBees = currentColony.numBees; _currentSpeed = currentColony.Speed; }