Exemple #1
0
 public void SelectNewColony(int index)
 {
     _activeColony = _colonies[index];
     //UI stuff to swap colony UI
     UpdateEncounter(_activeColony);
     _regionUIHandler.UpdateRegionUI(_activeColony);
 }
Exemple #2
0
    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);
        }
    }
Exemple #3
0
    //TODO: Energy Formulas
    private float energyCost(Region rNum, beeColony colonyNum)
    {
        float timeDif = 0f;

        timeDif = timeTaken(rNum, colonyNum);
        return(HiveManager.Instance.HoneyLossPerInterval * timeDif * 2);
    }
Exemple #4
0
    //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)));
    }
Exemple #5
0
 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;
 }
Exemple #6
0
    //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;
    }
Exemple #7
0
    /// <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);
        }
    }
Exemple #8
0
    /// <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() + "%";
    }
Exemple #9
0
    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
        }
    }
Exemple #10
0
 public void UpdateEncounter(beeColony c)
 {
     _encountersHandler.PopulateInfo(c, null);
 }
Exemple #11
0
 //Time helper formula
 private float timeTaken(Region rNum, beeColony colonyNum)
 {
     return(rNum.HiveDistance / colonyNum.Speed);
 }
Exemple #12
0
 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
 }
Exemple #13
0
    public float tInfluence(Region rNum, beeColony colonyNum)
    {
        float tValue = Mathf.Abs(rNum.Temperature + colonyNum.TemperatureResistance);

        return((20 - tValue) / 20);
    }
Exemple #14
0
 public void _updateColonyUI(beeColony currentColony)
 {
     _numBees      = currentColony.numBees;
     _currentSpeed = currentColony.Speed;
 }