コード例 #1
0
        private void playGame()
        {
            string newWord = list[rand.NextInt(list.Count)].Name;

            while (newWord.Equals(currWord))
            {
                newWord = list[rand.NextInt(list.Count)].Name;
            }
            currWord = newWord;

            charViews = new TextView[currWord.Length];
            // poista vanhat sanat
            wordLayout.RemoveAllViews();

            for (int c = 0; c < currWord.Length; c++)
            {
                charViews[c]      = new TextView(this);
                charViews[c].Text = currWord[c] + "";

                charViews[c].LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                charViews[c].Gravity          = GravityFlags.Center;
                charViews[c].SetTextColor(Resources.GetColor(Resource.Color.white));
                charViews[c].SetBackgroundResource(Resource.Drawable.letter_bg);
                //add to layout
                wordLayout.AddView(charViews[c]);
            }
            ltrAdapt = new LetterAdapter(this);
            letters.SetAdapter(ltrAdapt);

            currPart = 0;
            numChars = currWord.Length;
            numCorr  = 0;

            for (int p = 0; p < numParts; p++)
            {
                bodyParts[p].Visibility = ViewStates.Invisible;
            }
        }
コード例 #2
0
ファイル: Gamenew.cs プロジェクト: rupinder97/Hangman
        private void playGame()
        {
            string newWord = listdata[random.NextInt(listdata.Count)].Name;

            while (newWord.Equals(current))
            {
                newWord = listdata[random.NextInt(listdata.Count)].Name;
            }
            current = newWord;

            charViews = new TextView[current.Length];
            words.RemoveAllViews();

            for (int c = 0; c < current.Length; c++)
            {
                charViews[c]      = new TextView(this);
                charViews[c].Text = current[c] + "";

                charViews[c].LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                charViews[c].Gravity          = GravityFlags.Center;
                charViews[c].SetTextColor(Resources.GetColor(Resource.Color.white));
                charViews[c].SetBackgroundResource(Resource.Drawable.letter_bg);
                words.AddView(charViews[c]);
            }
            adp = new LetterAdapter(this);
            alphabets.SetAdapter(adp);

            currPart  = 0;
            numc      = current.Length;
            corrected = 0;

            for (int p = 0; p < numParts; p++)
            {
                images[p].Visibility  = ViewStates.Visible;
                images2[p].Visibility = ViewStates.Gone;
            }
        }