Exemple #1
0
        private void RechargeButtons(RechargeMode mode)
        {
            List <LetterButton> targetButtons;

            switch (mode)
            {
            case RechargeMode.All:
                targetButtons = _buttons;
                break;

            case RechargeMode.Used:
                targetButtons = _buttons.Where(b => b.IsUsed).ToList();
                break;

            case RechargeMode.Orb:
                targetButtons = _buttons.Where(b => b.IsUsed && b.Letter.OrbColor != null).ToList();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(mode), mode, null);
            }
            var excludeLetters = TakeLetters(targetButtons).GroupBy(l => l).Where(g => g.Count() > 1).Select(g => g.Key).ToList();
            var letters        = LetterCore.PickLetters(targetButtons.Count, excludeLetters);

            for (var i = 0; i < targetButtons.Count; i++)
            {
                var button = targetButtons[i];
                if (letters.Count <= i)
                {
                    button.SetUsed(true);
                }
                else
                {
                    button.SetLetter(new Letter(letters[i]));
                    button.SetUsed(false);
                }
            }

            SetButtonsLocked(false);



            if (BattleLogController.Instance?.IsActive == true)
            {
                var hasLetters = TakeLetters(_buttons);
                var words      = LetterCore.GetWords(hasLetters);

                var topWords = words.GroupBy(w => w.Length).OrderBy(g => g.Key).Select(g => g.First());
                BattleLogController.Instance?.PushMessage($"total {words.Count} examples: {string.Join(", ", topWords)}");
            }
        }
Exemple #2
0
 private void Awake()
 {
     LetterCore.Init();
 }
Exemple #3
0
 private void Awake()
 {
     _db = LetterCore.LoadDb();
 }