Ejemplo n.º 1
0
        public static T GetRandomItem <T>(this List <T> list)
        {
            if (list.Count == 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            return(list[Maths.RandomNr(0, list.Count - 1)]);
        }
Ejemplo n.º 2
0
 public static Color RandomTransColor()
 {
     return(new Color(Maths.RandomNr(0, 255), Maths.RandomNr(0, 255), Maths.RandomNr(0, 255), Maths.RandomNr(0, 255)));
 }
Ejemplo n.º 3
0
 public static Vector2 RandomV2(int minX, int maxX, int minY, int maxY)
 {
     return(new Vector2(Maths.RandomNr(minX, maxX), Maths.RandomNr(minY, maxY)));
 }
Ejemplo n.º 4
0
 public void RandomizeStartFrame()
 {
     CurrentFrame.X = Maths.RandomNr(0, SheetSize.X - 1);
 }
Ejemplo n.º 5
0
 public static Texture2D str2Tex(params string[] textures)
 {
     return(Global.Content.Load <Texture2D>(Global.TexturesFolder + textures[Maths.RandomNr(0, textures.GetLength(0) - 1)]));
 }
Ejemplo n.º 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="chance">value between 0f and 1f. So 0.5f means 50% chance.</param>
 /// <returns>True if it happens and false if it does not happen.</returns>
 public static bool Chance(float chance)
 {
     return(Maths.RandomNr(1, 100) <= chance * 100);
 }
Ejemplo n.º 7
0
 public static bool RandomBool()
 {
     return(Maths.RandomNr(0, 1) == 1);
 }
Ejemplo n.º 8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="chance">value between 1-100. A value of 0 and lower means 0% chance.</param>
 /// <returns>True if it happens and false if it does not happen.</returns>
 public static bool Chance(int chance)
 {
     return(Maths.RandomNr(1, 100) <= chance);
 }
Ejemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sound"></param>
        /// <returns></returns>
        private static SoundEffectInstance PoolConstructor(params string[] sound)
        {
#warning randomizing the sounds doesnt work for some reason. It's always the same sound...
            SoundEffect         se  = Global.Content.Load <SoundEffect>(Folder + sound[Maths.RandomNr(0, sound.Length - 1)]);
            SoundEffectInstance sei = se.CreateInstance();
            AudioMgrPooled.Instance.InstancesForCleanup.Add(sei);
            sei.IsLooped = false;
            return(sei);
        }