Example #1
0
    void CorrectCheck_Level_two(GameObject clickObject) //정답체크
    {
        WordBox clickWordBox = FindWordBox(clickObject);

        if (wordBox.id == "") //클릭된게 없으면
        {
            wordBox.id       = clickWordBox.id;
            wordBox.row      = clickWordBox.row;
            wordBox.col      = clickWordBox.col;
            wordBox.instance = clickWordBox.instance;
            OutLineOnOFF(wordBox.instance);
        }
        else
        {
            Debug.Log("start" + wordBox.row + "" + wordBox.col + "" + wordBox.id);
            Debug.Log("clicked" + clickWordBox.row + "" + clickWordBox.col + "" + clickWordBox.id);
            if (wordBox.id == clickWordBox.id && wordBox.instance != clickObject) // 현재 클릭된 거랑 이전에 클릭된게 같으면 정답처리
            {
                bool   flag   = solve(wordBox, clickWordBox, 0, wordBox.id);
                string mychar = clickWordBox.id;
                if (flag == true)
                {
                    EffectSoundManager.instance.PlayCorrectSound();
                    wordBox.instance.SetActive(false);
                    FindWordBox(wordBox.instance).active = false;
                    clickWordBox.instance.SetActive(false);
                    clickWordBox.active                      = false;
                    tmap[wordBox.row, wordBox.col]           = ".";
                    tmap[clickWordBox.row, clickWordBox.col] = ".";

                    if (wordNum > 2)
                    {
                        PrintRoad();
                        if (Status() == false)
                        {
                            SaveState.state = false;
                        }
                    }
                    wordNum -= 2;
                    RemainWordBox();
                    Debug.Log("맞음");
                }
                else
                {
                    EffectSoundManager.instance.PlayWrongSound();
                    OutLineOnOFF(wordBox.instance);
                    Debug.Log("틀림");
                }
            }
            else
            {
                EffectSoundManager.instance.PlayWrongSound();
                Debug.Log("틀림");
                OutLineOnOFF(wordBox.instance);
                tmap[wordBox.row + 1, wordBox.col + 1] = wordBox.id;
            }
            wordBox = new WordBox();
        }
        System.GC.Collect();
    }
Example #2
0
        /// <summary>
        /// Builds a new Boggle Game form - the main component of the BoggleClient GUI
        /// </summary>
        /// <param name="_conn"> The player's Boggle Connection</param>
        /// <param name="_name">The player's name</param>
        public GameForm(BoggleConnection _conn, String _name)
        {
            InitializeComponent();
            conn = _conn;
            //register the event handlers
            conn.GameStarted    += StartReceived;
            conn.GameEnded      += StopReceived;
            conn.GameTerminated += TerminateReceived;
            conn.ScoreChanged   += ScoreReceived;
            conn.TimeChanged    += TimeReceived;
            conn.ServerLost     += LostServer;

            //normalize player name for nice display
            _name = _name.ToLower();
            name  = _name[0].ToString().ToUpper() + _name.Substring(1);

            //update labels, initialize board, set up buttons
            P1ScoreLabel.Text = name;
            P2ScoreLabel.Text = "Waiting...";
            this.FormClosing += ExitApplication;
            BoardButtons      = new Dictionary <int, Button>();
            FillBoardButtons();
            ButtonsUsed = false;
            GameStarted = false;
            WordBox.Focus();
            this.AcceptButton = PlayButton;
        }
Example #3
0
        private void wordSearcher(string lettersToSearch, bool isDescending)
        {
            lettersToSearch = lettersToSearch.Replace(" ", string.Empty);

            foreach (string line in File.ReadAllLines(Path.Combine(Environment.CurrentDirectory, fileName)))
            {
                if (line.Length <= lettersToSearch.Length)
                {
                    if (String_Contains_String(line, lettersToSearch))
                    {
                        addStringToDictionary(line, isDescending);
                    }
                }
            }
            if (ordered != null)
            {
                foreach (KeyValuePair <string, int> kv in ordered)
                {
                    WordBox.AppendText(kv.Key + " " + kv.Value + "\n");
                    //Console.WriteLine(kv.Key + " " + kv.Value);
                }
            }
            else
            {
                WordBox.AppendText("No Words Found");
            }
        }
Example #4
0
    public bool solve(WordBox from, WordBox to, int seg, string mychar)
    {
        Debug.Log("solve");
        bool check = false;
        //int depth = 0;
        Pos sp = new Pos(from.row, from.col);
        Pos ep = new Pos(to.row, to.col);

        init();

        path_pos[0].setPos(from.row, from.col);

        dfs_find(sp, ep, 0, -1, ref check, 0);

        if (check)
        {
            for (int i = 0; i < 10; i++)
            {
                if (path_pos[i].x == -1)
                {
                    break;
                }
                Debug.Log(path_pos[i].x.ToString() + "   " + path_pos[i].y.ToString());
            }
            return(true);
        }
        else
        {
            return(false);
        }

        return(false);
    }
Example #5
0
 //Оновлення залишкового часу раунду
 public void TimerTick(object sender, EventArgs e)
 {
     if (roundTime >= 0)
     {
         TimerBox.Text = "До кінця раунду " + roundTime.ToString() + " секунд";
         roundTime--;
         teamtext.Text = "";
         teamInfo();
     }
     else//Кінець раунду
     {
         roundTimer.Stop(); //Зупинка таймера
         roundTimer = new DispatcherTimer(); //Переініціалізація таймера (бо багався)
         //Активація і деактивація кнопок
         next.Visibility  = Visibility.Hidden;
         skip.Visibility  = Visibility.Hidden;
         start.Visibility = Visibility.Visible;
         //Очистка тексту з полів таймера і слова
         TimerBox.Clear();
         WordBox.Clear();
         //Деактивація команди
         teamList[currentTeamNumber - 1].isActive = false;
         //Перевірка, чи за раунд команда набрала виграшну кількість очок
         if (teamList[currentTeamNumber - 1].wins == true)
         {
             Victory();
         }
     }
 }
Example #6
0
 //кнопка очистка
 private void ClearBut_Click(object sender, EventArgs e)
 {
     CountBox.Clear();
     WordBox.Clear();
     DictionaryGridView.Rows.Clear();
     //dataGridView1.DataSource = null;
 }
Example #7
0
    void CorrectCheck_Level_one(GameObject clickObject) //정답체크
    {
        Debug.Log("CorrectCheck");
        WordBox clickWordBox = FindWordBox(clickObject);

        if (wordBox.id == "") //클릭된게 없으면
        {
            wordBox.id       = clickWordBox.id;
            wordBox.instance = clickWordBox.instance;
            OutLineOnOFF(wordBox.instance);
        }
        else
        {
            if (wordBox.id == clickWordBox.id && wordBox.instance != clickObject) // 현재 클릭된 거랑 이전에 클릭된게 같으면 정답처리
            {
                Debug.Log("맞음");
                EffectSoundManager.instance.PlayCorrectSound();
                wordNum -= 2;
                wordBox.instance.SetActive(false);
                FindWordBox(wordBox.instance).active = false;
                clickWordBox.instance.SetActive(false);
                clickWordBox.active = false;
                RemainWordBox();
            }
            else
            {
                Debug.Log("틀림");
                EffectSoundManager.instance.PlayWrongSound();
                OutLineOnOFF(wordBox.instance);
            }
            wordBox = new WordBox();
        }
    }
Example #8
0
 /// <summary>
 /// When a letter box is clicked we change the image to be darker and append that box's label's text to the word box to form a word
 /// </summary>
 /// <param name="i"></param>
 private void BoardButtonPressed(int i)
 {
     WordBox.Focus();
     BoardButtons[i].BackgroundImage = (System.Drawing.Image)Properties.Resources.selectedCube;
     BoardButtons[i].Enabled         = false;
     WordBox.Text += BoardButtons[i].Text.ToUpper();
     ButtonsUsed   = true;
 }
Example #9
0
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            wordOptions.Clear();
            WordBox.Clear();
            bool   isDescending    = SortChooser.SelectedIndex == 0 ? true : false;
            string lettersToSearch = LetterBox.Text;

            wordSearcher(lettersToSearch, isDescending);
        }
Example #10
0
 public WordBoxManager()
 {
     if (wbm == null)
     {
         wbm = this;
     }
     prefab  = Resources.Load <GameObject>("WordBox");
     wordBox = new WordBox(); // 정답 체크용 객체
     next    = new WordBox();
 }
Example #11
0
 private void StartGame()
 {
     WordBox.Enabled             = true;
     WordEnterButton.Enabled     = true;
     DisplayMadLibButton.Visible = false;
     SaveMadLibButton.Visible    = false;
     MadLibDisplayBox.Text       = "";
     madLib.CreateWordList();
     WordBox.Focus();
     DisplayNextWord();
 }
Example #12
0
    public bool Status()
    {
        bool flag = false;

        for (int i = 1; i < ROW_SIZE - 1; i++)
        {
            for (int j = 1; j < COL_SIZE - 1; j++)
            {
                //선택된 칸이 빈칸이면 패스
                if (tmap[i, j] == ".")
                {
                    continue;
                }
                else
                {
                    for (int k = 1; k < ROW_SIZE - 1; k++)
                    {
                        for (int l = 1; l < COL_SIZE - 1; l++)
                        {
                            //시작과 끝이 같은칸이면 패스
                            if (k == i && l == j)
                            {
                                continue;
                            }
                            //끝의 칸이 빈칸이면 패스
                            if (tmap[k, l] == ".")
                            {
                                continue;
                            }
                            WordBox to   = wordBoxes[i - 1, j - 1];
                            WordBox from = wordBoxes[k - 1, l - 1];

                            if (to.id == from.id)
                            {
                                flag = solve(to, from, 0, tmap[i, j]);
                            }

                            if (flag == true)
                            {
                                return(true);
                            }
                            else
                            {
                                continue;
                            }
                        }
                    }
                }
            }
        }
        return(false);
    }
Example #13
0
 private void PlayingState()
 {
     RegisterUserButton.Enabled = false;
     JoinGameButton.Enabled     = false;
     QuitGameButton.Enabled     = true;
     PlayerBox.Enabled          = false;
     ServerBox.Enabled          = false;
     TimeBox.Enabled            = false;
     WordBox.Text    = "";
     WordBox.Enabled = true;
     WordBox.Focus();
     timer          = new Timer();
     timer.Interval = 1000;
     timer.Tick    += UpdateScore;
     timer.Start();
 }
        public static LinkedList <WordBox> Find(FlowDocument Doc, string patternOfRegex)
        {
            LinkedList <WordBox> result = new LinkedList <WordBox>();
            Regex           reg         = new Regex(@patternOfRegex, RegexOptions.IgnoreCase);
            MatchCollection matches     = reg.Matches(new TextRange(Doc.ContentStart, Doc.ContentEnd).Text);

            foreach (Match m in matches)
            {
                WordBox     word  = new WordBox(new Word(m.Value), m.Index);
                TextPointer start = TextProccessorViewModel.GetTextPointerAtOffset(Doc, word.StartInText);
                TextPointer end   = TextProccessorViewModel.GetTextPointerAtOffset(Doc, word.EndInText);
                word.Range = new TextRange(start, end);
                result.AddLast(word);
            }
            return(result);
        }
        public static LinkedList <WordBox> Find(FlowDocument Doc, FontFamily family)
        {
            LinkedList <WordBox> result    = new LinkedList <WordBox>();
            StringBuilder        build     = new StringBuilder();
            TextPointer          end       = Doc.ContentStart;
            TextPointer          wordStart = null;

            MessageBox.Show("Start");
            for (int i = 1, start = 0; end.GetPositionAtOffset(i) != null; i++)
            {
                TextRange range = new TextRange(end.GetPositionAtOffset(i - 1), end.GetPositionAtOffset(i));
                if (family.Equals(range.GetPropertyValue(Inline.FontFamilyProperty)))
                {
                    if (wordStart == null)
                    {
                        wordStart = end.GetPositionAtOffset(i - 1);
                        start     = i - 1;
                    }
                }
                else
                {
                    if (wordStart != null)
                    {
                        TextRange rng = new TextRange(wordStart, end);
                        WordBox   box = new WordBox(new Word(rng.Text), start);
                        result.AddLast(box);
                        box.Range = rng;
                    }
                    wordStart = null;
                    start     = 0;
                }
            }

            foreach (WordBox w in result)
            {
                build.Append(w.Word.Value);
            }
            MessageBox.Show(build.ToString());

            return(result);
        }
Example #16
0
        //добавление слов в словарь
        private void butAdd_Click(object sender, EventArgs e)
        {
            bool flag = true;

            for (int i = 0; (flag) && (i < WordBox.Text.Length); i++)
            {
                flag = Char.IsLetter(WordBox.Text[i]);
            }
            ;
            if ((flag) && (WordBox.Text.Length != 0))
            {
                DictionaryGridView.Rows.Add(WordBox.Text);
                Table.Add(WordBox.Text.ToLower());
                WordBox.Clear();
            }
            else
            {
                MessageBox.Show("Введено недопустимое значение!",
                                "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #17
0
        private void EnterWordButton_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(WordBox.Text))
            {
                madLib.AddWord(WordBox.Text);
                WordBox.Clear();
                WordBox.Focus();

                if (madLib.EntryCount > madLib.TotalEntries)
                {
                    CreateFinishedMadLib();
                    WordInstructionLabel.Text = "Finished. Click the button below to view the finished Mad Lib";
                }
                else
                {
                    WordInstructionLabel.Text = string.Empty;
                    WordExamplesLabel.Text    = string.Empty;
                    Thread.Sleep(250);
                    DisplayNextWord();
                }
            }
        }
Example #18
0
        public void Draw()
        {
            spriteBatch.Draw(Background, new Vector2(0, 0), null, Color.White, 0,
                             new Vector2(0, 0), 1f, SpriteEffects.None, 0);
            WordBox.Draw();
            for (int ii = 0; ii < PlayFieldWidth; ii++)
            {
                for (int jj = 0; jj < PlayFieldHeight; jj++)
                {
                    CurrentLetter2DArray[ii, jj].Draw();
                }
            }
            HomeButton.Draw();
            Drawable.Draw();

            if (Won)
            {
                spriteBatch.Draw(WinnerSplash, new Vector2(256, 144), null, Color.White, 0,
                                 new Vector2(0, 0), 1f, SpriteEffects.None, 0);
                NewButton = new MenuButton(new Vector2(480, 448), "NewButton", gameContent.arrorRight, spriteBatch, gameContent);
                NewButton.Draw();
            }
        }
 void Start()
 {
     wordBox = this;
     isClicked = false;
     currColor = wordText.color;
     move ();
     turnOff ();
 }
Example #20
0
    public void CreateBtns(int level, GameObject gameObject) // 워드박스 생성
    {
        gameBoard = gameObject;
        wordNum   = row * col;
        wordDecks = SaveDeck.getDeck();    // 덱 가져오기
        wordBoxes = new WordBox[row, col]; // 단어 담을 객체 배열

        RemainWordBox();

        for (int i = 0; i < row; i++)
        {
            for (int j = 0; j < col; j++)
            {
                GameObject button = Instantiate(prefab);
                //단어박스 저장
                int position = (row * i) + j; // 현재 배열 위치
                wordBoxes[i, j] = new WordBox(button, wordDecks[position].word, wordDecks[position].id);
                GameObject instance = wordBoxes[i, j].instance;
                wordBoxes[i, j].row = i + 1;
                wordBoxes[i, j].col = j + 1;

                //버튼에 이미지 넣기
                int    r         = Random.Range(0, 4);
                Sprite btnSprite = Resources.Load <Sprite>(imageName[r]);
                Image  image     = instance.GetComponent <Image>();
                image.sprite = btnSprite;

                //위치 잡기
                RectTransform btnpos = instance.GetComponent <RectTransform>();
                instance.transform.position = gameObject.transform.position;
                btnpos.sizeDelta            = new Vector2(box_x_size, box_y_size);
                btnpos.SetParent(gameObject.transform);
                btnpos.anchoredPosition = new Vector2(x_position, y_position);
                btnpos.localScale       = new Vector2(1, 1);
                x_position += box_x_size;

                //버튼 글자 넣기
                Text text = instance.GetComponentInChildren <Text>();
                text.text     = wordBoxes[i, j].word;
                text.fontSize = 100;
                text.font     = Resources.Load <Font>("Typo");

                // Text 오브젝트 공간 조정
                ContentSizeFitter sizeFitter = instance.transform.Find("Text").gameObject.AddComponent <ContentSizeFitter>();
                sizeFitter.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;
                sizeFitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;

                // 버튼 클릭 리스너 등록
                Button btn = instance.GetComponent <Button>();
                btn.onClick.AddListener(() => { EffectSoundManager.instance.PlayPlayerClickedSound(); }); // 클릭 소리
                if (SaveLevel.level == 1)
                {
                    btn.onClick.AddListener(() => { CorrectCheck_Level_one(instance); }); // 비슷한 단어 찾기 정답 체크 함수
                }
                else if (SaveLevel.level == 2)
                {
                    btn.onClick.AddListener(() => { CorrectCheck_Level_two(instance); }); // 사천성 정답 체크 함수
                }
            }
            x_position  = -540;
            y_position -= (box_y_size + 15);
        }
        // GameObject.Find("WordBox").SetActive(false);
        //초기화 다시해줘야 경로 출력 때 사용
        x_position = x_const_position;
        y_position = y_const_position;

        Copy(tmap, wordBoxes);
    }
Example #21
0
    public void Hint()
    {
        Debug.Log("hint");
        if (SaveLevel.level == 1)
        {
            for (int i = 1; i < ROW_SIZE - 1; i++)
            {
                for (int j = 1; j < COL_SIZE - 1; j++)
                {
                    //선택된 칸이 빈칸이면 패스
                    for (int k = 1; k < ROW_SIZE - 1; k++)
                    {
                        for (int l = 1; l < COL_SIZE - 1; l++)
                        {
                            //시작과 끝이 같은칸이면 패스
                            if (k == i && l == j)
                            {
                                continue;
                            }
                            //끝의 칸이 빈칸이면 패스
                            if (tmap[k, l] == ".")
                            {
                                continue;
                            }
                            WordBox to   = wordBoxes[i - 1, j - 1];
                            WordBox from = wordBoxes[k - 1, l - 1];

                            if (to.instance.active == false || from.instance.active == false)
                            {
                                continue;
                            }

                            if (to.id == from.id)
                            {
                                Image imageTo = to.instance.GetComponent <Image>();
                                imageTo.color = new Color32(148, 255, 158, 255);
                                Image imageFrom = from.instance.GetComponent <Image>();
                                imageFrom.color = new Color32(148, 255, 158, 255);
                                return;
                            }
                            else
                            {
                                continue;
                            }
                        }
                    }
                }
            }
        }
        else
        {
            bool flag = false;
            for (int i = 1; i < ROW_SIZE - 1; i++)
            {
                for (int j = 1; j < COL_SIZE - 1; j++)
                {
                    //선택된 칸이 빈칸이면 패스
                    if (tmap[i, j] == ".")
                    {
                        continue;
                    }
                    else
                    {
                        for (int k = 1; k < ROW_SIZE - 1; k++)
                        {
                            for (int l = 1; l < COL_SIZE - 1; l++)
                            {
                                //시작과 끝이 같은칸이면 패스
                                if (k == i && l == j)
                                {
                                    continue;
                                }
                                //끝의 칸이 빈칸이면 패스
                                if (tmap[k, l] == ".")
                                {
                                    continue;
                                }
                                WordBox to   = wordBoxes[i - 1, j - 1];
                                WordBox from = wordBoxes[k - 1, l - 1];

                                if (to.id == from.id)
                                {
                                    flag = solve(to, from, 0, tmap[i, j]);
                                }

                                if (flag == true)
                                {
                                    Debug.Log(tmap[i, j]);
                                    Image imageTo = to.instance.GetComponent <Image>();
                                    imageTo.color = new Color32(148, 255, 158, 255);
                                    Image imageFrom = from.instance.GetComponent <Image>();
                                    imageFrom.color = new Color32(148, 255, 158, 255);
                                    return;
                                }
                                else
                                {
                                    continue;
                                }
                            }
                        }
                    }
                }
            }
        }
    }