Пример #1
0
        public void Draw(GameTime gameTime, MouseState d, Vector2 position)
        {
            if (!pauseGame)
            {
                string test1 = kanji[CorectKanji].reading;
                string test2 = kanji[CorectKanji].meaning;


                spriteBatch.Begin();

                string score = wins + " / " + round;
                if (replay)
                {
                    score += " [powtórka]";
                }
                spriteBatch.DrawString(text4, score, new Vector2(10, 5), Color.Black);

                // solution
                if (round > 0)
                {
                    Rectangle solutionBox = new Rectangle(GraphicsDevice.Viewport.Width - 200, 5, 180, 37);
                    spriteBatch.Draw(blank, solutionBox, Color.Black);

                    string goodKanji = kanji[goodAnswer].sign;

                    if (correctAnswer)
                    {
                        if ((position.X >= solutionBox.X && position.X <= solutionBox.X + solutionBox.Width) &&
                            (position.Y >= solutionBox.Y && position.Y <= solutionBox.Y + solutionBox.Height))
                        {
                            if (d.LeftButton == ButtonState.Pressed)
                            {
                                spriteBatch.Draw(blank, solutionBox, Color.Green);
                                spriteBatch.DrawString(text5, goodKanji, new Vector2((int)(solutionBox.X + solutionBox.Width / 2 - text5.MeasureString(goodKanji).X / 2), (int)(solutionBox.Y + solutionBox.Height / 2 - text5.MeasureString(goodKanji).Y / 2)), Color.Black);
                                pressed = true;
                            }
                            else if (pressed)
                            {
                                pressed         = false;
                                pauseGame       = true;
                                kanjiList.Index = goodAnswer;
                                kanjiList.SetNewKanjiArea();
                            }
                            else
                            {
                                spriteBatch.Draw(blank, solutionBox, Color.DarkGreen);
                                spriteBatch.DrawString(text5, goodKanji, new Vector2((int)(solutionBox.X + solutionBox.Width / 2 - text5.MeasureString(goodKanji).X / 2), (int)(solutionBox.Y + solutionBox.Height / 2 - text5.MeasureString(goodKanji).Y / 2)), Color.White);
                            }
                        }
                        else
                        {
                            spriteBatch.Draw(blank, solutionBox, Color.Green);
                            spriteBatch.DrawString(text5, goodKanji, new Vector2((int)(solutionBox.X + solutionBox.Width / 2 - text5.MeasureString(goodKanji).X / 2), (int)(solutionBox.Y + solutionBox.Height / 2 - text5.MeasureString(goodKanji).Y / 2)), Color.Black);
                        }
                    }
                    else
                    {
                        string wrongKanji = kanji[wrongAnswer].sign;

                        Rectangle solutionBox1 = new Rectangle((int)solutionBox.X,
                                                               (int)solutionBox.Y,
                                                               (int)solutionBox.Width / 2,
                                                               (int)solutionBox.Height);

                        Rectangle solutionBox2 = new Rectangle((int)(solutionBox.X + solutionBox.Width / 2),
                                                               (int)solutionBox.Y,
                                                               (int)solutionBox.Width / 2,
                                                               (int)solutionBox.Height);

                        if ((position.X >= solutionBox1.X && position.X <= solutionBox1.X + solutionBox1.Width) &&
                            (position.Y >= solutionBox1.Y && position.Y <= solutionBox1.Y + solutionBox1.Height))
                        {
                            if (d.LeftButton == ButtonState.Pressed)
                            {
                                spriteBatch.Draw(blank, solutionBox1, Color.Red);
                                spriteBatch.DrawString(text5, wrongKanji, new Vector2((int)(solutionBox1.X + solutionBox1.Width / 2 - text5.MeasureString(wrongKanji).X / 2), (int)(solutionBox1.Y + solutionBox1.Height / 2 - text5.MeasureString(wrongKanji).Y / 2)), Color.Black);
                                pressed = true;
                            }
                            else if (pressed)
                            {
                                pressed         = false;
                                pauseGame       = true;
                                kanjiList.Index = wrongAnswer;
                            }
                            else
                            {
                                spriteBatch.Draw(blank, solutionBox1, Color.DarkRed);
                                spriteBatch.DrawString(text5, wrongKanji, new Vector2((int)(solutionBox1.X + solutionBox1.Width / 2 - text5.MeasureString(wrongKanji).X / 2), (int)(solutionBox1.Y + solutionBox1.Height / 2 - text5.MeasureString(wrongKanji).Y / 2)), Color.White);
                            }
                        }
                        else
                        {
                            spriteBatch.Draw(blank, solutionBox1, Color.Red);
                            spriteBatch.DrawString(text5, wrongKanji, new Vector2((int)(solutionBox1.X + solutionBox1.Width / 2 - text5.MeasureString(wrongKanji).X / 2), (int)(solutionBox1.Y + solutionBox1.Height / 2 - text5.MeasureString(wrongKanji).Y / 2)), Color.Black);
                        }


                        if ((position.X >= solutionBox2.X && position.X <= solutionBox2.X + solutionBox2.Width) &&
                            (position.Y >= solutionBox2.Y && position.Y <= solutionBox2.Y + solutionBox2.Height))
                        {
                            if (d.LeftButton == ButtonState.Pressed)
                            {
                                spriteBatch.Draw(blank, solutionBox2, Color.Green);
                                spriteBatch.DrawString(text5, goodKanji, new Vector2((int)(solutionBox2.X + solutionBox2.Width / 2 - text5.MeasureString(goodKanji).X / 2), (int)(solutionBox2.Y + solutionBox2.Height / 2 - text5.MeasureString(goodKanji).Y / 2)), Color.Black);
                                pressed = true;
                            }
                            else if (pressed)
                            {
                                pressed         = false;
                                pauseGame       = true;
                                kanjiList.Index = goodAnswer;
                            }
                            else
                            {
                                spriteBatch.Draw(blank, solutionBox2, Color.DarkGreen);
                                spriteBatch.DrawString(text5, goodKanji, new Vector2((int)(solutionBox2.X + solutionBox2.Width / 2 - text5.MeasureString(goodKanji).X / 2), (int)(solutionBox2.Y + solutionBox2.Height / 2 - text5.MeasureString(goodKanji).Y / 2)), Color.White);
                            }
                        }
                        else
                        {
                            spriteBatch.Draw(blank, solutionBox2, Color.Green);
                            spriteBatch.DrawString(text5, goodKanji, new Vector2((int)(solutionBox2.X + solutionBox2.Width / 2 - text5.MeasureString(goodKanji).X / 2), (int)(solutionBox2.Y + solutionBox2.Height / 2 - text5.MeasureString(goodKanji).Y / 2)), Color.Black);
                        }
                    }
                }

                //
                // must "constructVirtualMenu()" -> realized

                spriteBatch.Draw(blank, mainText, Color.White);

                int lineSpacing = 0;

                if (text1.MeasureString(test1).Y > 40)
                {
                    lineSpacing = 5;
                }
                else
                {
                    lineSpacing = 15;
                }

                int textSpacing = lineSpacing + mainText.Y;

                Vector2 meaningPosition = Vector2.Zero;
                if (text1.MeasureString(test1).Y > 40)
                {
                    meaningPosition = new Vector2((int)((mainText.X + mainText.Width / 2) - text6.MeasureString(test1).X / 2), textSpacing);
                    spriteBatch.DrawString(text6, test1, meaningPosition, Color.Black);
                }
                else
                {
                    meaningPosition = new Vector2((int)((mainText.X + mainText.Width / 2) - text1.MeasureString(test1).X / 2), textSpacing);
                    spriteBatch.DrawString(text1, test1, meaningPosition, Color.Black);
                }


                if (text1.MeasureString(test1).Y > 40)
                {
                    textSpacing += (int)(text6.MeasureString(test1).Y + 1);
                }
                else
                {
                    textSpacing += (int)(text1.MeasureString(test1).Y + lineSpacing);
                }

                test2 = "(" + test2 + ")";

                Vector2 readingPosition = new Vector2((int)((mainText.X + mainText.Width / 2) - text2.MeasureString(test2).X / 2), textSpacing);

                spriteBatch.DrawString(text2, test2, readingPosition, Color.Black);

                //
                // must "constructVirtualMenu()" -> realized

                for (int i = 0; i < 6; i++)
                {
                    if ((position.X >= choose[i].X && position.X <= choose[i].X + choose[i].Width &&
                         (position.Y >= choose[i].Y && position.Y <= choose[i].Y + choose[i].Height)))
                    {
                        if (d.LeftButton == ButtonState.Pressed)
                        {
                            spriteBatch.Draw(blank, choose[i], Color.White);
                            spriteBatch.DrawString(text3, kanji[kanjiIndex[i]].sign, new Vector2(choose[i].X + (choose[i].Width / 2) - (text3.MeasureString(kanji[kanjiIndex[i]].sign).X / 2), choose[i].Y + (choose[i].Height / 2) - (text3.MeasureString(kanji[kanjiIndex[i]].sign).Y / 2)), Color.Black);
                            pressed = true;
                        }
                        else if (pressed)
                        {
                            pressed = false;

                            round++;

                            if (i == CorectKanjiIndex)
                            {
                                wins++;
                                correctAnswer = true;
                                goodAnswer    = kanjiIndex[i];

                                if (replay)
                                {
                                    rep.Remove(goodAnswer);
                                }
                            }
                            else
                            {
                                correctAnswer = false;
                                goodAnswer    = kanjiIndex[CorectKanjiIndex];
                                wrongAnswer   = kanjiIndex[i];

                                if (!replay)
                                {
                                    rep.Add(goodAnswer);
                                }
                            }

                            if (!replay)
                            {
                                l_rep++;

                                if (l_rep == max_rep && rep.Count != 0)
                                {
                                    replay = true;
                                }
                                else if (l_rep == max_rep && rep.Count == 0)
                                {
                                    l_rep = 0;
                                }
                            }
                            else
                            {
                                if (rep.Count == 0)
                                {
                                    replay = false;
                                    l_rep  = 0;
                                }
                            }

                            SetKanjiGameRound();
                        }
                        else
                        {
                            spriteBatch.Draw(blank, choose[i], Color.Black);
                            spriteBatch.DrawString(text3, kanji[kanjiIndex[i]].sign, new Vector2(choose[i].X + (choose[i].Width / 2) - (text3.MeasureString(kanji[kanjiIndex[i]].sign).X / 2), choose[i].Y + (choose[i].Height / 2) - (text3.MeasureString(kanji[kanjiIndex[i]].sign).Y / 2)), Color.White);
                        }
                    }
                    else
                    {
                        spriteBatch.Draw(blank, choose[i], Color.White);
                        spriteBatch.DrawString(text3, kanji[kanjiIndex[i]].sign, new Vector2(choose[i].X + (choose[i].Width / 2) - (text3.MeasureString(kanji[kanjiIndex[i]].sign).X / 2), choose[i].Y + (choose[i].Height / 2) - (text3.MeasureString(kanji[kanjiIndex[i]].sign).Y / 2)), Color.Black);
                    }
                }

                spriteBatch.End();
            }
            else
            {
                kanjiList.Draw(gameTime, d, position);
                returnButton(d, position);
            }

            base.Draw(gameTime);
        }
Пример #2
0
        public void Draw(GameTime gameTime, MouseState d, Vector2 position)
        {
            if (!pauseGame && !pauseGame2)
            {
                string test1 = composition[CorectKanji].signs;
                string test2 = "";
                if (showReading)
                {
                    test2 = composition[CorectKanji].reading;
                }

                spriteBatch.Begin();

                string score = wins + " / " + round;
                spriteBatch.DrawString(text4, score, new Vector2(10, 5), Color.Black);

                // solution
                if (round > 0)
                {
                    Rectangle solutionBox = new Rectangle(GraphicsDevice.Viewport.Width - 320, 5, 300, 37);
                    spriteBatch.Draw(blank, solutionBox, Color.Black);

                    string goodKanji = composition[goodAnswer].signs;

                    if (correctAnswer)
                    {
                        if ((position.X >= solutionBox.X && position.X <= solutionBox.X + solutionBox.Width) &&
                            (position.Y >= solutionBox.Y && position.Y <= solutionBox.Y + solutionBox.Height))
                        {
                            if (d.LeftButton == ButtonState.Pressed)
                            {
                                spriteBatch.Draw(blank, solutionBox, Color.Green);
                                spriteBatch.DrawString(text5, goodKanji, new Vector2((int)(solutionBox.X + solutionBox.Width / 2 - text5.MeasureString(goodKanji).X / 2), (int)(solutionBox.Y + solutionBox.Height / 2 - text5.MeasureString(goodKanji).Y / 2)), Color.Black);
                                pressed = true;
                            }
                            else if (pressed)
                            {
                                pressed         = false;
                                pauseGame       = true;
                                kanjiList.Index = goodKanjiAnswer;
                                kanjiList.SetNewKanjiArea();
                            }
                            else
                            {
                                spriteBatch.Draw(blank, solutionBox, Color.DarkGreen);
                                spriteBatch.DrawString(text5, goodKanji, new Vector2((int)(solutionBox.X + solutionBox.Width / 2 - text5.MeasureString(goodKanji).X / 2), (int)(solutionBox.Y + solutionBox.Height / 2 - text5.MeasureString(goodKanji).Y / 2)), Color.White);
                            }
                        }
                        else
                        {
                            spriteBatch.Draw(blank, solutionBox, Color.Green);
                            spriteBatch.DrawString(text5, goodKanji, new Vector2((int)(solutionBox.X + solutionBox.Width / 2 - text5.MeasureString(goodKanji).X / 2), (int)(solutionBox.Y + solutionBox.Height / 2 - text5.MeasureString(goodKanji).Y / 2)), Color.Black);
                        }
                    }
                    else
                    {
                        string wrongKanji = composition[wrongAnswer].signs;

                        Rectangle solutionBox1 = new Rectangle((int)solutionBox.X,
                                                               (int)solutionBox.Y,
                                                               (int)solutionBox.Width / 2,
                                                               (int)solutionBox.Height);

                        Rectangle solutionBox2 = new Rectangle((int)(solutionBox.X + solutionBox.Width / 2),
                                                               (int)solutionBox.Y,
                                                               (int)solutionBox.Width / 2,
                                                               (int)solutionBox.Height);

                        if ((position.X >= solutionBox1.X && position.X <= solutionBox1.X + solutionBox1.Width) &&
                            (position.Y >= solutionBox1.Y && position.Y <= solutionBox1.Y + solutionBox1.Height))
                        {
                            if (d.LeftButton == ButtonState.Pressed)
                            {
                                spriteBatch.Draw(blank, solutionBox1, Color.Red);
                                spriteBatch.DrawString(text5, wrongKanji, new Vector2((int)(solutionBox1.X + solutionBox1.Width / 2 - text5.MeasureString(wrongKanji).X / 2), (int)(solutionBox1.Y + solutionBox1.Height / 2 - text5.MeasureString(wrongKanji).Y / 2)), Color.Black);
                                pressed = true;
                            }
                            else if (pressed)
                            {
                                pressed         = false;
                                pauseGame       = true;
                                kanjiList.Index = wrongKanjiAnswer;
                            }
                            else
                            {
                                spriteBatch.Draw(blank, solutionBox1, Color.DarkRed);
                                spriteBatch.DrawString(text5, wrongKanji, new Vector2((int)(solutionBox1.X + solutionBox1.Width / 2 - text5.MeasureString(wrongKanji).X / 2), (int)(solutionBox1.Y + solutionBox1.Height / 2 - text5.MeasureString(wrongKanji).Y / 2)), Color.White);
                            }
                        }
                        else
                        {
                            spriteBatch.Draw(blank, solutionBox1, Color.Red);
                            spriteBatch.DrawString(text5, wrongKanji, new Vector2((int)(solutionBox1.X + solutionBox1.Width / 2 - text5.MeasureString(wrongKanji).X / 2), (int)(solutionBox1.Y + solutionBox1.Height / 2 - text5.MeasureString(wrongKanji).Y / 2)), Color.Black);
                        }


                        if ((position.X >= solutionBox2.X && position.X <= solutionBox2.X + solutionBox2.Width) &&
                            (position.Y >= solutionBox2.Y && position.Y <= solutionBox2.Y + solutionBox2.Height))
                        {
                            if (d.LeftButton == ButtonState.Pressed)
                            {
                                spriteBatch.Draw(blank, solutionBox2, Color.Green);
                                spriteBatch.DrawString(text5, goodKanji, new Vector2((int)(solutionBox2.X + solutionBox2.Width / 2 - text5.MeasureString(goodKanji).X / 2), (int)(solutionBox2.Y + solutionBox2.Height / 2 - text5.MeasureString(goodKanji).Y / 2)), Color.Black);
                                pressed = true;
                            }
                            else if (pressed)
                            {
                                pressed         = false;
                                pauseGame       = true;
                                kanjiList.Index = goodKanjiAnswer;
                            }
                            else
                            {
                                spriteBatch.Draw(blank, solutionBox2, Color.DarkGreen);
                                spriteBatch.DrawString(text5, goodKanji, new Vector2((int)(solutionBox2.X + solutionBox2.Width / 2 - text5.MeasureString(goodKanji).X / 2), (int)(solutionBox2.Y + solutionBox2.Height / 2 - text5.MeasureString(goodKanji).Y / 2)), Color.White);
                            }
                        }
                        else
                        {
                            spriteBatch.Draw(blank, solutionBox2, Color.Green);
                            spriteBatch.DrawString(text5, goodKanji, new Vector2((int)(solutionBox2.X + solutionBox2.Width / 2 - text5.MeasureString(goodKanji).X / 2), (int)(solutionBox2.Y + solutionBox2.Height / 2 - text5.MeasureString(goodKanji).Y / 2)), Color.Black);
                        }
                    }
                }

                //
                // must "constructVirtualMenu()" -> realized

                spriteBatch.Draw(blank, mainText, Color.White);

                int lineSpacing = 15;

                int textSpacing = lineSpacing + mainText.Y;

                Vector2 meaningPosition = new Vector2((int)((mainText.X + mainText.Width / 2) - text3.MeasureString(test1).X / 2), textSpacing);

                spriteBatch.DrawString(text3, test1, meaningPosition, Color.Black);


                if (showReading)
                {
                    textSpacing += (int)(text3.MeasureString(test1).Y + lineSpacing);

                    test2 = "(" + test2 + ")";

                    Vector2 readingPosition = new Vector2((int)((mainText.X + mainText.Width / 2) - text5.MeasureString(test2).X / 2), textSpacing);

                    spriteBatch.DrawString(text5, test2, readingPosition, Color.Black);
                }

                //
                // must "constructVirtualMenu()" -> realized

                for (int i = 0; i < 6; i++)
                {
                    if ((position.X >= choose[i].X && position.X <= choose[i].X + choose[i].Width &&
                         (position.Y >= choose[i].Y && position.Y <= choose[i].Y + choose[i].Height)))
                    {
                        if (d.LeftButton == ButtonState.Pressed)
                        {
                            spriteBatch.Draw(blank, choose[i], Color.White);
                            spriteBatch.DrawString(text6, composition[kanjiIndex[i]].meaning, new Vector2(choose[i].X + (choose[i].Width / 2) - (text6.MeasureString(composition[kanjiIndex[i]].meaning).X / 2), choose[i].Y + (choose[i].Height / 2) - (text6.MeasureString(composition[kanjiIndex[i]].meaning).Y / 2)), Color.Black);
                            pressed = true;
                        }
                        else if (pressed)
                        {
                            pressed = false;

                            round++;

                            if (i == CorectKanjiIndex)
                            {
                                wins++;
                                correctAnswer   = true;
                                goodAnswer      = kanjiIndex[i];
                                goodKanjiAnswer = compositionIndex[goodAnswer];
                            }
                            else
                            {
                                correctAnswer    = false;
                                goodAnswer       = kanjiIndex[CorectKanjiIndex];
                                goodKanjiAnswer  = compositionIndex[goodAnswer];
                                wrongAnswer      = kanjiIndex[i];
                                wrongKanjiAnswer = compositionIndex[wrongAnswer];
                            }

                            SetKanjiGameRound();
                        }
                        else
                        {
                            spriteBatch.Draw(blank, choose[i], Color.Black);
                            spriteBatch.DrawString(text6, composition[kanjiIndex[i]].meaning, new Vector2(choose[i].X + (choose[i].Width / 2) - (text6.MeasureString(composition[kanjiIndex[i]].meaning).X / 2), choose[i].Y + (choose[i].Height / 2) - (text6.MeasureString(composition[kanjiIndex[i]].meaning).Y / 2)), Color.White);
                        }
                    }
                    else
                    {
                        spriteBatch.Draw(blank, choose[i], Color.White);
                        spriteBatch.DrawString(text6, composition[kanjiIndex[i]].meaning, new Vector2(choose[i].X + (choose[i].Width / 2) - (text6.MeasureString(composition[kanjiIndex[i]].meaning).X / 2), choose[i].Y + (choose[i].Height / 2) - (text6.MeasureString(composition[kanjiIndex[i]].meaning).Y / 2)), Color.Black);
                    }
                }

                spriteBatch.End();

                compositionListButton(d, position);
            }
            else
            {
                if (pauseGame)
                {
                    kanjiList.Draw(gameTime, d, position);
                }
                else if (pauseGame2)
                {
                    compList.Draw(gameTime, d, position);
                }

                returnButton(d, position);
            }

            base.Draw(gameTime);
        }