Пример #1
0
        protected virtual void Update()
        {
            var finalCounters = counters.Count > 0 ? counters : null;
            var ratio         = P3dColorCounter.GetRatio(color, finalCounters);

            if (inverse == true)
            {
                ratio = 1.0f - ratio;
            }

            cachedImage.fillAmount = Mathf.Clamp01(ratio);
        }
        private bool TryGetContribution(P3dColorCounter counter, ref Contribution contribution)
        {
            if (contributions == null)
            {
                contributions = new List <Contribution>();
            }

            for (var i = contributions.Count - 1; i >= 0; i--)
            {
                contribution = contributions[i];

                if (contribution.Counter == counter)
                {
                    return(true);
                }
            }

            return(false);
        }
        public void Contribute(P3dColorCounter counter, int solid)
        {
            var contribution = default(Contribution);

            if (TryGetContribution(counter, ref contribution) == false)
            {
                if (solid <= 0)
                {
                    return;
                }

                contribution = new Contribution();

                contributions.Add(contribution);

                contribution.Counter = counter;
            }

            contribution.Solid = solid;
        }
Пример #4
0
        protected virtual void Update()
        {
            var finalCounters = counters.Count > 0 ? counters : null;
            var total         = P3dColorCounter.GetTotal(finalCounters);
            var count         = P3dColorCounter.GetCount(color, finalCounters);

            if (inverse == true)
            {
                count = total - count;
            }

            var final   = format;
            var percent = P3dHelper.RatioToPercentage(P3dHelper.Divide(count, total), decimalPlaces);

            final = final.Replace("{TOTAL}", total.ToString());
            final = final.Replace("{COUNT}", count.ToString());
            final = final.Replace("{PERCENT}", percent.ToString());

            cachedText.text = final;
        }