示例#1
0
        public void Next(bool transition = true)
        {
            if (transition)
            {
                SetupTransition();
            }
            solutionProgress++;
            TextboxInfo changeTextbox = null;

            if (transition && solutionProgress >= solution.snapshots.Count)
            {
                solutionProgress = solution.snapshots.Count - 1;
                if (solution.Completed)
                {
                    changeTextbox = new TextboxInfo(Main.textResource.completed);
                }
                else
                {
                    if (solution.Invalid)
                    {
                        changeTextbox = new TextboxInfo(Main.textResource.unsolvable);
                    }
                    else
                    {
                        changeTextbox = new TextboxInfo(Main.textResource.tooDifficult);
                    }
                }
            }
            helpHistory.Clear();
            if (transition)
            {
                ChangeTextbox(changeTextbox);
            }
            solution.snapshots[solutionProgress].CopyTo(this);
            if (transition)
            {
                foreach (Cell cell in board)
                {
                    if (cell.previousInfo is Notes)
                    {
                        Notes notes = (Notes)cell.previousInfo;
                        if (cell.info is Number)
                        {
                            cell.transitionColor = Color.Green;
                        }
                        else if (cell.info is Notes)
                        {
                            Notes newNotes = (Notes)cell.info;
                            for (int k = 0; k < CellInfo.numbers; k++)
                            {
                                if (notes.Values[k] && !newNotes.Values[k])
                                {
                                    notes.OverrideColors[k] = Color.Red;
                                }
                            }
                        }
                    }
                }
            }
        }
示例#2
0
 private void DeletePuzzle()
 {
     foreach (Cell cell in board)
     {
         cell.info            = null;
         cell.transitionColor = null;
         cell.overrideColor   = null;
     }
     previousTextbox  = null;
     textbox          = null;
     solveTime        = 0;
     strategies       = null;
     solution         = null;
     solutionProgress = 0;
     helpHistory.Clear();
 }
示例#3
0
 public HelpSnapshot(Board board)
 {
     this.Contents = board.board.Select(cell => cell.info.HelpClone()).ToArray();
     this.Colors   = board.board.Select(cell => cell.overrideColor).ToArray();
     this.textbox  = board.textbox;
 }
示例#4
0
 public void ChangeTextbox(TextboxInfo next)
 {
     previousTextbox   = textbox;
     textbox           = next;
     textboxTransition = 0f;
 }
示例#5
0
        public void DrawTextBox(float x, float y, float width, float height, TextboxInfo textboxInfo, float alpha = 1f)
        {
            string text = textboxInfo.Text;

            string[] args = textboxInfo.Arguments;
            DrawTextBox(x, y, width, height, alpha);
            List <string> words  = new List <string>();
            List <bool>   spaces = new List <bool>();
            int           k      = 0;

            while (k < text.Length)
            {
                if (text[k] == ' ')
                {
                    k++;
                }
                else if (text[k] == '[')
                {
                    int l;
                    for (l = k + 1; l < text.Length; l++)
                    {
                        if (text[l] == ']')
                        {
                            break;
                        }
                    }
                    if (l < text.Length)
                    {
                        words.Add(text.Substring(k, l + 1 - k));
                        spaces.Add(l + 1 < text.Length && text[l + 1] == ' ');
                        k = l + 1;
                    }
                }
                else
                {
                    int  l;
                    bool addSpace = true;
                    for (l = k + 1; l < text.Length; l++)
                    {
                        if (text[l] == ' ' || text[l] == '[')
                        {
                            if (text[l] == '[')
                            {
                                addSpace = false;
                            }
                            break;
                        }
                    }
                    spaces.Add(addSpace);
                    words.Add(text.Substring(k, l - k));
                    k = l;
                    if (addSpace)
                    {
                        k++;
                    }
                }
            }
            Color color      = Color.Black;
            float charX      = 0f;
            float charY      = 0f;
            float lineHeight = 0f;

            for (k = 0; k < words.Count; k++)
            {
                string word     = words[k];
                string realWord = word;
                bool   drawWord = false;
                if (word[0] == '[' && word[word.Length - 1] == ']' && word.Length > 4)
                {
                    if (word[2] != ':')
                    {
                        drawWord = true;
                    }
                    else if (word[1] == 'c')
                    {
                        string name = word.Substring(3, word.Length - 4);
                        Color  tryColor;
                        if (Color.GetColor(name, out tryColor))
                        {
                            color = tryColor;
                        }
                        else
                        {
                            drawWord = true;
                        }
                    }
                    else if (word[1] == 'a')
                    {
                        string number = word.Substring(3, word.Length - 4);
                        int    arg;
                        if (int.TryParse(number, out arg))
                        {
                            realWord = args[arg];
                        }
                        drawWord = true;
                    }
                    else
                    {
                        drawWord = true;
                    }
                }
                else
                {
                    drawWord = true;
                }
                if (drawWord)
                {
                    float wordWidth  = MeasureTextWidth(realWord);
                    float wordHeight = MeasureTextHeight(realWord);
                    if (charX > 0f && charX + wordWidth > width - 8f)
                    {
                        charX      = 0f;
                        charY     += lineHeight + 4f;
                        lineHeight = 0f;
                    }
                    if (wordHeight > lineHeight)
                    {
                        lineHeight = wordHeight;
                    }
                    DrawText((int)(x + 4f + charX), (int)(y + 4f + charY), realWord, color);
                    charX += wordWidth;
                }
                if (spaces[k])
                {
                    charX += 8f;
                }
            }
        }