Beispiel #1
0
    public void WordLength(WordGen theWord)
    {
        string worldlength = "";
        int    lettercount = 1;

        foreach (char letter in theWord.word)
        {
            if (letter == ' ')
            {
                worldlength = worldlength + " ";
            }
            else
            {
                if (lettercount == theWord.word.Length)
                {
                    worldlength = worldlength + "_";
                }


                else
                {
                    worldlength = worldlength + "_ ";
                }
            }
            lettercount++;
        }

        wordprogress = worldlength;
    }
Beispiel #2
0
    // Use this for initialization
    void Awake()
    {
        _wordGen = GetComponent <WordGen>();

        //Singleton instantiation pattern
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            DestroyObject(instance);
        }
    }
Beispiel #3
0
    // Use this for initialization
    void Awake()
    {
        //Singleton instantiation pattern
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            DestroyObject(instance);
        }

        boardScript = GetComponent <BoardManager>();
        wordGen     = GetComponent <WordGen>();
        board       = GetComponent <Board> ();
        StartAPIManager();
    }
Beispiel #4
0
    protected void ButtonStart_Click(object sender, EventArgs e)
    {
        int    previousword     = 0;
        string previouscategory = "Animals";

        if (Session["previousword"] != null)
        {
            previousword = (int)Session["previousword"];
        }
        if (Session["previousword"] != null)
        {
            previouscategory = (string)Session["previouscategory"];
        }

        WordGuess wordguess = new WordGuess();
        WordGen   word      = new WordGen();

        wordguess.theWord = word;
        wordguess.theWord.ChooseTopic(DropDownListCategories.SelectedValue, previousword, previouscategory);
        Session["previousword"]     = wordguess.theWord.words.ToList().FindIndex(a => a == wordguess.theWord.word);
        Session["previouscategory"] = DropDownListCategories.SelectedValue;
        wordguess.letters.Clear();
        wordguess.missedletters.Clear();
        LabelMissWords.Text = wordguess.DisplayMissedLetters();
        wordguess.ResetCounter();
        wordguess.WordLength(wordguess.theWord);
        ImageBase.ImageUrl             = "~/Images/State" + 0 + ".png";
        ButtonGiveUp.Visible           = true;
        TextBoxGuess.Visible           = true;
        ButtonGuess.Visible            = true;
        LabelWordToGuess.Visible       = true;
        LabelWordToGuess.Text          = "";
        LabelWordToGuess.Text          = wordguess.wordprogress;
        LabelMissWords.Visible         = true;
        LabelStatus.Text               = "";
        LabelCategories.Visible        = false;
        DropDownListCategories.Visible = false;
        ButtonStart.Visible            = false;
        Session["wordguess"]           = wordguess;
    }
    // Use this for initialization
    void Start()
    {
        state = GameState.Instance;
        state.currentLevel = this;
        int numColumns = state.numColumns;
        int numRows    = state.numRows;

        int[] runeNums = new int[numColumns * numRows];
        for (int i = 0; i < numRows * numColumns; i++)
        {
            runeNums[i] = i % 26;
        }

        System.Random rnd        = new System.Random();
        var           randomNums = runeNums.OrderBy(r => rnd.Next())
                                   .ToArray();

        GameObject    hex;
        RuneBehaviour rune;
        int           index = 0;

        float xOffset = numColumns * 1.5f * dimension / 2f;
        float yOffset = numRows * 1f * ratio * dimension / 2f;

        for (int row = 0; row < numRows; row++)
        {
            for (int col = 0; col < numColumns; col++)
            {
                hex = GameObject.Instantiate(hexagon) as GameObject;
                hex.transform.parent     = transform;
                hex.transform.localScale = new Vector3(xScale, yScale, 1f);

                hex.transform.localPosition = new Vector3(
                    ((3f + colSpacing) * dimension * col + 1.5f * dimension * (row % 2)) * xScale - xOffset,
                    (row * (ratio * dimension + rowSpacing)) * yScale - yOffset, 0f);

                hex.transform.localRotation = Quaternion.identity;

                rune = hex.GetComponent <RuneBehaviour>();
                rune.SetSymbol(randomNums[index++]);
                runes.Add(rune);
            }
        }

        int numLetters = state.wordLength;

        foreach (Player player in state.players)
        {
            player.SetWord(WordGen.GetWord(numLetters));
        }

        Selector         = GameObject.FindObjectOfType <SelectorWithBolts>();
        PhysicsContainer = GameObject.Find("PhysicsContainer");


        EnableKinematics(true);
        for (int i = 0; i < 3; i++)
        {
            InputManager.Instance.PushActiveContext("CinematicEvent", i);
        }

        Icon1.gameObject.SetActive(false);
        Icon2.gameObject.SetActive(false);
        Icon3.gameObject.SetActive(false);
        IconGo.gameObject.SetActive(false);

        StartCoroutine(CountDown());
    }
Beispiel #6
0
    public void SetupScene(int level, WordGen wordGen, Board board, Themes themes, GameManager gameManager)
    {
        // Properties
        _wordGen     = wordGen;
        _level       = level;
        _board       = board;
        _gameManager = gameManager;
        _camera      = Camera.main;
        _points      = 0;
        _timer       = 0f;
        _themes      = themes;

        int challenge1StartTime = 0;
        int challenge1EndTime   = (int)(_secondsLeft * .333);

        int challenge2StartTime = challenge1EndTime;
        int challenge2EndTime   = (int)(_secondsLeft * .665);

        int challenge3StartTime = challenge2EndTime;
        int challenge3EndTime   = (int)_secondsLeft;

        _challengeTimes.Add(UnityEngine.Random.Range(challenge1StartTime, challenge1EndTime));
        _challengeTimes.Add(UnityEngine.Random.Range(challenge2StartTime, challenge2EndTime));
        _challengeTimes.Add(UnityEngine.Random.Range(challenge3StartTime, challenge3EndTime));

        //Bug timer.... fix here patch
        _totalTimeFloat = 0f;
        _secondsLeft    = _secondsLeftPreserve;

        //Display Points
        _canvas = GameObject.FindGameObjectWithTag("Canvas").GetComponent <Canvas>();
        _dataPersistInstance = Instantiate(_dataPersistPrefab).GetComponent <DataPersist>();

        GameObject scoreTimeInstance = Instantiate(_scoreAndTimePrefab) as GameObject;

        scoreTimeInstance.transform.SetParent(_canvas.transform, false);

        _pauseButton = Instantiate(_pauseButtonPrefab) as Button;
        _pauseButton.transform.SetParent(_canvas.transform, false);
        _pauseButton.onClick.AddListener(() => {
            PauseGame();
        });

        _backButton = Instantiate(_backButtonPrefab) as Button;
        _backButton.transform.SetParent(_canvas.transform, false);
        _backButton.onClick.AddListener(() => {
            _gameManager.RestartGame();
        });

        _shuffleInstance = Instantiate(_shufflePrefab) as GameObject;
        _shuffleInstance.transform.SetParent(_canvas.transform, false);
        _shuffleButton = _shuffleInstance.GetComponentInChildren <Button>();
        _shuffleButton.onClick.AddListener(() => {
            ShuffleBoard();
        });

        _scrollView = _canvas.GetComponentInChildren <ScrollRect> ();
        _scrollBar  = _canvas.GetComponentInChildren <Scrollbar> ();
        _content    = _scrollView.content;

        _gameDetails_Panel         = GameObject.FindGameObjectWithTag("PointsPanel");
        _gameDetails_RectTransform = _gameDetails_Panel.GetComponent <RectTransform> ();

        GameObject timePanel = Instantiate(_timePanelPrefab);

        timePanel.transform.SetParent(_canvas.transform, false);

        _time_Panel         = GameObject.FindGameObjectWithTag("TimePanel");
        _time_RectTransform = _time_Panel.GetComponent <RectTransform> ();

        // Points display
        _pointsText      = Instantiate(_textPrefab, new Vector3(0f, -6f, 0f), Quaternion.identity) as Text;
        _pointsText.text = "Points: " + _points.ToString();
        _pointsText.transform.SetParent(_gameDetails_RectTransform.transform, false);

        // Timer display
        _timeText       = Instantiate(_secondsLeftTextPrefab, new Vector3(0f, 0f, 0f), Quaternion.identity) as Text;
        _secondsLeftInt = (int)_secondsLeft;
        _timeText.text  = _secondsLeftInt.ToString();
        _timeText.transform.SetParent(_time_Panel.transform, false);

        //Theme related UI changes
        switch (_themes.Theme)
        {
        case Themes.Setting.Wood:
            _content.GetComponent <Image>().color           = new Color(1f, 0.973f, 0.522f, .5f);
            _gameDetails_Panel.GetComponent <Image>().color = new Color(1f, 0.973f, 0.522f, .5f);
            break;

        case Themes.Setting.Beach:
            _content.GetComponent <Image>().color           = new Color(0.65f, 0.72f, 0.8f, .5f);
            _gameDetails_Panel.GetComponent <Image>().color = new Color(0.65f, 0.72f, 0.8f, .5f);
            break;

        case Themes.Setting.Grass:
            _content.GetComponent <Image>().color           = new Color(0.4f, 0.82f, 0.8f, 0.5f);
            _gameDetails_Panel.GetComponent <Image>().color = new Color(0.4f, 0.82f, 0.8f, 0.5f);
            break;

        default:
            break;
        }

        _removeSound           = Instantiate(_wordRemoved_SoundPrefab) as AudioSource;
        _multiplierRemoveSound = Instantiate(_multiplierRemoved_SoundPrefab) as AudioSource;

        // Get Started with board definition and setup
        _activePieces = new List <GamePiece> ();
        _boardHolder  = new GameObject("Board").transform;

        InitializeList();
        BoardSetup(_gridPositions, false);
        initialized = true;
    }
Beispiel #7
0
        public string next()
        {
            int wordLen = primeStream.next();

            return(WordGen.Generate(wordLen));
        }