Ejemplo n.º 1
0
        /// <summary>
        /// 获取一组不相同的随机数
        /// </summary>
        /// <param name="min">最小值(包含)</param>
        /// <param name="max">最大值(不包含)</param>
        /// <param name="num">随机数量</param>
        /// <returns></returns>
        public static int[] Random(int min, int max, uint num)
        {
            List <int> randoms = new List <int>();

            if (max - min >= num)
            {
                while (randoms.Count < num)
                {
                    int v = UnityEngine.Random.Range(min, max);
                    if (!randoms.Contains(v))
                    {
                        randoms.Add(v);
                    }
                }
            }
            else
            {
                GLog.E("Random Error:: The range of value (max - min) is less then num.");
            }
            return(randoms.ToArray());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取一组不相同的随机数
        /// </summary>
        /// <param name="min">最小值(包含)</param>
        /// <param name="max">最大值(包含)</param>
        /// <param name="num">随机数量</param>
        /// <returns></returns>
        public static float[] Random(float min, float max, uint num)
        {
            List <float> randoms = new List <float>();

            if (max > min)
            {
                while (randoms.Count < num)
                {
                    float v = UnityEngine.Random.Range(min, max);
                    if (!randoms.Contains(v))
                    {
                        randoms.Add(v);
                    }
                }
            }
            else
            {
                GLog.E("Random Error:: Random max value is less than min value.");
            }
            return(randoms.ToArray());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取
        /// </summary>
        /// <returns></returns>
        public GameObject Get()
        {
            if (m_pool.countAll >= m_maxSize && m_pool.countInactive <= 0)
            {
                GLog.E(string.Format("{0} Pool has reached the Maximum.", m_name));
                return(null);
            }

            if (m_pool.countInactive > 0)
            {
                return(m_pool.Get());
            }


            if (m_prefab == null)
            {
                GLog.E(string.Format("{0} Pool 's prefab has been destroyed.", m_name));
                return(null);
            }

            return(m_pool.Get());
        }