public override void _Process(float delta) { timer += delta; var sorted = wordPool.OrderByDescending(x => x.Position.x); current = sorted.First(); if (timer > speed) { activateRandom(); timer = 0f; } }
public void activateRandom() { rng.Randomize(); var idleWords = wordPool.Where(x => x.active == false).ToList(); if (idleWords.Count > 0) { if (first == null) { first = idleWords[rng.RandiRange(0, idleWords.Count - 1)]; first.Activate(); } else { idleWords[rng.RandiRange(0, idleWords.Count - 1)].Activate(); } } }
/// <summary> /// Only works if all letters are all leters and are all lowercase /// </summary> /// <param name="word"></param> /// <param name="color"></param> /// <returns></returns> public WordSprite Word(string word, CharColor color) { char[] chars = word.ToCharArray(); WordSprite sprite = new WordSprite { Texture = CharTexture(color) }; for (int i = 0; i < chars.Length; i++) { Rectangle source = new Rectangle { Size = letterSize }; source.Y = 0; source.X = (chars[i] - 'a') * letterWidthHeight; sprite.SourceRectangles.Add(source); } return(sprite); }
/// <summary> /// /// </summary> /// <param name="number"></param> /// <param name="places"></param> /// <returns></returns> public WordSprite Number(int number, int places, CharColor color) { char[] theNumber = number.ToString().ToCharArray(); WordSprite sprite = new WordSprite { Texture = CharTexture(color) }; //add leading zeros for (int i = 0; i < places - theNumber.Length; i++) { sprite.SourceRectangles.Add(new Rectangle(new Point(0, letterWidthHeight), numberSize)); } for (int i = 0; i < theNumber.Length; i++) { Rectangle source = new Rectangle(new Point(0, letterWidthHeight), numberSize) { X = (theNumber[i] - '0') * numberWidth }; sprite.SourceRectangles.Add(source); } return(sprite); }