Exemplo n.º 1
0
        protected int spriteColorByCluster(int nSprite, int nLevels)
        {
            int set   = 0;
            int unset = 0;
            int i     = nSprite * nClustersPerSprite;
            int z     = i + nClustersPerSprite;

            for ( ; i < z; i++)
            {
                if (Clusters.Get(i))
                {
                    set++;
                }
                else
                {
                    unset++;
                }
            }

            if (set == 0)
            {
                return(nLevels);
            }
            double percent = (double)set / (set + unset);
            int    level   = (int)(percent * nLevels);

            if (level >= nLevels)
            {
                level = nLevels - 1;
            }
            return(level);
        }