Esempio n. 1
0
        public double GetNormalisedAbundance(int idx)
        {
            Species s         = idxToSpecies[idx];
            double  realAbund = simulation.GetSolvedAbundance(s);

            // null used to always throw event on first time
            if (realAbund <= 0 && (!s.Endangered ?? true))
            {
                OnEndangered.Invoke(idx);
            }
            if (realAbund > 0 && (s.Endangered ?? true))
            {
                OnRescued.Invoke(idx);
            }
            s.Endangered = realAbund <= 0;


            if (realAbund > 0)
            {
                if (realAbund < minRealAbund)
                {
                    return(0);
                }
                else if (realAbund <= maxRealAbund)
                {
                    return((Math.Log10(realAbund) - minLogAbund) / (maxLogAbund - minLogAbund));
                }
                else
                {
                    return(1);
                }
            }
            else // return a negative abundance but scaled as if it were positive
            {
                if (-realAbund < minRealAbund)
                {
                    return(0);
                }
                else if (-realAbund <= maxRealAbund)
                {
                    return(-(Math.Log10(-realAbund) - minLogAbund) / (maxLogAbund - minLogAbund));
                }
                else
                {
                    return(-1);
                }
            }
        }
Esempio n. 2
0
 public void ChangeFriend(int id)
 {
     OnRescued?.Invoke(id);
     myFriend.GetComponent <Friend>().ChangeFriendSkin(id);
 }