コード例 #1
0
    /// <summary>
    /// 下一步按钮回调
    /// </summary>
    void NextBtnClick()
    {
        List <int> wordIndexList;
        string     splitWord;

        m_EditorLetterPan.ConfirmWord(out wordIndexList, out splitWord);

        WordSplitList.Add(wordIndexList);
        m_SplitWordListScript.AddWord(splitWord);
    }
    private void SetupWordList()
    {
        TextTracker tracker = TrackerManager.Instance.GetTracker <TextTracker>();

        if (tracker != null)
        {
            WordList wordList = tracker.WordList;
            wordList.LoadWordListFile(this.mWordListFile);
            if (this.mCustomWordListFile != "")
            {
                wordList.AddWordsFromFile(this.mCustomWordListFile);
            }
            if (this.mAdditionalCustomWords != null)
            {
                foreach (string str in this.mAdditionalCustomWords.Split(new char[] { '\r', '\n' }))
                {
                    if (str.Length > 0)
                    {
                        wordList.AddWord(str);
                    }
                }
            }
            wordList.SetFilterMode(this.mFilterMode);
            if (this.mFilterMode != WordFilterMode.NONE)
            {
                if (this.mFilterListFile != "")
                {
                    wordList.LoadFilterListFile(this.mFilterListFile);
                }
                if (this.mAdditionalFilterWords != null)
                {
                    foreach (string str2 in this.mAdditionalFilterWords.Split(new char[] { '\n' }))
                    {
                        if (str2.Length > 0)
                        {
                            wordList.AddWordToFilterList(str2);
                        }
                    }
                }
            }
        }
    }
コード例 #3
0
    void createText(string text, string parentName)
    {
        // ホスト以外は処理をしない
        if (!MonobitEngine.MonobitNetwork.isHost)
        {
            return;
        }
        GameObject newText = MonobitNetwork.Instantiate(
            ToSpawn.name,
            Vector3.zero,
            Quaternion.identity,
            0,
            null,
            true,
            false,
            true
            ) as GameObject;

        newText.GetComponentInChildren <textStatusReceiver>().parentName = parentName;
        newText.GetComponentInChildren <textStatusReceiver>().text       = text;
        newText.GetComponentInChildren <textStatusReceiver>().color      = fcp.color;
        //入力された言葉を連想配列に追加する
        wordList.AddWord(text);
    }
コード例 #4
0
    static void Main()
    {
        Console.ForegroundColor = ConsoleColor.Red;
        Console.Title           = "C# Hangman";
        Console.WriteLine("Welcome To C# Hangman!");

        //MENU

        char MenuChoice;

        Console.Write("\n\t1) Add words");
        Console.Write("\n\t2) Show list of words");
        Console.Write("\n\t3) Play");
        Console.Write("\n\t4) Quit\n\n");

        Console.Write("\n\tChoose 1-4: ");            //Choose meny item
        MenuChoice = Convert.ToChar(Console.ReadLine());
        WordList showing = new WordList();

        switch (MenuChoice)
        {
        case '1':
            var input = Console.ReadLine();
            showing.AddWord(input);
            break;

        case '2':

            showing.ListOfWords();
            Console.Write("\n\tList of words\n\n");


            break;


        case '3':               //Running game

            int guesses;
            Console.Write("\n\tHow many faults can you have: ");
            guesses = Convert.ToInt32(Console.ReadLine());
            Console.Write("\n\tAwesome, let´s play!\n");


            String input;
            bool   wrong;
            int    NumberOfTries = 0;


            do
            {
                Console.WriteLine("\n\n\tWrong guesses: " + NumberOfTries + " / " + guesses + "\n");
                Console.WriteLine("\n\tGuessed letters:\n");
                Console.WriteLine("\n\tWord:\n");
                Console.Write("\n\n\tGuess letter: ");
                input = Console.ReadLine();
                Console.Write("\n\n\t ");

                wrong = !input.Equals("t") &&
                        !input.Equals("e") &&
                        !input.Equals("s") &&
                        !input.Equals("t");
                if (wrong)
                {
                    NumberOfTries++;
                    Console.WriteLine("\n\tWrong letter " + "Try again!");
                }
                if (wrong && (NumberOfTries > guesses - 1))
                {
                    Console.WriteLine("\n\tYou have failed " + guesses + ". End of game!\n");
                    break;
                }
            } while (wrong);
            if (!wrong)
            {
                Console.WriteLine("\n\tWhohoo!");
            }

            break;

        case '4':

            Console.WriteLine("\n\tEnd game?\n\n");
            break;
        }
    }
コード例 #5
0
        /// <summary>
        /// This gets called whenever a command is recieved from
        /// </summary>
        /// <param name="pSender">The telnet server instance</param>
        /// <param name="pEventArgs">The event args, including the socket</param>
        private void TelnetCommandRecieved(object pSender, TelnetServerCommandEventArgs pEventArgs)
        {
            //A command has arrived from a telnet client.  Parse it.
            //Tokenize the command string
            string [] tmpCommandArguments = pEventArgs.Command.Split(' ');

            if (tmpCommandArguments.Length > 0)
            {
                switch (tmpCommandArguments[0].ToUpper())
                {
                case "ADD":
                    if (tmpCommandArguments.Length > 1)
                    {
                        System.Text.StringBuilder tmpSearchString = new System.Text.StringBuilder();

                        for (int tmpCounter = 1; tmpCounter < tmpCommandArguments.Length; tmpCounter++)
                        {
                            //Add back the spaces to make the search meaningful.
                            if (tmpSearchString.Length > 0)
                            {
                                tmpSearchString.Append(" ");
                            }

                            tmpSearchString.Append(tmpCommandArguments[tmpCounter].ToString());
                        }

                        _TelnetServer.SendData("Adding [" + tmpSearchString.ToString() + "] to the word list.", pEventArgs.Socket);
                        _TelnetServer.SendLineFeed(pEventArgs.Socket);

                        _WordList.AddWord(tmpSearchString.ToString());

                        _TelnetServer.SendData("There are now " + _WordList.Count + " items in the word list.", pEventArgs.Socket);
                        _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    }
                    else
                    {
                        _TelnetServer.SendData("Use: ADD [word]", pEventArgs.Socket);
                        _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    }
                    break;

                case "AL":
                case "ALP":
                case "ALPH":
                case "ALPHA":
                    if (tmpCommandArguments.Length > 1)
                    {
                        System.Text.StringBuilder tmpSearchString = new System.Text.StringBuilder();

                        for (int tmpCounter = 1; tmpCounter < tmpCommandArguments.Length; tmpCounter++)
                        {
                            //Add back the spaces to make the search meaningful.
                            if (tmpSearchString.Length > 0)
                            {
                                tmpSearchString.Append(" ");
                            }

                            tmpSearchString.Append(tmpCommandArguments[tmpCounter].ToString());
                        }

                        _TelnetServer.SendData("Generating Alphagram from [" + tmpSearchString.ToString() + "]", pEventArgs.Socket);
                        _TelnetServer.SendData(" resulting in [" + GenerateAlphagram(tmpSearchString.ToString()) + "]", pEventArgs.Socket);
                        _TelnetServer.SendLineFeed(pEventArgs.Socket);
                        _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    }
                    else
                    {
                        _TelnetServer.SendData("Use: ALPHA [some text]", pEventArgs.Socket);
                        _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    }
                    break;

                case "CO":
                case "COU":
                case "COUN":
                case "COUNT":
                    _TelnetServer.SendData("There are " + _WordList.Count + " items in the word list.", pEventArgs.Socket);
                    _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    break;

                case "EXIT":
                    //Kill the socket
                    pEventArgs.Socket.Kill();
                    break;

                case "?":
                case "H":
                case "HE":
                case "HEL":
                case "HELP":
                    SendTelnetHelp(pEventArgs);
                    break;

                case "INFO":
                    _TelnetServer.SendData("         Linked List Information", pEventArgs.Socket);
                    _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    _TelnetServer.SendData("-------------------------------------------", pEventArgs.Socket);
                    _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    _TelnetServer.SendData("         List Count: " + _WordList.Count, pEventArgs.Socket);
                    _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    if (_WordList.Count > 0)
                    {
                        _TelnetServer.SendData(String.Format("       Current Item: ({0}) {1} ... Alphagram[{2}]", _WordList.CurrentItemKey, _WordList.CurrentWord, _WordList.CurrentWordAlphagram), pEventArgs.Socket);
                        _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    }
                    _TelnetServer.SendData("          Add Count: " + _WordList.StatisticAddCount, pEventArgs.Socket);
                    _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    _TelnetServer.SendData("       Delete Count: " + _WordList.StatisticDeleteCount, pEventArgs.Socket);
                    _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    _TelnetServer.SendData("       Search Count: " + _WordList.StatisticSearchCount, pEventArgs.Socket);
                    _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    _TelnetServer.SendData(" Search Match Count: " + _WordList.StatisticSearchMatchCount, pEventArgs.Socket);
                    _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    _TelnetServer.SendData("   Navigation Count: " + _WordList.StatisticNavigationCount, pEventArgs.Socket);
                    _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    break;

                case "LS":
                case "LI":
                case "LIS":
                case "LIST":
                    if (tmpCommandArguments.Length > 1)
                    {
                        System.Text.StringBuilder tmpSearchString = new System.Text.StringBuilder();

                        for (int tmpCounter = 1; tmpCounter < tmpCommandArguments.Length; tmpCounter++)
                        {
                            //Add back the spaces to make the search meaningful.
                            if (tmpSearchString.Length > 0)
                            {
                                tmpSearchString.Append(" ");
                            }

                            tmpSearchString.Append(tmpCommandArguments[tmpCounter].ToString());
                        }

                        SendTelnetWordList(pEventArgs, tmpSearchString.ToString().Trim());
                    }
                    else
                    {
                        _TelnetServer.SendData("Use: LIST [option]", pEventArgs.Socket);
                        _TelnetServer.SendLineFeed(pEventArgs.Socket);
                        _TelnetServer.SendData("     If you want a full list, use 'LIST ALL'", pEventArgs.Socket);
                        _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    }
                    break;

                case "LOAD":
                    System.Text.StringBuilder tmpFileName = new System.Text.StringBuilder();

                    if (tmpCommandArguments.Length < 2)
                    {
                        _TelnetServer.SendData("No File Specified; Using 'Scrabble.txt'", pEventArgs.Socket);
                        _TelnetServer.SendLineFeed(pEventArgs.Socket);

                        tmpFileName.Append("Scrabble.txt");
                    }
                    else
                    {
                        for (int tmpCounter = 1; tmpCounter < tmpCommandArguments.Length; tmpCounter++)
                        {
                            //Add back the spaces to make the search meaningful.
                            if (tmpFileName.Length > 0)
                            {
                                tmpFileName.Append(" ");
                            }

                            tmpFileName.Append(tmpCommandArguments[tmpCounter].ToString());
                        }
                    }

                    _TelnetServer.SendData("Loading [" + tmpFileName.ToString() + "] into the word list.", pEventArgs.Socket);
                    _TelnetServer.SendLineFeed(pEventArgs.Socket);

                    _WordList.LoadWordList(tmpFileName.ToString());

                    _TelnetServer.SendData("There are now " + _WordList.Count + " items in the word list.", pEventArgs.Socket);
                    _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    break;

                case "QU":
                case "QUI":
                    _TelnetServer.SendData("You must fully type QUIT to close the program.", pEventArgs.Socket);
                    _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    break;

                case "QUIT":
                    //Kill the socket, close the application
                    pEventArgs.Socket.Kill();
                    _KeepRunning = false;
                    break;

                case "SEARCH":
                    if (tmpCommandArguments.Length > 1)
                    {
                        System.Text.StringBuilder tmpSearchString = new System.Text.StringBuilder();

                        for (int tmpCounter = 1; tmpCounter < tmpCommandArguments.Length; tmpCounter++)
                        {
                            //Add back the spaces to make the search meaningful.
                            if (tmpSearchString.Length > 0)
                            {
                                tmpSearchString.Append(" ");
                            }

                            tmpSearchString.Append(tmpCommandArguments[tmpCounter].ToString());
                        }

                        _TelnetServer.SendData("Searching for word [" + tmpSearchString.ToString() + "] in the word list.", pEventArgs.Socket);
                        _TelnetServer.SendLineFeed(pEventArgs.Socket);

                        if (_WordList.FindFirstByWord(tmpSearchString.ToString()))
                        {
                            _TelnetServer.SendData("Found a match!", pEventArgs.Socket);
                            _TelnetServer.SendLineFeed(pEventArgs.Socket);
                            _TelnetServer.SendData(String.Format(" {0}. {1}          Alphagram[{2}]", _WordList.CurrentItemKey, _WordList.CurrentWord, _WordList.CurrentWordAlphagram), pEventArgs.Socket);
                            _TelnetServer.SendLineFeed(pEventArgs.Socket);
                        }
                        else
                        {
                            _TelnetServer.SendData("No matches!\n\r", pEventArgs.Socket);
                            _TelnetServer.SendLineFeed(pEventArgs.Socket);
                        }
                    }
                    else
                    {
                        _TelnetServer.SendData("Use: WORD [number]", pEventArgs.Socket);
                        _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    }
                    break;

                case "SEARCHALPHA":
                    if (tmpCommandArguments.Length > 1)
                    {
                        System.Text.StringBuilder tmpSearchString = new System.Text.StringBuilder();

                        for (int tmpCounter = 1; tmpCounter < tmpCommandArguments.Length; tmpCounter++)
                        {
                            //Add back the spaces to make the search meaningful.
                            if (tmpSearchString.Length > 0)
                            {
                                tmpSearchString.Append(" ");
                            }

                            tmpSearchString.Append(tmpCommandArguments[tmpCounter].ToString());
                        }

                        SendTelnetAlphaWordList(pEventArgs, tmpSearchString.ToString().Trim());
                    }
                    else
                    {
                        _TelnetServer.SendData("Use: SEARCHALPHA [option]", pEventArgs.Socket);
                        _TelnetServer.SendLineFeed(pEventArgs.Socket);
                        _TelnetServer.SendData("     If you want a full list, use 'LIST ALL'", pEventArgs.Socket);
                        _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    }
                    break;

                case "WORD":
                    if (tmpCommandArguments.Length > 1)
                    {
                        long tmpIndexToFind = Convert.ToInt32(tmpCommandArguments[1]);
                        _TelnetServer.SendData("Searching for word #[" + tmpIndexToFind.ToString() + "] in the word list.", pEventArgs.Socket);
                        _TelnetServer.SendLineFeed(pEventArgs.Socket);

                        if (_WordList.FindFirstByIndex(tmpIndexToFind))
                        {
                            _TelnetServer.SendData("Found a match!", pEventArgs.Socket);
                            _TelnetServer.SendLineFeed(pEventArgs.Socket);
                            _TelnetServer.SendData(String.Format(" {0}. {1}          Alphagram[{2}]", _WordList.CurrentItemKey, _WordList.CurrentWord, _WordList.CurrentWordAlphagram), pEventArgs.Socket);
                            _TelnetServer.SendLineFeed(pEventArgs.Socket);
                        }
                        else
                        {
                            _TelnetServer.SendData("No matches!\n\r", pEventArgs.Socket);
                            _TelnetServer.SendLineFeed(pEventArgs.Socket);
                        }
                    }
                    else
                    {
                        _TelnetServer.SendData("Use: WORD [number]", pEventArgs.Socket);
                        _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    }
                    break;

                default:
                    //Do nothing but be a little helpful on default.
                    _TelnetServer.SendData("What are you doing, Dave.\n\rType 'help' for a list of commands.", pEventArgs.Socket);
                    _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    break;
                }
            }
        }