コード例 #1
0
        public GenWord GetWord(string lvl)
        {
            int lvlIndex = 0;

            if (lvl.Equals("Easy"))
            {
                lvlIndex = 0;
            }
            else if (lvl.Equals("Medium"))
            {
                lvlIndex = 1;
            }
            else if (lvl.Equals("Hard"))
            {
                lvlIndex = 2;
            }
            else
            {
                return(GetRandomWord());
            }

            Random ran   = new Random();
            int    index = ran.Next(0, Words[lvlIndex].Length);

            GenWord gw = new GenWord();

            gw.Word   = Words[lvlIndex][index];
            gw.Points = Levels[lvlIndex];

            return(gw);
        }
コード例 #2
0
            public void DropWord(Canvas obj)
            {
                GenWord   word      = new GenWord();
                TextBlock wordBlock = new TextBlock
                {
                    Width         = 220,
                    FontSize      = 24,
                    TextAlignment = TextAlignment.Center,
                    Text          = word.getWord()
                };

                obj.Children.Add(wordBlock);
                Canvas.SetTop(wordBlock, rnd.Next(200));                        // randomly place the text block
                Canvas.SetLeft(wordBlock, rnd.Next(400));

                DoubleAnimation WordAnimation = new DoubleAnimation();          // create animation for falling words

                WordAnimation.From     = Canvas.GetTop(wordBlock);
                WordAnimation.To       = 405;
                WordAnimation.Duration = new Duration(TimeSpan.FromSeconds(10));

                Storyboard.SetTarget(WordAnimation, wordBlock);
                Storyboard.SetTargetProperty(WordAnimation, new PropertyPath(Canvas.TopProperty));
                Storyboard story = new Storyboard();

                story.Completed += GameController.Instance.Scold;
                story.Completed += (o, s) => { obj.Children.Remove(wordBlock); };
                story.Children.Add(WordAnimation);
                story.Begin();
            }
コード例 #3
0
 private void Init()
 {
     _Stop = true;
     ChangeStatus("init");
     _GenWord = _WordGenerator.GetWord(GameSession.Game.Mode);
     Points   = _GenWord.Points;
     Word     = "**********";
 }
コード例 #4
0
        public GenWord GetRandomWord()
        {
            Random  ran      = new Random();
            int     lvlIndex = ran.Next(0, 2);
            int     index    = ran.Next(0, Words[lvlIndex].Length);
            GenWord gw       = new GenWord();

            gw.Word   = Words[lvlIndex][index];
            gw.Points = Levels[lvlIndex];
            return(gw);
        }