Esempio n. 1
0
    private void Start()
    {
        _target = GameObject.FindGameObjectWithTag("Player").transform;

        MyWord          = WordDatabase.FetchRandomWord();
        wordVisual.text = MyWord;
        _typedWord      = MyWord;
    }
Esempio n. 2
0
    private void Start()
    {
        _line            = GetComponent <LineRenderer>();
        _audioController = GetComponent <AudioController>();

        WordDatabase.LoadWords();   // TODO do this in word database initialization

        RandomizeNewWord();
    }
        public void Controller_Test_WordCounterControllerGetShow()
        {
            WordCounterController wordCounterController = new WordCounterController();

            WordDatabase.AddWordSearch(new WordSearch("apple", "Apple juice is good!"));
            IActionResult showView = wordCounterController.Show(WordDatabase.GetWordSearches().First().Key.ToString());

            Assert.IsInstanceOfType(showView, typeof(ViewResult));
        }
Esempio n. 4
0
    public void ChooseOption(int option)
    {
        float value = WordDatabase.GetWordValue(_currentWords[option]);

        _transactionValue += value;
        UIManager.Instance.UpdateTransactionScore(_transactionValue, value);

        UpdateWords();
    }
Esempio n. 5
0
 void OnEnable()
 {
     db = AssetDatabase.LoadAssetAtPath <WordDatabase>("Assets/" + WordDatabase.db_path);
     if (db == null)
     {
         EditorUtility.DisplayDialog("Error", "Database not created! Create one first!", "OK");
         this.Close();
     }
 }
        public void Controller_Test_WordCounterControllerShowHasCorrectModelType()
        {
            WordCounterController wordCounterController = new WordCounterController();

            WordDatabase.AddWordSearch(new WordSearch("apple", "Apple juice is good!"));
            ViewResult showView = wordCounterController.Show(WordDatabase.GetWordSearches().First().Key.ToString()) as ViewResult;
            var        result   = showView.ViewData.Model;

            Assert.IsInstanceOfType(result, typeof(WordSearch));
        }
Esempio n. 7
0
 public void Load()
 {
     string[] paths = SFB.StandaloneFileBrowser.OpenFilePanel("Open Word Target Database", "", "wtdb", false);
     if (paths.Length == 1)
     {
         StreamReader file = System.IO.File.OpenText(paths[0]);
         db = WordDatabase.Deserialize(file);
         SynchWords();
         filename = paths[0];
     }
 }
Esempio n. 8
0
    public void UpdateOptions(int[] newWords)
    {
        if (_hidden)
        {
            _hidden = false;
            OptionsPanel.SetActive(true);
        }

        for (int i = 0; i < newWords.Length; i++)
        {
            _optionButtonTexts[i].text = WordDatabase.GetWordText(newWords[i]);
        }
    }
Esempio n. 9
0
    private void Update()
    {
        if (hasStarted)
        {
            return;
        }
        //if (Input.GetKeyDown(KeyCode.Space))

        hasStarted = true;
        inputField.AddWord(WordDatabase.GetRandomWord());
        inputField.Activate();
        inputField.OnCompletion += HandleWordDone;
    }
Esempio n. 10
0
    public bool GenBoard()
    {
        WordDatabase db = WordDatabase.Load();

        if (db != null)
        {
            char start_with = (char)Random.Range('a', 'z' + 1);
            var  indices    = db.GetRandomWordList(start_with, TotalWords);
            if (indices == null)
            {
                Debug.LogError("NO WORDS STARTING WITH " + start_with + " IN DATABASE!");
                return(true);
            }
            List <Alphaword> awords = new List <Alphaword>();
            for (int i = 0; i < indices.Count; ++i)
            {
                awords.Add(db[start_with, indices[i]]);
            }
            board = LevelGenerator.Generate(awords);
            return(true);
        }

        return(true);
    }
Esempio n. 11
0
    void Awake()
    {
        if (instance && instance != this)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            state    = confirm_state.NONE;
            var db = WordDatabase.Load();
            if (db != null)
            {
                if (BoardGen.Instance == null)
                {
                    if (RandomStart)
                    {
                        StartWith = (char)Random.Range('a', 'z' + 1);
                    }
                    var indices = db.GetRandomWordList(StartWith, TotalWords);
                    if (indices == null)
                    {
                        Debug.LogError("NO WORDS STARTING WITH " + StartWith + " IN DATABASE!");
                        return;
                    }
                    List <Alphaword> awords = new List <Alphaword>();
                    for (int i = 0; i < indices.Count; ++i)
                    {
                        awords.Add(db[StartWith, indices[i]]);
                    }
                    board = LevelGenerator.Generate(awords);
                }
                else
                {
                    board = BoardGen.Instance.Board;
                }
                var r  = CellPrefab.GetComponent <GameCell>();
                var rt = CellPrefab.transform as RectTransform;
                if (r == null || rt == null)
                {
                    Debug.LogError("NO PROPER CELL PREFAB");
                    return;
                }
                float width  = r.Width;
                float height = r.Height;

                Vector3 origin = new Vector3(BoardOrigin.position.x, BoardOrigin.position.y, 0);
                BoardBackground.sizeDelta = new Vector2(width * board.Width, height * board.Height);

                if (HintBox != null)
                {
                    // paste hints onto hint box
                    HintBox.text = board.Hints;
                }

                // build cells
                cells = new List <InputField>();

                for (int j = 0; j < board.Height; ++j)
                {
                    for (int i = 0; i < board.Width; ++i)
                    {
                        if (board[i, j] == Cell.Empty)
                        {
                            continue;
                        }
                        var curr_cell = Instantiate(CellPrefab);
                        curr_cell.transform.position = origin;
                        // put cells in the scroll view.
                        curr_cell.transform.SetParent(BoardOrigin);
                        curr_cell.GetComponent <GameCell>().Place(new Coordinates(i, j), board.FirstOf(i, j));
                        cells.Add(curr_cell.GetComponent <InputField>());
                        cells[cells.Count - 1].interactable = true;
                        // place cell at correct position based on size of cell and board coords.
                        (curr_cell.transform as RectTransform).localPosition = new Vector2((i + 1) * width, -(j + 1) * height);
                    }
                }
            }
        }
    }
Esempio n. 12
0
 private void HandleWordDone()
 {
     Debug.Log("word done !");
     inputField.AddWord(WordDatabase.GetRandomWord());
 }
Esempio n. 13
0
 private void UpdateWords()
 {
     _currentWords = WordDatabase.GetRandomWordIdSet().Shuffle().ToArray();
     UIManager.Instance.UpdateOptions(_currentWords);
 }