public PuzzleAnimatedString(CanvasDevice device, string str, bool bUseLargeFont = false)
        {
            string[] words = str.Split(" ".ToCharArray());

            PuzzleAnimatedLine line = new PuzzleAnimatedLine();

            for (int i = 0; i < words.Length; i++)
            {
                Color color = i % 2 == 0 ? DarkColor : LightColor;
                PuzzleAnimatedWord currentWord = new PuzzleAnimatedWord(device, words[i], color, bUseLargeFont);
                if (line.Width + currentWord.Width >= 1800)
                {
                    Lines.Add(line);
                    line = new PuzzleAnimatedLine();
                }
                line.AddWord(currentWord);
            }

            if (line.Width > 0)
            {
                Lines.Add(line);
            }

            int totalHeight = Lines.Sum(x => x.Height) + (Lines.Count - 1) * _lineBuffer;
            int y           = (1080 - totalHeight) / 2;

            // center each line
            foreach (PuzzleAnimatedLine l in Lines)
            {
                l.SetPosition(y: y);
                y += l.Height + _lineBuffer;
            }
        }
 public void HighlightWord(string str)
 {
     foreach (PuzzleAnimatedLine line in Lines)
     {
         PuzzleAnimatedWord word = line.GetWord(str);
         if (word != null)
         {
             word.Highlight();
         }
     }
 }
Beispiel #3
0
 public void AddWord(PuzzleAnimatedWord word)
 {
     Words.Add(word);
 }